Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2449)

Unified Diff: ash/common/system/chromeos/brightness/tray_brightness.cc

Issue 2482043002: [ash-md] Updated layout of Brightness and Audio system menu rows to the material design spec. (Closed)
Patch Set: Fixed the volume slider to transition to the detailed view on <return> keypress. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/audio/volume_view.cc ('k') | ash/common/system/tray/actionable_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/chromeos/brightness/tray_brightness.cc
diff --git a/ash/common/system/chromeos/brightness/tray_brightness.cc b/ash/common/system/chromeos/brightness/tray_brightness.cc
index e02d3b17388392c3cb70f6cf7ab2828c21a0db03..4f90583f9511a2119699e31f875fe740fae81993 100644
--- a/ash/common/system/chromeos/brightness/tray_brightness.cc
+++ b/ash/common/system/chromeos/brightness/tray_brightness.cc
@@ -6,13 +6,12 @@
#include <algorithm>
-#include "ash/common/ash_constants.h"
#include "ash/common/material_design/material_design_controller.h"
#include "ash/common/shell_observer.h"
#include "ash/common/system/brightness_control_delegate.h"
-#include "ash/common/system/tray/fixed_sized_image_view.h"
-#include "ash/common/system/tray/system_tray_delegate.h"
#include "ash/common/system/tray/tray_constants.h"
+#include "ash/common/system/tray/tray_popup_utils.h"
+#include "ash/common/system/tray/tri_view.h"
#include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/common/wm_shell.h"
#include "ash/resources/vector_icons/vector_icons.h"
@@ -27,12 +26,10 @@
#include "ui/display/display.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/paint_vector_icon.h"
-#include "ui/views/border.h"
-#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/slider.h"
-#include "ui/views/layout/box_layout.h"
+#include "ui/views/layout/fill_layout.h"
#include "ui/views/view.h"
namespace ash {
@@ -99,13 +96,15 @@ BrightnessView::BrightnessView(bool default_view, double initial_percent)
: dragging_(false),
is_default_view_(default_view),
last_percent_(initial_percent) {
- SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal,
- kTrayPopupPaddingHorizontal, 0,
- kTrayPopupPaddingBetweenItems));
+ SetLayoutManager(new views::FillLayout);
+ // Use CreateMultiTargetRowView() instead of CreateDefaultRowView() because
+ // that's what the audio row uses and we want the two rows to layout with the
+ // same insets.
+ TriView* tri_view = TrayPopupUtils::CreateMultiTargetRowView();
+ AddChildView(tri_view);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- views::ImageView* icon =
- new FixedSizedImageView(0, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT));
+ views::ImageView* icon = TrayPopupUtils::CreateMainImageView();
if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
icon->SetImage(
gfx::CreateVectorIcon(kSystemMenuBrightnessIcon, kMenuIconColor));
@@ -113,18 +112,13 @@ BrightnessView::BrightnessView(bool default_view, double initial_percent)
icon->SetImage(
rb.GetImageNamed(IDR_AURA_UBER_TRAY_BRIGHTNESS).ToImageSkia());
}
- AddChildView(icon);
- slider_ = views::Slider::CreateSlider(
- ash::MaterialDesignController::IsSystemTrayMenuMaterial(), this);
- if (ash::MaterialDesignController::IsSystemTrayMenuMaterial()) {
- slider_->SetBorder(views::CreateEmptyBorder(
- gfx::Insets(0, kTrayPopupSliderPaddingMD) + slider_->GetInsets()));
- }
- slider_->set_focus_border_color(kFocusBorderColor);
+ tri_view->AddView(TriView::Container::START, icon);
+
+ slider_ = TrayPopupUtils::CreateSlider(this);
slider_->SetValue(static_cast<float>(initial_percent / 100.0));
slider_->SetAccessibleName(
rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BRIGHTNESS));
- AddChildView(slider_);
+ tri_view->AddView(TriView::Container::CENTER, slider_);
if (MaterialDesignController::IsSystemTrayMenuMaterial()) {
SetVisible(true);
@@ -136,6 +130,9 @@ BrightnessView::BrightnessView(bool default_view, double initial_percent)
->IsMaximizeModeWindowManagerEnabled());
}
}
+
+ if (!is_default_view_)
+ tri_view->SetContainerVisible(TriView::Container::END, false);
}
BrightnessView::~BrightnessView() {
« no previous file with comments | « ash/common/system/audio/volume_view.cc ('k') | ash/common/system/tray/actionable_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698