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

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

Issue 2487603005: Adjust TriView. (Closed)
Patch Set: 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
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 2e71ff246b63110803b076492721e82f88dc7430..763ef367031445792a94f9d4326564c110ac98f8 100644
--- a/ash/common/system/tray/tray_popup_utils.cc
+++ b/ash/common/system/tray/tray_popup_utils.cc
@@ -39,16 +39,29 @@ std::unique_ptr<views::LayoutManager> CreateDefaultCenterLayoutManager() {
return std::unique_ptr<views::LayoutManager>(box_layout);
}
-// Creates a layout manager that positions Views horizontally. The Views will be
bruthig 2016/11/10 18:33:40 Just as a heads up this CL: https://codereview.chr
Evan Stade 2016/11/10 19:18:05 Acknowledged.
-// 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);
- box_layout->set_main_axis_alignment(
- views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER);
- box_layout->set_cross_axis_alignment(
- views::BoxLayout::CROSS_AXIS_ALIGNMENT_STRETCH);
Evan Stade 2016/11/09 23:32:15 The code does not match the comment above the func
- return std::unique_ptr<views::LayoutManager>(box_layout);
+void ConfigureDefaultLayout(TriView* tri_view, TriView::Container container) {
Evan Stade 2016/11/09 23:32:15 the rest of the changes in this file allow the cen
+ const int min_height = GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT);
+ switch (container) {
+ case TriView::Container::START:
+ tri_view->SetMinSize(
+ TriView::Container::START,
+ gfx::Size(GetTrayConstant(TRAY_POPUP_ITEM_MIN_START_WIDTH),
+ min_height));
+ break;
+ case TriView::Container::CENTER:
+ tri_view->SetContainerLayout(container,
+ CreateDefaultCenterLayoutManager());
+ tri_view->SetFlexForContainer(TriView::Container::CENTER, 1.f);
+ tri_view->SetMinSize(TriView::Container::CENTER,
+ gfx::Size(0, min_height));
+ break;
+ case TriView::Container::END:
+ tri_view->SetMinSize(
+ TriView::Container::END,
+ gfx::Size(GetTrayConstant(TRAY_POPUP_ITEM_MIN_END_WIDTH),
+ min_height));
+ break;
+ }
}
class BorderlessLabelButton : public views::LabelButton {
@@ -104,7 +117,6 @@ TriView* TrayPopupUtils::CreateDefaultRowView() {
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));
ConfigureDefaultLayout(tri_view, TriView::Container::START);
ConfigureDefaultLayout(tri_view, TriView::Container::CENTER);
@@ -113,20 +125,6 @@ TriView* TrayPopupUtils::CreateDefaultRowView() {
return tri_view;
}
-std::unique_ptr<views::LayoutManager> TrayPopupUtils::CreateLayoutManager(
- 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;
-}
-
views::Label* TrayPopupUtils::CreateDefaultLabel() {
views::Label* label = new views::Label();
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
@@ -193,25 +191,4 @@ bool TrayPopupUtils::CanOpenWebUISettings(LoginStatus status) {
!WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen();
}
-void TrayPopupUtils::ConfigureDefaultLayout(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;
- }
-
- tri_view->SetContainerLayout(container, CreateLayoutManager(container));
-}
-
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698