OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/views/star_toggle.h" | 5 #include "chrome/browser/views/star_toggle.h" |
6 | 6 |
7 #include "chrome/app/chrome_dll_resource.h" | 7 #include "chrome/app/chrome_dll_resource.h" |
8 #include "chrome/app/theme/theme_resources.h" | 8 #include "chrome/app/theme/theme_resources.h" |
9 #include "chrome/common/gfx/chrome_canvas.h" | 9 #include "chrome/common/gfx/chrome_canvas.h" |
10 #include "chrome/common/resource_bundle.h" | 10 #include "chrome/common/resource_bundle.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 return state_; | 33 return state_; |
34 } | 34 } |
35 | 35 |
36 void StarToggle::Paint(ChromeCanvas* canvas) { | 36 void StarToggle::Paint(ChromeCanvas* canvas) { |
37 PaintFocusBorder(canvas); | 37 PaintFocusBorder(canvas); |
38 canvas->DrawBitmapInt(state_ ? *state_on_ : *state_off_, | 38 canvas->DrawBitmapInt(state_ ? *state_on_ : *state_off_, |
39 (width() - state_off_->width()) / 2, | 39 (width() - state_off_->width()) / 2, |
40 (height() - state_off_->height()) / 2); | 40 (height() - state_off_->height()) / 2); |
41 } | 41 } |
42 | 42 |
43 void StarToggle::GetPreferredSize(CSize* out) { | 43 gfx::Size StarToggle::GetPreferredSize() { |
44 out->cx = state_off_->width(); | 44 return gfx::Size(state_off_->width(), state_off_->height()); |
45 out->cy = state_off_->height(); | |
46 } | 45 } |
47 | 46 |
48 bool StarToggle::OnMouseDragged(const ChromeViews::MouseEvent& e) { | 47 bool StarToggle::OnMouseDragged(const ChromeViews::MouseEvent& e) { |
49 return e.IsLeftMouseButton(); | 48 return e.IsLeftMouseButton(); |
50 } | 49 } |
51 | 50 |
52 bool StarToggle::OnMousePressed(const ChromeViews::MouseEvent& e) { | 51 bool StarToggle::OnMousePressed(const ChromeViews::MouseEvent& e) { |
53 if (e.IsLeftMouseButton() && HitTest(e.location())) { | 52 if (e.IsLeftMouseButton() && HitTest(e.location())) { |
54 RequestFocus(); | 53 RequestFocus(); |
55 return true; | 54 return true; |
(...skipping 15 matching lines...) Expand all Loading... |
71 return false; | 70 return false; |
72 } | 71 } |
73 | 72 |
74 void StarToggle::SwitchState() { | 73 void StarToggle::SwitchState() { |
75 const bool new_state = !state_; | 74 const bool new_state = !state_; |
76 if (change_state_immediately_) | 75 if (change_state_immediately_) |
77 state_ = new_state; | 76 state_ = new_state; |
78 SchedulePaint(); | 77 SchedulePaint(); |
79 delegate_->StarStateChanged(new_state); | 78 delegate_->StarStateChanged(new_state); |
80 } | 79 } |
OLD | NEW |