OLD | NEW |
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/app_list/views/page_switcher.h" | 5 #include "ui/app_list/views/page_switcher.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "third_party/skia/include/core/SkPath.h" | 9 #include "third_party/skia/include/core/SkPath.h" |
10 #include "ui/app_list/app_list_constants.h" | 10 #include "ui/app_list/app_list_constants.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 if (selected_range_ == selected_range) | 42 if (selected_range_ == selected_range) |
43 return; | 43 return; |
44 | 44 |
45 selected_range_ = selected_range; | 45 selected_range_ = selected_range; |
46 SchedulePaint(); | 46 SchedulePaint(); |
47 } | 47 } |
48 | 48 |
49 void set_button_width(int button_width) { button_width_ = button_width; } | 49 void set_button_width(int button_width) { button_width_ = button_width; } |
50 | 50 |
51 // Overridden from views::View: | 51 // Overridden from views::View: |
52 virtual gfx::Size GetPreferredSize() OVERRIDE { | 52 virtual gfx::Size GetPreferredSize() const OVERRIDE { |
53 return gfx::Size(button_width_, kButtonHeight); | 53 return gfx::Size(button_width_, kButtonHeight); |
54 } | 54 } |
55 | 55 |
56 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | 56 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { |
57 if (state() == STATE_HOVERED) | 57 if (state() == STATE_HOVERED) |
58 PaintButton(canvas, kPagerHoverColor); | 58 PaintButton(canvas, kPagerHoverColor); |
59 else | 59 else |
60 PaintButton(canvas, kPagerNormalColor); | 60 PaintButton(canvas, kPagerNormalColor); |
61 } | 61 } |
62 | 62 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 return; | 158 return; |
159 } | 159 } |
160 | 160 |
161 for (int i = 0; i < button_count; ++i) { | 161 for (int i = 0; i < button_count; ++i) { |
162 PageSwitcherButton* button = | 162 PageSwitcherButton* button = |
163 static_cast<PageSwitcherButton*>(buttons_->child_at(i)); | 163 static_cast<PageSwitcherButton*>(buttons_->child_at(i)); |
164 button->SetState(views::CustomButton::STATE_NORMAL); | 164 button->SetState(views::CustomButton::STATE_NORMAL); |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 gfx::Size PageSwitcher::GetPreferredSize() { | 168 gfx::Size PageSwitcher::GetPreferredSize() const { |
169 // Always return a size with correct height so that container resize is not | 169 // Always return a size with correct height so that container resize is not |
170 // needed when more pages are added. | 170 // needed when more pages are added. |
171 return gfx::Size(buttons_->GetPreferredSize().width(), | 171 return gfx::Size(buttons_->GetPreferredSize().width(), |
172 kPreferredHeight); | 172 kPreferredHeight); |
173 } | 173 } |
174 | 174 |
175 void PageSwitcher::Layout() { | 175 void PageSwitcher::Layout() { |
176 gfx::Rect rect(GetContentsBounds()); | 176 gfx::Rect rect(GetContentsBounds()); |
177 | 177 |
178 CalculateButtonWidthAndSpacing(rect.width()); | 178 CalculateButtonWidthAndSpacing(rect.width()); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 remaining = -remaining; | 258 remaining = -remaining; |
259 progress = -progress; | 259 progress = -progress; |
260 } | 260 } |
261 | 261 |
262 GetButtonByIndex(buttons_, current_page)->SetSelectedRange(remaining); | 262 GetButtonByIndex(buttons_, current_page)->SetSelectedRange(remaining); |
263 if (model_->is_valid_page(target_page)) | 263 if (model_->is_valid_page(target_page)) |
264 GetButtonByIndex(buttons_, target_page)->SetSelectedRange(progress); | 264 GetButtonByIndex(buttons_, target_page)->SetSelectedRange(progress); |
265 } | 265 } |
266 | 266 |
267 } // namespace app_list | 267 } // namespace app_list |
OLD | NEW |