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

Side by Side Diff: ui/views/controls/button/label_button.h

Issue 11262002: Merge TextButton and LabelButton border images util structs, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add friend tests, remove unused variable. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/button/border_images.cc ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_
6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ 6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "third_party/skia/include/core/SkColor.h" 9 #include "third_party/skia/include/core/SkColor.h"
10 #include "ui/gfx/image/image_skia.h" 10 #include "ui/gfx/image/image_skia.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 void set_max_size(const gfx::Size& max_size) { max_size_ = max_size; } 48 void set_max_size(const gfx::Size& max_size) { max_size_ = max_size; }
49 49
50 // Get or set the option to handle the return key; false by default. 50 // Get or set the option to handle the return key; false by default.
51 bool default_button() const { return default_button_; } 51 bool default_button() const { return default_button_; }
52 void SetDefaultButton(bool default_button); 52 void SetDefaultButton(bool default_button);
53 53
54 // Get or set the option to use a native button appearance; false by default. 54 // Get or set the option to use a native button appearance; false by default.
55 bool native_theme() const { return native_theme_; } 55 bool native_theme() const { return native_theme_; }
56 void SetNativeTheme(bool native_theme); 56 void SetNativeTheme(bool native_theme);
57 57
58 private:
59 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Init);
60 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Label);
61 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Image);
62 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, LabelAndImage);
63
58 // Overridden from CustomButton: 64 // Overridden from CustomButton:
59 virtual void StateChanged() OVERRIDE; 65 virtual void StateChanged() OVERRIDE;
60 66
61 // Overridden from View: 67 // Overridden from View:
62 virtual gfx::Size GetPreferredSize() OVERRIDE; 68 virtual gfx::Size GetPreferredSize() OVERRIDE;
63 virtual void Layout() OVERRIDE; 69 virtual void Layout() OVERRIDE;
64 virtual std::string GetClassName() const OVERRIDE; 70 virtual std::string GetClassName() const OVERRIDE;
65 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; 71 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE;
66 72
67 protected:
68 // Overridden from NativeThemeDelegate: 73 // Overridden from NativeThemeDelegate:
69 virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE; 74 virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE;
70 virtual gfx::Rect GetThemePaintRect() const OVERRIDE; 75 virtual gfx::Rect GetThemePaintRect() const OVERRIDE;
71 virtual ui::NativeTheme::State GetThemeState( 76 virtual ui::NativeTheme::State GetThemeState(
72 ui::NativeTheme::ExtraParams* params) const OVERRIDE; 77 ui::NativeTheme::ExtraParams* params) const OVERRIDE;
73 virtual const ui::Animation* GetThemeAnimation() const OVERRIDE; 78 virtual const ui::Animation* GetThemeAnimation() const OVERRIDE;
74 virtual ui::NativeTheme::State GetBackgroundThemeState( 79 virtual ui::NativeTheme::State GetBackgroundThemeState(
75 ui::NativeTheme::ExtraParams* params) const OVERRIDE; 80 ui::NativeTheme::ExtraParams* params) const OVERRIDE;
76 virtual ui::NativeTheme::State GetForegroundThemeState( 81 virtual ui::NativeTheme::State GetForegroundThemeState(
77 ui::NativeTheme::ExtraParams* params) const OVERRIDE; 82 ui::NativeTheme::ExtraParams* params) const OVERRIDE;
78 83
79 // Fill |params| with information about the button. 84 // Fill |params| with information about the button.
80 virtual void GetExtraParams(ui::NativeTheme::ExtraParams* params) const; 85 virtual void GetExtraParams(ui::NativeTheme::ExtraParams* params) const;
81 86
82 private:
83 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Init);
84 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, LabelAndImage);
85
86 // The image and label shown in the button. 87 // The image and label shown in the button.
87 ImageView* image_; 88 ImageView* image_;
88 Label* label_; 89 Label* label_;
89 90
90 // The images and colors for each button state. 91 // The images and colors for each button state.
91 gfx::ImageSkia button_state_images_[BS_COUNT]; 92 gfx::ImageSkia button_state_images_[BS_COUNT];
92 SkColor button_state_colors_[BS_COUNT]; 93 SkColor button_state_colors_[BS_COUNT];
93 94
94 // |min_size_| increases monotonically with the preferred size. 95 // |min_size_| increases monotonically with the preferred size.
95 gfx::Size min_size_; 96 gfx::Size min_size_;
96 // |max_size_| may be set to clamp the preferred size. 97 // |max_size_| may be set to clamp the preferred size.
97 gfx::Size max_size_; 98 gfx::Size max_size_;
98 99
99 // Flag indicating default handling of the return key via an accelerator. 100 // Flag indicating default handling of the return key via an accelerator.
100 bool default_button_; 101 bool default_button_;
101 102
102 // Flag indicating native theme styling (or Views styling) of the button. 103 // Flag indicating native theme styling (or Views styling) of the button.
103 bool native_theme_; 104 bool native_theme_;
104 105
105 DISALLOW_COPY_AND_ASSIGN(LabelButton); 106 DISALLOW_COPY_AND_ASSIGN(LabelButton);
106 }; 107 };
107 108
108 } // namespace views 109 } // namespace views
109 110
110 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ 111 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_
OLDNEW
« no previous file with comments | « ui/views/controls/button/border_images.cc ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698