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

Unified Diff: ui/views/examples/button_example.cc

Issue 1569113002: MacViews: Style BUTTON_STYLE buttons using the "modern" UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: respond to comments Created 4 years, 8 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/examples/button_example.h ('k') | ui/views/style/mac/combobox_background_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/examples/button_example.cc
diff --git a/ui/views/examples/button_example.cc b/ui/views/examples/button_example.cc
index 2cf42afa9e3e5b4a0ae61595d380e0cfb46cea18..02a56822c6540ef8340ffaa2d58d89608b55c496 100644
--- a/ui/views/examples/button_example.cc
+++ b/ui/views/examples/button_example.cc
@@ -29,12 +29,7 @@ const char kLongText[] = "Start of Really Really Really Really Really Really "
namespace views {
namespace examples {
-ButtonExample::ButtonExample()
- : ExampleBase("Button"),
- label_button_(NULL),
- image_button_(NULL),
- icon_(NULL),
- count_(0) {
+ButtonExample::ButtonExample() : ExampleBase("Button") {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
icon_ = rb.GetImageNamed(IDR_CLOSE_H).ToImageSkia();
}
@@ -52,16 +47,14 @@ void ButtonExample::CreateExampleView(View* container) {
label_button_->SetFocusable(true);
container->AddChildView(label_button_);
- LabelButton* styled_button =
- new LabelButton(this, ASCIIToUTF16("Styled Button"));
- styled_button->SetStyle(Button::STYLE_BUTTON);
- container->AddChildView(styled_button);
+ styled_button_ = new LabelButton(this, ASCIIToUTF16("Styled Button"));
+ styled_button_->SetStyle(Button::STYLE_BUTTON);
+ container->AddChildView(styled_button_);
- LabelButton* disabled_button =
- new LabelButton(this, ASCIIToUTF16("Disabled Button"));
- disabled_button->SetStyle(Button::STYLE_BUTTON);
- disabled_button->SetState(Button::STATE_DISABLED);
- container->AddChildView(disabled_button);
+ disabled_button_ = new LabelButton(this, ASCIIToUTF16("Disabled Button"));
+ disabled_button_->SetStyle(Button::STYLE_BUTTON);
+ disabled_button_->SetState(Button::STATE_DISABLED);
+ container->AddChildView(disabled_button_);
container->AddChildView(new BlueButton(this, ASCIIToUTF16("Blue Button")));
@@ -88,41 +81,48 @@ void ButtonExample::CreateExampleView(View* container) {
container->AddChildView(image_button_);
}
-void ButtonExample::LabelButtonPressed(const ui::Event& event) {
+void ButtonExample::LabelButtonPressed(LabelButton* label_button,
+ const ui::Event& event) {
PrintStatus("Label Button Pressed! count: %d", ++count_);
if (event.IsControlDown()) {
if (event.IsShiftDown()) {
- label_button_->SetText(ASCIIToUTF16(
- label_button_->GetText().empty()
+ label_button->SetText(ASCIIToUTF16(
+ label_button->GetText().empty()
? kLongText
- : label_button_->GetText().length() > 50 ? kLabelButton : ""));
+ : label_button->GetText().length() > 50 ? kLabelButton : ""));
} else if (event.IsAltDown()) {
- label_button_->SetImage(Button::STATE_NORMAL,
- label_button_->GetImage(Button::STATE_NORMAL).isNull() ?
- *icon_ : gfx::ImageSkia());
+ label_button->SetImage(
+ Button::STATE_NORMAL,
+ label_button->GetImage(Button::STATE_NORMAL).isNull()
+ ? *icon_
+ : gfx::ImageSkia());
} else {
static int alignment = 0;
- label_button_->SetHorizontalAlignment(
+ label_button->SetHorizontalAlignment(
static_cast<gfx::HorizontalAlignment>(++alignment % 3));
}
} else if (event.IsShiftDown()) {
if (event.IsAltDown()) {
- label_button_->SetFocusable(!label_button_->IsFocusable());
+ label_button->SetFocusable(!label_button->IsFocusable());
} else {
- label_button_->SetStyle(static_cast<Button::ButtonStyle>(
- (label_button_->style() + 1) % Button::STYLE_COUNT));
+ label_button->SetStyle(static_cast<Button::ButtonStyle>(
+ (label_button->style() + 1) % Button::STYLE_COUNT));
}
} else if (event.IsAltDown()) {
- label_button_->SetIsDefault(!label_button_->is_default());
+ label_button->SetIsDefault(!label_button->is_default());
} else {
- label_button_->SetMinSize(gfx::Size());
+ label_button->SetMinSize(gfx::Size());
}
example_view()->GetLayoutManager()->Layout(example_view());
}
void ButtonExample::ButtonPressed(Button* sender, const ui::Event& event) {
if (sender == label_button_)
- LabelButtonPressed(event);
+ LabelButtonPressed(label_button_, event);
+ else if (sender == styled_button_)
+ LabelButtonPressed(styled_button_, event);
+ else if (sender == disabled_button_)
+ LabelButtonPressed(disabled_button_, event);
else
PrintStatus("Image Button Pressed! count: %d", ++count_);
}
« no previous file with comments | « ui/views/examples/button_example.h ('k') | ui/views/style/mac/combobox_background_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698