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

Side by Side Diff: ui/views/examples/button_example.cc

Issue 1963563002: Views: Flip default value of CustomButton::request_focus_on_press_ to false. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « ui/views/controls/button/label_button.cc ('k') | ui/views/examples/tree_view_example.h » ('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 #include "ui/views/examples/button_example.h" 5 #include "ui/views/examples/button_example.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/base/resource/resource_bundle.h" 8 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/gfx/image/image.h" 9 #include "ui/gfx/image/image.h"
10 #include "ui/resources/grit/ui_resources.h" 10 #include "ui/resources/grit/ui_resources.h"
(...skipping 27 matching lines...) Expand all
38 } 38 }
39 39
40 void ButtonExample::CreateExampleView(View* container) { 40 void ButtonExample::CreateExampleView(View* container) {
41 container->set_background(Background::CreateSolidBackground(SK_ColorWHITE)); 41 container->set_background(Background::CreateSolidBackground(SK_ColorWHITE));
42 BoxLayout* layout = new BoxLayout(BoxLayout::kVertical, 10, 10, 10); 42 BoxLayout* layout = new BoxLayout(BoxLayout::kVertical, 10, 10, 10);
43 layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); 43 layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
44 container->SetLayoutManager(layout); 44 container->SetLayoutManager(layout);
45 45
46 label_button_ = new LabelButton(this, ASCIIToUTF16(kLabelButton)); 46 label_button_ = new LabelButton(this, ASCIIToUTF16(kLabelButton));
47 Button::ConfigureDefaultFocus(label_button_); 47 Button::ConfigureDefaultFocus(label_button_);
48 label_button_->set_request_focus_on_press(true);
48 container->AddChildView(label_button_); 49 container->AddChildView(label_button_);
49 50
50 styled_button_ = new LabelButton(this, ASCIIToUTF16("Styled Button")); 51 styled_button_ = new LabelButton(this, ASCIIToUTF16("Styled Button"));
51 styled_button_->SetStyle(Button::STYLE_BUTTON); 52 styled_button_->SetStyle(Button::STYLE_BUTTON);
52 container->AddChildView(styled_button_); 53 container->AddChildView(styled_button_);
53 54
54 disabled_button_ = new LabelButton(this, ASCIIToUTF16("Disabled Button")); 55 disabled_button_ = new LabelButton(this, ASCIIToUTF16("Disabled Button"));
55 disabled_button_->SetStyle(Button::STYLE_BUTTON); 56 disabled_button_->SetStyle(Button::STYLE_BUTTON);
56 disabled_button_->SetState(Button::STATE_DISABLED); 57 disabled_button_->SetState(Button::STATE_DISABLED);
57 container->AddChildView(disabled_button_); 58 container->AddChildView(disabled_button_);
58 59
59 container->AddChildView(new BlueButton(this, ASCIIToUTF16("Blue Button"))); 60 container->AddChildView(new BlueButton(this, ASCIIToUTF16("Blue Button")));
60 61
61 container->AddChildView(MdTextButton::CreateMdButton( 62 container->AddChildView(MdTextButton::CreateMdButton(
62 nullptr, base::ASCIIToUTF16("Material design"))); 63 nullptr, base::ASCIIToUTF16("Material design")));
63 MdTextButton* md_button = MdTextButton::CreateMdButton( 64 MdTextButton* md_button = MdTextButton::CreateMdButton(
64 nullptr, base::ASCIIToUTF16("Strong call to action")); 65 nullptr, base::ASCIIToUTF16("Strong call to action"));
65 md_button->SetCallToAction(MdTextButton::STRONG_CALL_TO_ACTION); 66 md_button->SetCallToAction(MdTextButton::STRONG_CALL_TO_ACTION);
66 container->AddChildView(md_button); 67 container->AddChildView(md_button);
67 md_button = MdTextButton::CreateMdButton( 68 md_button = MdTextButton::CreateMdButton(
68 nullptr, base::ASCIIToUTF16("Weak call to action")); 69 nullptr, base::ASCIIToUTF16("Weak call to action"));
69 md_button->SetCallToAction(MdTextButton::WEAK_CALL_TO_ACTION); 70 md_button->SetCallToAction(MdTextButton::WEAK_CALL_TO_ACTION);
70 container->AddChildView(md_button); 71 container->AddChildView(md_button);
71 72
72 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 73 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
73 image_button_ = new ImageButton(this); 74 image_button_ = new ImageButton(this);
74 Button::ConfigureDefaultFocus(image_button_); 75 Button::ConfigureDefaultFocus(image_button_);
76 image_button_->set_request_focus_on_press(true);
75 image_button_->SetImage(ImageButton::STATE_NORMAL, 77 image_button_->SetImage(ImageButton::STATE_NORMAL,
76 rb.GetImageNamed(IDR_CLOSE).ToImageSkia()); 78 rb.GetImageNamed(IDR_CLOSE).ToImageSkia());
77 image_button_->SetImage(ImageButton::STATE_HOVERED, 79 image_button_->SetImage(ImageButton::STATE_HOVERED,
78 rb.GetImageNamed(IDR_CLOSE_H).ToImageSkia()); 80 rb.GetImageNamed(IDR_CLOSE_H).ToImageSkia());
79 image_button_->SetImage(ImageButton::STATE_PRESSED, 81 image_button_->SetImage(ImageButton::STATE_PRESSED,
80 rb.GetImageNamed(IDR_CLOSE_P).ToImageSkia()); 82 rb.GetImageNamed(IDR_CLOSE_P).ToImageSkia());
81 container->AddChildView(image_button_); 83 container->AddChildView(image_button_);
82 } 84 }
83 85
84 void ButtonExample::LabelButtonPressed(LabelButton* label_button, 86 void ButtonExample::LabelButtonPressed(LabelButton* label_button,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 else if (sender == styled_button_) 127 else if (sender == styled_button_)
126 LabelButtonPressed(styled_button_, event); 128 LabelButtonPressed(styled_button_, event);
127 else if (sender == disabled_button_) 129 else if (sender == disabled_button_)
128 LabelButtonPressed(disabled_button_, event); 130 LabelButtonPressed(disabled_button_, event);
129 else 131 else
130 PrintStatus("Image Button Pressed! count: %d", ++count_); 132 PrintStatus("Image Button Pressed! count: %d", ++count_);
131 } 133 }
132 134
133 } // namespace examples 135 } // namespace examples
134 } // namespace views 136 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/label_button.cc ('k') | ui/views/examples/tree_view_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698