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

Side by Side Diff: ui/views/controls/scrollbar/native_scroll_bar_views.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 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 | Annotate | Revision Log
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/controls/scrollbar/native_scroll_bar_views.h" 5 #include "ui/views/controls/scrollbar/native_scroll_bar_views.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/events/keycodes/keyboard_codes.h" 8 #include "ui/events/keycodes/keyboard_codes.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/path.h" 10 #include "ui/gfx/path.h"
(...skipping 14 matching lines...) Expand all
25 enum Type { 25 enum Type {
26 UP, 26 UP,
27 DOWN, 27 DOWN,
28 LEFT, 28 LEFT,
29 RIGHT, 29 RIGHT,
30 }; 30 };
31 31
32 ScrollBarButton(ButtonListener* listener, Type type); 32 ScrollBarButton(ButtonListener* listener, Type type);
33 virtual ~ScrollBarButton(); 33 virtual ~ScrollBarButton();
34 34
35 virtual gfx::Size GetPreferredSize() OVERRIDE; 35 virtual gfx::Size GetPreferredSize() const OVERRIDE;
36 virtual const char* GetClassName() const OVERRIDE { 36 virtual const char* GetClassName() const OVERRIDE {
37 return "ScrollBarButton"; 37 return "ScrollBarButton";
38 } 38 }
39 39
40 protected: 40 protected:
41 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 41 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
42 42
43 private: 43 private:
44 ui::NativeTheme::ExtraParams GetNativeThemeParams() const; 44 ui::NativeTheme::ExtraParams GetNativeThemeParams() const;
45 ui::NativeTheme::Part GetNativeThemePart() const; 45 ui::NativeTheme::Part GetNativeThemePart() const;
46 ui::NativeTheme::State GetNativeThemeState() const; 46 ui::NativeTheme::State GetNativeThemeState() const;
47 47
48 Type type_; 48 Type type_;
49 }; 49 };
50 50
51 // Wrapper for the scroll thumb 51 // Wrapper for the scroll thumb
52 class ScrollBarThumb : public BaseScrollBarThumb { 52 class ScrollBarThumb : public BaseScrollBarThumb {
53 public: 53 public:
54 explicit ScrollBarThumb(BaseScrollBar* scroll_bar); 54 explicit ScrollBarThumb(BaseScrollBar* scroll_bar);
55 virtual ~ScrollBarThumb(); 55 virtual ~ScrollBarThumb();
56 56
57 virtual gfx::Size GetPreferredSize() OVERRIDE; 57 virtual gfx::Size GetPreferredSize() const OVERRIDE;
58 virtual const char* GetClassName() const OVERRIDE { 58 virtual const char* GetClassName() const OVERRIDE {
59 return "ScrollBarThumb"; 59 return "ScrollBarThumb";
60 } 60 }
61 61
62 protected: 62 protected:
63 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 63 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
64 64
65 private: 65 private:
66 ui::NativeTheme::ExtraParams GetNativeThemeParams() const; 66 ui::NativeTheme::ExtraParams GetNativeThemeParams() const;
67 ui::NativeTheme::Part GetNativeThemePart() const; 67 ui::NativeTheme::Part GetNativeThemePart() const;
68 ui::NativeTheme::State GetNativeThemeState() const; 68 ui::NativeTheme::State GetNativeThemeState() const;
69 69
70 ScrollBar* scroll_bar_; 70 ScrollBar* scroll_bar_;
71 }; 71 };
72 72
73 ///////////////////////////////////////////////////////////////////////////// 73 /////////////////////////////////////////////////////////////////////////////
74 // ScrollBarButton 74 // ScrollBarButton
75 75
76 ScrollBarButton::ScrollBarButton(ButtonListener* listener, Type type) 76 ScrollBarButton::ScrollBarButton(ButtonListener* listener, Type type)
77 : BaseScrollBarButton(listener), 77 : BaseScrollBarButton(listener),
78 type_(type) { 78 type_(type) {
79 SetFocusable(false); 79 SetFocusable(false);
80 SetAccessibilityFocusable(false); 80 SetAccessibilityFocusable(false);
81 } 81 }
82 82
83 ScrollBarButton::~ScrollBarButton() { 83 ScrollBarButton::~ScrollBarButton() {
84 } 84 }
85 85
86 gfx::Size ScrollBarButton::GetPreferredSize() { 86 gfx::Size ScrollBarButton::GetPreferredSize() const {
87 return GetNativeTheme()->GetPartSize(GetNativeThemePart(), 87 return GetNativeTheme()->GetPartSize(GetNativeThemePart(),
88 GetNativeThemeState(), 88 GetNativeThemeState(),
89 GetNativeThemeParams()); 89 GetNativeThemeParams());
90 } 90 }
91 91
92 void ScrollBarButton::OnPaint(gfx::Canvas* canvas) { 92 void ScrollBarButton::OnPaint(gfx::Canvas* canvas) {
93 gfx::Rect bounds(GetPreferredSize()); 93 gfx::Rect bounds(GetPreferredSize());
94 GetNativeTheme()->Paint(canvas->sk_canvas(), GetNativeThemePart(), 94 GetNativeTheme()->Paint(canvas->sk_canvas(), GetNativeThemePart(),
95 GetNativeThemeState(), bounds, 95 GetNativeThemeState(), bounds,
96 GetNativeThemeParams()); 96 GetNativeThemeParams());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 ScrollBarThumb::ScrollBarThumb(BaseScrollBar* scroll_bar) 157 ScrollBarThumb::ScrollBarThumb(BaseScrollBar* scroll_bar)
158 : BaseScrollBarThumb(scroll_bar), 158 : BaseScrollBarThumb(scroll_bar),
159 scroll_bar_(scroll_bar) { 159 scroll_bar_(scroll_bar) {
160 SetFocusable(false); 160 SetFocusable(false);
161 SetAccessibilityFocusable(false); 161 SetAccessibilityFocusable(false);
162 } 162 }
163 163
164 ScrollBarThumb::~ScrollBarThumb() { 164 ScrollBarThumb::~ScrollBarThumb() {
165 } 165 }
166 166
167 gfx::Size ScrollBarThumb::GetPreferredSize() { 167 gfx::Size ScrollBarThumb::GetPreferredSize() const {
168 return GetNativeTheme()->GetPartSize(GetNativeThemePart(), 168 return GetNativeTheme()->GetPartSize(GetNativeThemePart(),
169 GetNativeThemeState(), 169 GetNativeThemeState(),
170 GetNativeThemeParams()); 170 GetNativeThemeParams());
171 } 171 }
172 172
173 void ScrollBarThumb::OnPaint(gfx::Canvas* canvas) { 173 void ScrollBarThumb::OnPaint(gfx::Canvas* canvas) {
174 const gfx::Rect local_bounds(GetLocalBounds()); 174 const gfx::Rect local_bounds(GetLocalBounds());
175 const ui::NativeTheme::State theme_state = GetNativeThemeState(); 175 const ui::NativeTheme::State theme_state = GetNativeThemeState();
176 const ui::NativeTheme::ExtraParams extra_params(GetNativeThemeParams()); 176 const ui::NativeTheme::ExtraParams extra_params(GetNativeThemeParams());
177 GetNativeTheme()->Paint(canvas->sk_canvas(), 177 GetNativeTheme()->Paint(canvas->sk_canvas(),
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 285
286 params_.scrollbar_track.track_x = bounds.x(); 286 params_.scrollbar_track.track_x = bounds.x();
287 params_.scrollbar_track.track_y = bounds.y(); 287 params_.scrollbar_track.track_y = bounds.y();
288 params_.scrollbar_track.track_width = bounds.width(); 288 params_.scrollbar_track.track_width = bounds.width();
289 params_.scrollbar_track.track_height = bounds.height(); 289 params_.scrollbar_track.track_height = bounds.height();
290 params_.scrollbar_track.classic_state = 0; 290 params_.scrollbar_track.classic_state = 0;
291 291
292 GetNativeTheme()->Paint(canvas->sk_canvas(), part_, state_, bounds, params_); 292 GetNativeTheme()->Paint(canvas->sk_canvas(), part_, state_, bounds, params_);
293 } 293 }
294 294
295 gfx::Size NativeScrollBarViews::GetPreferredSize() { 295 gfx::Size NativeScrollBarViews::GetPreferredSize() const {
296 const ui::NativeTheme* theme = native_scroll_bar_->GetNativeTheme(); 296 const ui::NativeTheme* theme = native_scroll_bar_->GetNativeTheme();
297 if (native_scroll_bar_->IsHorizontal()) 297 if (native_scroll_bar_->IsHorizontal())
298 return gfx::Size(0, GetHorizontalScrollBarHeight(theme)); 298 return gfx::Size(0, GetHorizontalScrollBarHeight(theme));
299 return gfx::Size(GetVerticalScrollBarWidth(theme), 0); 299 return gfx::Size(GetVerticalScrollBarWidth(theme), 0);
300 } 300 }
301 301
302 const char* NativeScrollBarViews::GetClassName() const { 302 const char* NativeScrollBarViews::GetClassName() const {
303 return kViewClassName; 303 return kViewClassName;
304 } 304 }
305 305
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 thumb_params.scrollbar_thumb.is_hovering = false; 415 thumb_params.scrollbar_thumb.is_hovering = false;
416 gfx::Size track_size = theme->GetPartSize( 416 gfx::Size track_size = theme->GetPartSize(
417 ui::NativeTheme::kScrollbarVerticalThumb, 417 ui::NativeTheme::kScrollbarVerticalThumb,
418 ui::NativeTheme::kNormal, 418 ui::NativeTheme::kNormal,
419 thumb_params); 419 thumb_params);
420 420
421 return std::max(track_size.width(), button_size.width()); 421 return std::max(track_size.width(), button_size.width());
422 } 422 }
423 423
424 } // namespace views 424 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scrollbar/native_scroll_bar_views.h ('k') | ui/views/controls/scrollbar/overlay_scroll_bar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698