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

Unified Diff: ash/common/system/tray/tray_popup_utils.cc

Issue 2487603005: Adjust TriView. (Closed)
Patch Set: merge 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/tray/tray_popup_utils.h ('k') | ash/common/system/tray/tri_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/tray/tray_popup_utils.cc
diff --git a/ash/common/system/tray/tray_popup_utils.cc b/ash/common/system/tray/tray_popup_utils.cc
index 3864fa8dd9891be18cc259886a6ad09ca8ffa947..b1a2735fa0abc7e3e3e86ef8d74e0c94cd821348 100644
--- a/ash/common/system/tray/tray_popup_utils.cc
+++ b/ash/common/system/tray/tray_popup_utils.cc
@@ -32,25 +32,60 @@ namespace {
// stretched horizontally and centered vertically.
std::unique_ptr<views::LayoutManager> CreateDefaultCenterLayoutManager() {
// TODO(bruthig): Use constants instead of magic numbers.
- views::BoxLayout* box_layout =
- new views::BoxLayout(views::BoxLayout::kVertical, 4, 8, 4);
+ auto box_layout =
+ base::MakeUnique<views::BoxLayout>(views::BoxLayout::kVertical, 4, 8, 4);
box_layout->set_main_axis_alignment(
views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER);
box_layout->set_cross_axis_alignment(
views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH);
- return std::unique_ptr<views::LayoutManager>(box_layout);
+ return std::move(box_layout);
}
// Creates a layout manager that positions Views horizontally. The Views will be
// centered along the horizontal and vertical axis.
std::unique_ptr<views::LayoutManager> CreateDefaultEndsLayoutManager() {
- views::BoxLayout* box_layout =
- new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
+ auto box_layout = base::MakeUnique<views::BoxLayout>(
+ views::BoxLayout::kHorizontal, 0, 0, 0);
box_layout->set_main_axis_alignment(
views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER);
box_layout->set_cross_axis_alignment(
- views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH);
- return std::unique_ptr<views::LayoutManager>(box_layout);
+ views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
+ return std::move(box_layout);
+}
+
+std::unique_ptr<views::LayoutManager> CreateDefaultLayoutManager(
+ TriView::Container container) {
+ switch (container) {
+ case TriView::Container::START:
+ case TriView::Container::END:
+ return CreateDefaultEndsLayoutManager();
+ case TriView::Container::CENTER:
+ return CreateDefaultCenterLayoutManager();
+ }
+ // Required by some compilers.
+ NOTREACHED();
+ return nullptr;
+}
+
+// Configures the default size and flex value for the specified |container|
+// of the given |tri_view|. Used by CreateDefaultRowView().
+void ConfigureDefaultSizeAndFlex(TriView* tri_view,
+ TriView::Container container) {
+ int min_width = 0;
+ switch (container) {
+ case TriView::Container::START:
+ min_width = GetTrayConstant(TRAY_POPUP_ITEM_MIN_START_WIDTH);
+ break;
+ case TriView::Container::CENTER:
+ tri_view->SetFlexForContainer(TriView::Container::CENTER, 1.f);
+ break;
+ case TriView::Container::END:
+ min_width = GetTrayConstant(TRAY_POPUP_ITEM_MIN_END_WIDTH);
+ break;
+ }
+
+ tri_view->SetMinSize(
+ container, gfx::Size(min_width, GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT)));
}
class BorderlessLabelButton : public views::LabelButton {
@@ -128,7 +163,6 @@ TriView* TrayPopupUtils::CreateMultiTargetRowView() {
tri_view->SetInsets(
gfx::Insets(0, GetTrayConstant(TRAY_POPUP_ITEM_LEFT_INSET), 0,
GetTrayConstant(TRAY_POPUP_ITEM_RIGHT_INSET)));
- tri_view->SetMinCrossAxisSize(GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT));
ConfigureDefaultSizeAndFlex(tri_view, TriView::Container::START);
ConfigureDefaultSizeAndFlex(tri_view, TriView::Container::CENTER);
@@ -197,25 +231,6 @@ void TrayPopupUtils::ConfigureContainer(TriView::Container container,
CreateDefaultLayoutManager(container).release());
}
-void TrayPopupUtils::ConfigureDefaultSizeAndFlex(TriView* tri_view,
- TriView::Container container) {
- switch (container) {
- case TriView::Container::START:
- tri_view->SetMinSize(
- TriView::Container::START,
- gfx::Size(GetTrayConstant(TRAY_POPUP_ITEM_MIN_START_WIDTH), 0));
- break;
- case TriView::Container::CENTER:
- tri_view->SetFlexForContainer(TriView::Container::CENTER, 1.f);
- break;
- case TriView::Container::END:
- tri_view->SetMinSize(
- TriView::Container::END,
- gfx::Size(GetTrayConstant(TRAY_POPUP_ITEM_MIN_END_WIDTH), 0));
- break;
- }
-}
-
views::LabelButton* TrayPopupUtils::CreateTrayPopupBorderlessButton(
views::ButtonListener* listener,
const base::string16& text) {
@@ -250,20 +265,6 @@ bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) {
!WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen();
}
-std::unique_ptr<views::LayoutManager>
-TrayPopupUtils::CreateDefaultLayoutManager(TriView::Container container) {
- switch (container) {
- case TriView::Container::START:
- case TriView::Container::END:
- return CreateDefaultEndsLayoutManager();
- case TriView::Container::CENTER:
- return CreateDefaultCenterLayoutManager();
- }
- // Required by some compilers.
- NOTREACHED();
- return nullptr;
-}
-
std::unique_ptr<views::Border> TrayPopupUtils::CreateDefaultBorder(
TriView::Container container) {
switch (container) {
« no previous file with comments | « ash/common/system/tray/tray_popup_utils.h ('k') | ash/common/system/tray/tri_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698