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

Unified Diff: ui/views/controls/button/label_button.h

Issue 1216673005: views::LabelButton should not call virtual methods from its constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20150703-Views-ButtonBorderRefactor
Patch Set: self review Created 5 years, 5 months 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 | « ui/views/controls/button/custom_button_unittest.cc ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/button/label_button.h
diff --git a/ui/views/controls/button/label_button.h b/ui/views/controls/button/label_button.h
index 2efd5b11f7d273e19eba4cdc95bbac37e5f4eee5..842b4fb2b962749bf45c7f8ea1022405edce0b96 100644
--- a/ui/views/controls/button/label_button.h
+++ b/ui/views/controls/button/label_button.h
@@ -28,9 +28,25 @@ class VIEWS_EXPORT LabelButton : public CustomButton,
static const char kViewClassName[];
+ // Construct an uninitialized LabelButton with a Listener. Client code must
+ // also call InitAsTextbutton() or InitAsButton() to initialize the
+ // (possibly themed) button borders.
+ explicit LabelButton(ButtonListener* listener);
+
+ // Deprecated (calls virtual methods). TODO(tapted): Remove this overload.
LabelButton(ButtonListener* listener, const base::string16& text);
+
~LabelButton() override;
+ // Initializes the LabelButton with STYLE_TEXTBUTTON. If borders have not been
+ // set with SetBorder(), creates default themed borders. These may also be
+ // customized by a subclass via CreateDefaultBorder().
+ void InitAsTextbutton(const base::string16& text);
+
+ // Initializes with STYLE_BUTTON and creates default borders if SetBorder()
+ // has not already been called.
+ void InitAsButton(const base::string16& text);
+
// Get or set the image shown for the specified button state.
// GetImage returns the image for STATE_NORMAL if the state's image is empty.
virtual const gfx::ImageSkia& GetImage(ButtonState for_state);
@@ -73,8 +89,11 @@ class VIEWS_EXPORT LabelButton : public CustomButton,
bool is_default() const { return is_default_; }
void SetIsDefault(bool is_default);
- // Get or set the button's overall style; the default is |STYLE_TEXTBUTTON|.
+ // Gets the button's overall style.
ButtonStyle style() const { return style_; }
+
+ // Sets the button style and updates (possibly themed) borders. TODO(tapted):
+ // Make this method protected after callers have switched to InitAsButton().
void SetStyle(ButtonStyle style);
// Set the spacing between the image and the text. Shrinking the spacing
@@ -127,6 +146,7 @@ class VIEWS_EXPORT LabelButton : public CustomButton,
gfx::Rect GetThemePaintRect() const override;
private:
+ FRIEND_TEST_ALL_PREFIXES(BlueButtonTest, Border);
FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Init);
FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Label);
FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Image);
« no previous file with comments | « ui/views/controls/button/custom_button_unittest.cc ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698