OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/status/status_area_button.h" | 5 #include "chrome/browser/chromeos/status/status_area_button.h" |
6 | 6 |
7 #include "gfx/canvas.h" | 7 #include "gfx/canvas.h" |
8 #include "gfx/skbitmap_operations.h" | 8 #include "gfx/skbitmap_operations.h" |
9 #include "grit/theme_resources.h" | 9 #include "grit/theme_resources.h" |
10 #include "views/border.h" | 10 #include "views/border.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 void StatusAreaButton::Paint(gfx::Canvas* canvas, bool for_drag) { | 27 void StatusAreaButton::Paint(gfx::Canvas* canvas, bool for_drag) { |
28 if (state() == BS_PUSHED) { | 28 if (state() == BS_PUSHED) { |
29 // Apply 10% white when pushed down. | 29 // Apply 10% white when pushed down. |
30 canvas->FillRectInt(SkColorSetARGB(0x19, 0xFF, 0xFF, 0xFF), | 30 canvas->FillRectInt(SkColorSetARGB(0x19, 0xFF, 0xFF, 0xFF), |
31 0, 0, width(), height()); | 31 0, 0, width(), height()); |
32 } | 32 } |
33 | 33 |
34 if (use_menu_button_paint_) { | 34 if (use_menu_button_paint_) { |
35 views::MenuButton::Paint(canvas, for_drag); | 35 views::MenuButton::Paint(canvas, for_drag); |
36 } else { | 36 } else { |
37 if (state() == BS_PUSHED) | |
38 DrawPressed(canvas); | |
39 | |
40 DrawIcon(canvas); | 37 DrawIcon(canvas); |
41 PaintFocusBorder(canvas); | 38 PaintFocusBorder(canvas); |
42 } | 39 } |
43 } | 40 } |
44 | 41 |
45 gfx::Size StatusAreaButton::GetPreferredSize() { | 42 gfx::Size StatusAreaButton::GetPreferredSize() { |
46 // icons are 24x24 | |
47 static const int kIconWidth = 24; | |
48 static const int kIconHeight = 24; | |
49 gfx::Insets insets = views::MenuButton::GetInsets(); | 43 gfx::Insets insets = views::MenuButton::GetInsets(); |
50 gfx::Size prefsize(kIconWidth + insets.width(), | 44 gfx::Size prefsize(icon_width() + insets.width(), |
51 kIconHeight + insets.height()); | 45 icon_height() + insets.height()); |
52 | 46 |
53 // Adjusts size when use menu button paint. | 47 // Adjusts size when use menu button paint. |
54 if (use_menu_button_paint_) { | 48 if (use_menu_button_paint_) { |
55 gfx::Size menu_button_size = views::MenuButton::GetPreferredSize(); | 49 gfx::Size menu_button_size = views::MenuButton::GetPreferredSize(); |
56 prefsize.SetSize( | 50 prefsize.SetSize( |
57 std::max(prefsize.width(), menu_button_size.width()), | 51 std::max(prefsize.width(), menu_button_size.width()), |
58 std::max(prefsize.height(), menu_button_size.height()) | 52 std::max(prefsize.height(), menu_button_size.height()) |
59 ); | 53 ); |
60 | 54 |
61 // Shift 1-pixel down for odd number of pixels in vertical space. | 55 // Shift 1-pixel down for odd number of pixels in vertical space. |
(...skipping 16 matching lines...) Expand all Loading... |
78 // We clear that max text size, so we can adjust the size to fit the text. | 72 // We clear that max text size, so we can adjust the size to fit the text. |
79 ClearMaxTextSize(); | 73 ClearMaxTextSize(); |
80 views::MenuButton::SetText(text); | 74 views::MenuButton::SetText(text); |
81 } | 75 } |
82 | 76 |
83 void StatusAreaButton::DrawIcon(gfx::Canvas* canvas) { | 77 void StatusAreaButton::DrawIcon(gfx::Canvas* canvas) { |
84 canvas->DrawBitmapInt(icon(), 0, 0); | 78 canvas->DrawBitmapInt(icon(), 0, 0); |
85 } | 79 } |
86 | 80 |
87 } // namespace chromeos | 81 } // namespace chromeos |
OLD | NEW |