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

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

Issue 1870573003: Full Keyboard Access: Second Approach (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « ui/views/controls/webview/webview.cc ('k') | ui/views/examples/tree_view_example.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 #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"
11 #include "ui/views/background.h" 11 #include "ui/views/background.h"
12 #include "ui/views/controls/button/blue_button.h" 12 #include "ui/views/controls/button/blue_button.h"
13 #include "ui/views/controls/button/image_button.h" 13 #include "ui/views/controls/button/image_button.h"
14 #include "ui/views/controls/button/label_button.h" 14 #include "ui/views/controls/button/label_button.h"
15 #include "ui/views/controls/button/md_text_button.h" 15 #include "ui/views/controls/button/md_text_button.h"
16 #include "ui/views/layout/box_layout.h" 16 #include "ui/views/layout/box_layout.h"
17 #include "ui/views/resources/grit/views_resources.h" 17 #include "ui/views/resources/grit/views_resources.h"
18 #include "ui/views/style/platform_style.h"
18 #include "ui/views/view.h" 19 #include "ui/views/view.h"
19 20
20 using base::ASCIIToUTF16; 21 using base::ASCIIToUTF16;
21 22
22 namespace { 23 namespace {
23 const char kLabelButton[] = "Label Button"; 24 const char kLabelButton[] = "Label Button";
24 const char kLongText[] = "Start of Really Really Really Really Really Really " 25 const char kLongText[] = "Start of Really Really Really Really Really Really "
25 "Really Really Really Really Really Really Really " 26 "Really Really Really Really Really Really Really "
26 "Really Really Really Really Really Long Button Text"; 27 "Really Really Really Really Really Long Button Text";
27 } // namespace 28 } // namespace
(...skipping 14 matching lines...) Expand all
42 ButtonExample::~ButtonExample() { 43 ButtonExample::~ButtonExample() {
43 } 44 }
44 45
45 void ButtonExample::CreateExampleView(View* container) { 46 void ButtonExample::CreateExampleView(View* container) {
46 container->set_background(Background::CreateSolidBackground(SK_ColorWHITE)); 47 container->set_background(Background::CreateSolidBackground(SK_ColorWHITE));
47 BoxLayout* layout = new BoxLayout(BoxLayout::kVertical, 10, 10, 10); 48 BoxLayout* layout = new BoxLayout(BoxLayout::kVertical, 10, 10, 10);
48 layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); 49 layout->set_cross_axis_alignment(BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
49 container->SetLayoutManager(layout); 50 container->SetLayoutManager(layout);
50 51
51 label_button_ = new LabelButton(this, ASCIIToUTF16(kLabelButton)); 52 label_button_ = new LabelButton(this, ASCIIToUTF16(kLabelButton));
52 label_button_->SetFocusable(true); 53 PlatformStyle::ConfigureFocus(PlatformStyle::CONTROL::BUTTON, label_button_);
53 container->AddChildView(label_button_); 54 container->AddChildView(label_button_);
54 55
55 LabelButton* styled_button = 56 LabelButton* styled_button =
56 new LabelButton(this, ASCIIToUTF16("Styled Button")); 57 new LabelButton(this, ASCIIToUTF16("Styled Button"));
57 styled_button->SetStyle(Button::STYLE_BUTTON); 58 styled_button->SetStyle(Button::STYLE_BUTTON);
58 container->AddChildView(styled_button); 59 container->AddChildView(styled_button);
59 60
60 LabelButton* disabled_button = 61 LabelButton* disabled_button =
61 new LabelButton(this, ASCIIToUTF16("Disabled Button")); 62 new LabelButton(this, ASCIIToUTF16("Disabled Button"));
62 disabled_button->SetStyle(Button::STYLE_BUTTON); 63 disabled_button->SetStyle(Button::STYLE_BUTTON);
63 disabled_button->SetState(Button::STATE_DISABLED); 64 disabled_button->SetState(Button::STATE_DISABLED);
64 container->AddChildView(disabled_button); 65 container->AddChildView(disabled_button);
65 66
66 container->AddChildView(new BlueButton(this, ASCIIToUTF16("Blue Button"))); 67 container->AddChildView(new BlueButton(this, ASCIIToUTF16("Blue Button")));
67 68
68 container->AddChildView(MdTextButton::CreateMdButton( 69 container->AddChildView(MdTextButton::CreateMdButton(
69 nullptr, base::ASCIIToUTF16("Material design"))); 70 nullptr, base::ASCIIToUTF16("Material design")));
70 MdTextButton* md_button = MdTextButton::CreateMdButton( 71 MdTextButton* md_button = MdTextButton::CreateMdButton(
71 nullptr, base::ASCIIToUTF16("Strong call to action")); 72 nullptr, base::ASCIIToUTF16("Strong call to action"));
72 md_button->SetCallToAction(MdTextButton::STRONG_CALL_TO_ACTION); 73 md_button->SetCallToAction(MdTextButton::STRONG_CALL_TO_ACTION);
73 container->AddChildView(md_button); 74 container->AddChildView(md_button);
74 md_button = MdTextButton::CreateMdButton( 75 md_button = MdTextButton::CreateMdButton(
75 nullptr, base::ASCIIToUTF16("Weak call to action")); 76 nullptr, base::ASCIIToUTF16("Weak call to action"));
76 md_button->SetCallToAction(MdTextButton::WEAK_CALL_TO_ACTION); 77 md_button->SetCallToAction(MdTextButton::WEAK_CALL_TO_ACTION);
77 container->AddChildView(md_button); 78 container->AddChildView(md_button);
78 79
79 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 80 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
80 image_button_ = new ImageButton(this); 81 image_button_ = new ImageButton(this);
81 image_button_->SetFocusable(true); 82 PlatformStyle::ConfigureFocus(PlatformStyle::CONTROL::BUTTON, image_button_);
82 image_button_->SetImage(ImageButton::STATE_NORMAL, 83 image_button_->SetImage(ImageButton::STATE_NORMAL,
83 rb.GetImageNamed(IDR_CLOSE).ToImageSkia()); 84 rb.GetImageNamed(IDR_CLOSE).ToImageSkia());
84 image_button_->SetImage(ImageButton::STATE_HOVERED, 85 image_button_->SetImage(ImageButton::STATE_HOVERED,
85 rb.GetImageNamed(IDR_CLOSE_H).ToImageSkia()); 86 rb.GetImageNamed(IDR_CLOSE_H).ToImageSkia());
86 image_button_->SetImage(ImageButton::STATE_PRESSED, 87 image_button_->SetImage(ImageButton::STATE_PRESSED,
87 rb.GetImageNamed(IDR_CLOSE_P).ToImageSkia()); 88 rb.GetImageNamed(IDR_CLOSE_P).ToImageSkia());
88 container->AddChildView(image_button_); 89 container->AddChildView(image_button_);
89 } 90 }
90 91
91 void ButtonExample::LabelButtonPressed(const ui::Event& event) { 92 void ButtonExample::LabelButtonPressed(const ui::Event& event) {
(...skipping 30 matching lines...) Expand all
122 123
123 void ButtonExample::ButtonPressed(Button* sender, const ui::Event& event) { 124 void ButtonExample::ButtonPressed(Button* sender, const ui::Event& event) {
124 if (sender == label_button_) 125 if (sender == label_button_)
125 LabelButtonPressed(event); 126 LabelButtonPressed(event);
126 else 127 else
127 PrintStatus("Image Button Pressed! count: %d", ++count_); 128 PrintStatus("Image Button Pressed! count: %d", ++count_);
128 } 129 }
129 130
130 } // namespace examples 131 } // namespace examples
131 } // namespace views 132 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/webview/webview.cc ('k') | ui/views/examples/tree_view_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698