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

Side by Side Diff: ash/accelerators/exit_warning_handler.cc

Issue 2901503003: Rename GetPreferredSize to CalculatePreferredSize in ash/ (Closed)
Patch Set: improvements Created 3 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 | « no previous file | ash/autoclick/common/autoclick_ring_handler.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/accelerators/exit_warning_handler.h" 5 #include "ash/accelerators/exit_warning_handler.h"
6 6
7 #include "ash/public/cpp/shell_window_ids.h" 7 #include "ash/public/cpp/shell_window_ids.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_delegate.h" 10 #include "ash/shell_delegate.h"
(...skipping 27 matching lines...) Expand all
38 const int kWindowCornerRadius = 2; 38 const int kWindowCornerRadius = 2;
39 const int kHorizontalMarginAroundText = 100; 39 const int kHorizontalMarginAroundText = 100;
40 const int kVerticalMarginAroundText = 100; 40 const int kVerticalMarginAroundText = 100;
41 41
42 class ExitWarningWidgetDelegateView : public views::WidgetDelegateView { 42 class ExitWarningWidgetDelegateView : public views::WidgetDelegateView {
43 public: 43 public:
44 ExitWarningWidgetDelegateView() 44 ExitWarningWidgetDelegateView()
45 : text_(l10n_util::GetStringUTF16(IDS_ASH_SIGN_OUT_WARNING_POPUP_TEXT)), 45 : text_(l10n_util::GetStringUTF16(IDS_ASH_SIGN_OUT_WARNING_POPUP_TEXT)),
46 accessible_name_(l10n_util::GetStringUTF16( 46 accessible_name_(l10n_util::GetStringUTF16(
47 IDS_ASH_SIGN_OUT_WARNING_POPUP_TEXT_ACCESSIBLE)), 47 IDS_ASH_SIGN_OUT_WARNING_POPUP_TEXT_ACCESSIBLE)),
48 text_width_(0), 48 text_width_(0) {
49 width_(0),
50 height_(0) {
51 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 49 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
52 const gfx::FontList& font_list = 50 const gfx::FontList& font_list =
53 rb.GetFontList(ui::ResourceBundle::LargeFont); 51 rb.GetFontList(ui::ResourceBundle::LargeFont);
54 text_width_ = gfx::GetStringWidth(text_, font_list); 52 text_width_ = gfx::GetStringWidth(text_, font_list);
55 width_ = text_width_ + kHorizontalMarginAroundText; 53 set_preferred_size(
56 height_ = font_list.GetHeight() + kVerticalMarginAroundText; 54 gfx::Size(text_width_ + kHorizontalMarginAroundText,
55 font_list.GetHeight() + kVerticalMarginAroundText));
57 views::Label* label = new views::Label(); 56 views::Label* label = new views::Label();
58 label->SetText(text_); 57 label->SetText(text_);
59 label->SetHorizontalAlignment(gfx::ALIGN_CENTER); 58 label->SetHorizontalAlignment(gfx::ALIGN_CENTER);
60 label->SetFontList(font_list); 59 label->SetFontList(font_list);
61 label->SetEnabledColor(kTextColor); 60 label->SetEnabledColor(kTextColor);
62 label->SetDisabledColor(kTextColor); 61 label->SetDisabledColor(kTextColor);
63 label->SetAutoColorReadabilityEnabled(false); 62 label->SetAutoColorReadabilityEnabled(false);
64 label->SetSubpixelRenderingEnabled(false); 63 label->SetSubpixelRenderingEnabled(false);
65 AddChildView(label); 64 AddChildView(label);
66 SetLayoutManager(new views::FillLayout); 65 SetLayoutManager(new views::FillLayout);
67 } 66 }
68 67
69 gfx::Size GetPreferredSize() const override {
70 return gfx::Size(width_, height_);
71 }
72
73 void OnPaint(gfx::Canvas* canvas) override { 68 void OnPaint(gfx::Canvas* canvas) override {
74 cc::PaintFlags flags; 69 cc::PaintFlags flags;
75 flags.setStyle(cc::PaintFlags::kFill_Style); 70 flags.setStyle(cc::PaintFlags::kFill_Style);
76 flags.setColor(kWindowBackgroundColor); 71 flags.setColor(kWindowBackgroundColor);
77 canvas->DrawRoundRect(GetLocalBounds(), kWindowCornerRadius, flags); 72 canvas->DrawRoundRect(GetLocalBounds(), kWindowCornerRadius, flags);
78 views::WidgetDelegateView::OnPaint(canvas); 73 views::WidgetDelegateView::OnPaint(canvas);
79 } 74 }
80 75
81 void GetAccessibleNodeData(ui::AXNodeData* node_data) override { 76 void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
82 node_data->SetName(accessible_name_); 77 node_data->SetName(accessible_name_);
83 node_data->role = ui::AX_ROLE_ALERT; 78 node_data->role = ui::AX_ROLE_ALERT;
84 } 79 }
85 80
86 private: 81 private:
87 base::string16 text_; 82 base::string16 text_;
88 base::string16 accessible_name_; 83 base::string16 accessible_name_;
89 int text_width_; 84 int text_width_;
90 int width_;
91 int height_;
92 85
93 DISALLOW_COPY_AND_ASSIGN(ExitWarningWidgetDelegateView); 86 DISALLOW_COPY_AND_ASSIGN(ExitWarningWidgetDelegateView);
94 }; 87 };
95 88
96 } // namespace 89 } // namespace
97 90
98 ExitWarningHandler::ExitWarningHandler() 91 ExitWarningHandler::ExitWarningHandler()
99 : state_(IDLE), stub_timer_for_test_(false) {} 92 : state_(IDLE), stub_timer_for_test_(false) {}
100 93
101 ExitWarningHandler::~ExitWarningHandler() { 94 ExitWarningHandler::~ExitWarningHandler() {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 widget_->Show(); 161 widget_->Show();
169 162
170 delegate->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); 163 delegate->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
171 } 164 }
172 165
173 void ExitWarningHandler::Hide() { 166 void ExitWarningHandler::Hide() {
174 widget_.reset(); 167 widget_.reset();
175 } 168 }
176 169
177 } // namespace ash 170 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/autoclick/common/autoclick_ring_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698