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

Side by Side Diff: ash/common/system/tray/tray_popup_utils.h

Issue 2482043002: [ash-md] Updated layout of Brightness and Audio system menu rows to the material design spec. (Closed)
Patch Set: Some polish after self review. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_UTILS_H_ 5 #ifndef ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_UTILS_H_
6 #define ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_UTILS_H_ 6 #define ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_UTILS_H_
7 7
8 #include "ash/common/system/tray/tri_view.h" 8 #include "ash/common/system/tray/tri_view.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 10
11 namespace views { 11 namespace views {
12 class Border;
12 class ButtonListener; 13 class ButtonListener;
13 class ImageView; 14 class ImageView;
14 class Label; 15 class Label;
15 class LabelButton; 16 class LabelButton;
16 class LayoutManager; 17 class LayoutManager;
17 class Slider; 18 class Slider;
18 class SliderListener; 19 class SliderListener;
19 } // namespace views 20 } // namespace views
20 21
21 namespace ash { 22 namespace ash {
22 23
23 // Factory/utility functions used by the system menu. 24 // Factory/utility functions used by the system menu.
24 class TrayPopupUtils { 25 class TrayPopupUtils {
25 public: 26 public:
26 // Creates a default container view to be used most system menu rows. The 27 // Creates a default container view to be used by system menu rows that are
27 // caller takes over ownership of the created view. 28 // either a single targetable area or not targetable at all. The caller takes
29 // over ownership of the created view.
28 // 30 //
29 // The returned view consists of 3 regions: START, CENTER, and END. Any child 31 // The returned view consists of 3 regions: START, CENTER, and END. Any child
30 // Views added to the START and END containers will be added horizonatlly and 32 // Views added to the START and END containers will be added horizontally and
31 // any Views added to the CENTER container will be added vertically. 33 // any Views added to the CENTER container will be added vertically.
32 // 34 //
33 // The START and END containers have a fixed width but can grow into the 35 // The START and END containers have a fixed minimum width but can grow into
34 // CENTER container if space is required and available. 36 // the CENTER container if space is required and available.
35 // 37 //
36 // The CENTER container has a flexible width. 38 // The CENTER container has a flexible width.
37 static TriView* CreateDefaultRowView(); 39 static TriView* CreateDefaultRowView();
38 40
39 // Creates the default layout manager by CreateDefault() row for the given 41 // Creates a container view to be used by system menu rows that want to embed
40 // |container|. To be used when mutliple targetable areas are required within 42 // a targetable area within one (or more) of the containers OR by any row
41 // a single row. 43 // that requires a non-default layout within the container views. The returned
42 static std::unique_ptr<views::LayoutManager> CreateLayoutManager( 44 // view will have the following configurations:
43 TriView::Container container); 45 // - default minimum row height
46 // - default minimum width for the START and END containers
47 // - default left and right insets
48 // - default container flex values
49 // - Each container view will have a FillLayout installed on it
50 //
51 // The caller takes over ownership of the created view.
52 //
53 // The START and END containers have a fixed minimum width but can grow into
54 // the CENTER container if space is required and available. The CENTER
55 // container has a flexible width.
56 //
57 // Clients can use ConfigureContainer() to configure their own container views
58 // before adding them to the returned TriView.
59 static TriView* CreateMultiTargetRowView();
44 60
45 // Returns a label that has been configured for system menu layout. This 61 // Returns a label that has been configured for system menu layout. This
46 // should be used by all rows that require a label, i.e. both default and 62 // should be used by all rows that require a label, i.e. both default and
47 // detailed rows should use this. 63 // detailed rows should use this.
48 // 64 //
49 // TODO(bruthig): Update all system menu rows to use this. 65 // TODO(bruthig): Update all system menu rows to use this.
50 static views::Label* CreateDefaultLabel(); 66 static views::Label* CreateDefaultLabel();
51 67
52 // Returns an image view to be used for the main image of a system menu row. 68 // Returns an image view to be used in the main image region of a system menu
53 // This should be used by all rows that have a main image, i.e. both default 69 // row. This should be used by all rows that have a main image, i.e. both
54 // and detailed rows should use this. 70 // default and detailed rows should use this.
55 // 71 //
56 // TODO(bruthig): Update all system menu rows to use this. 72 // TODO(bruthig): Update all system menu rows to use this.
57 static views::ImageView* CreateMainImageView(); 73 static views::ImageView* CreateMainImageView();
58 74
59 // Returns an image view to be used for the 'more' arrow image on rows. In 75 // Returns an image view to be used in the 'more' region of default rows. This
60 // general this applies to all rows in the system menu that have a 'more' 76 // is used for all 'more' images as well as other images that appear in this
61 // image however most, if not all, are default rows. 77 // region, e.g. audio output icon.
62 // 78 //
63 // TODO(bruthig): Update all default rows to use this. 79 // TODO(bruthig): Update all default rows to use this.
64 static views::ImageView* CreateMoreImageView(); 80 static views::ImageView* CreateMoreImageView();
65 81
82 // Returns a slider configured for proper layout within a TriView container
83 // with a FillLayout.
84 static views::Slider* CreateSlider(views::SliderListener* listener);
85
86 // Configures |container_view| just like CreateDefaultRowView() would
87 // configure on the returned TriView for the given |container|. To be used
tdanderson 2016/11/09 01:38:33 wording: "... just like CreateDefaultRowView() wou
bruthig 2016/11/10 02:54:54 Done.
88 // when mutliple targetable areas are required within a single row.
89 static void ConfigureContainer(TriView::Container container,
90 views::View* container_view);
91
66 private: 92 private:
67 TrayPopupUtils() = delete; 93 TrayPopupUtils() = delete;
68 ~TrayPopupUtils() = delete; 94 ~TrayPopupUtils() = delete;
69 95
70 // Configures the specified |container| view with the default layout. Used by 96 // Configures the default size and flex value for the specified |container|
71 // CreateDefaultRowView(). 97 // of the given |tri_view|. Used by CreateDefaultRowView().
72 static void ConfigureDefaultLayout(TriView* tri_view, 98 static void ConfigureDefaultSizeAndFlex(TriView* tri_view,
73 TriView::Container container); 99 TriView::Container container);
100
101 // Returns the default layout manager used by CreateDefaultRowView() and
102 // ConfigureContainer() for the given |container|.
103 static std::unique_ptr<views::LayoutManager> CreateDefaultLayoutManager(
104 TriView::Container container);
105
106 // Returns the default border used by CreateDefaultRow() and
107 // ConfigureContainer() for the given |container|.
108 static std::unique_ptr<views::Border> CreateDefaultBorder(
109 TriView::Container container);
74 }; 110 };
75 111
76 } // namespace ash 112 } // namespace ash
77 113
78 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_UTILS_H_ 114 #endif // ASH_COMMON_SYSTEM_TRAY_TRAY_POPUP_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698