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

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, desktop linux 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
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..9ab47f02253ff0c4b652fe026f2552fe49d254a7 100644
--- a/ui/views/examples/button_example.cc
+++ b/ui/views/examples/button_example.cc
@@ -88,41 +88,45 @@ 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);
+ LabelButton* label_button = CustomButton::AsLabelButton(sender);
+ if (label_button)
+ LabelButtonPressed(label_button, event);
else
PrintStatus("Image Button Pressed! count: %d", ++count_);
}

Powered by Google App Engine
This is Rietveld 408576698