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

Side by Side Diff: views/controls/menu/menu_item_view_win.cc

Issue 8122013: Allow CanvasSkia to bind to an existing SkCanvas. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 1 more fix Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/controls/menu/menu_item_view.h" 5 #include "views/controls/menu/menu_item_view.h"
6 6
7 #include <uxtheme.h> 7 #include <uxtheme.h>
8 #include <Vssym32.h> 8 #include <Vssym32.h>
9 9
10 #include "grit/ui_strings.h" 10 #include "grit/ui_strings.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 control_state = NativeTheme::kDisabled; 59 control_state = NativeTheme::kDisabled;
60 } 60 }
61 61
62 // The gutter is rendered before the background. 62 // The gutter is rendered before the background.
63 if (config.render_gutter && mode == PB_NORMAL) { 63 if (config.render_gutter && mode == PB_NORMAL) {
64 gfx::Rect gutter_bounds(label_start_ - config.gutter_to_label - 64 gfx::Rect gutter_bounds(label_start_ - config.gutter_to_label -
65 config.gutter_width, 0, config.gutter_width, 65 config.gutter_width, 0, config.gutter_width,
66 height()); 66 height());
67 AdjustBoundsForRTLUI(&gutter_bounds); 67 AdjustBoundsForRTLUI(&gutter_bounds);
68 NativeTheme::ExtraParams extra; 68 NativeTheme::ExtraParams extra;
69 NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), 69 NativeTheme::instance()->Paint(canvas->GetSkCanvas(),
70 NativeTheme::kMenuPopupGutter, 70 NativeTheme::kMenuPopupGutter,
71 NativeTheme::kNormal, 71 NativeTheme::kNormal,
72 gutter_bounds, 72 gutter_bounds,
73 extra); 73 extra);
74 } 74 }
75 75
76 // Render the background. 76 // Render the background.
77 if (mode == PB_NORMAL) { 77 if (mode == PB_NORMAL) {
78 gfx::Rect item_bounds(0, 0, width(), height()); 78 gfx::Rect item_bounds(0, 0, width(), height());
79 NativeTheme::ExtraParams extra; 79 NativeTheme::ExtraParams extra;
80 extra.menu_item.is_selected = render_selection; 80 extra.menu_item.is_selected = render_selection;
81 AdjustBoundsForRTLUI(&item_bounds); 81 AdjustBoundsForRTLUI(&item_bounds);
82 NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), 82 NativeTheme::instance()->Paint(canvas->GetSkCanvas(),
83 NativeTheme::kMenuItemBackground, control_state, item_bounds, extra); 83 NativeTheme::kMenuItemBackground, control_state, item_bounds, extra);
84 } 84 }
85 85
86 int top_margin = GetTopMargin(); 86 int top_margin = GetTopMargin();
87 int bottom_margin = GetBottomMargin(); 87 int bottom_margin = GetBottomMargin();
88 88
89 if ((type_ == RADIO || type_ == CHECKBOX) && 89 if ((type_ == RADIO || type_ == CHECKBOX) &&
90 GetDelegate()->IsItemChecked(GetCommand())) { 90 GetDelegate()->IsItemChecked(GetCommand())) {
91 PaintCheck(canvas, control_state, render_selection ? SELECTED : UNSELECTED, 91 PaintCheck(canvas, control_state, render_selection ? SELECTED : UNSELECTED,
92 config); 92 config);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 config.label_to_arrow_padding, 0, 137 config.label_to_arrow_padding, 0,
138 config.arrow_width, height()); 138 config.arrow_width, height());
139 AdjustBoundsForRTLUI(&arrow_bounds); 139 AdjustBoundsForRTLUI(&arrow_bounds);
140 140
141 // If our sub menus open from right to left (which is the case when the 141 // If our sub menus open from right to left (which is the case when the
142 // locale is RTL) then we should make sure the menu arrow points to the 142 // locale is RTL) then we should make sure the menu arrow points to the
143 // right direction. 143 // right direction.
144 gfx::NativeTheme::ExtraParams extra; 144 gfx::NativeTheme::ExtraParams extra;
145 extra.menu_arrow.pointing_right = !base::i18n::IsRTL(); 145 extra.menu_arrow.pointing_right = !base::i18n::IsRTL();
146 extra.menu_arrow.is_selected = render_selection; 146 extra.menu_arrow.is_selected = render_selection;
147 gfx::NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), 147 gfx::NativeTheme::instance()->Paint(canvas->GetSkCanvas(),
148 gfx::NativeTheme::kMenuPopupArrow, control_state, arrow_bounds, extra); 148 gfx::NativeTheme::kMenuPopupArrow, control_state, arrow_bounds, extra);
149 } 149 }
150 } 150 }
151 151
152 void MenuItemView::PaintCheck(gfx::Canvas* canvas, 152 void MenuItemView::PaintCheck(gfx::Canvas* canvas,
153 NativeTheme::State state, 153 NativeTheme::State state,
154 SelectionState selection_state, 154 SelectionState selection_state,
155 const MenuConfig& config) { 155 const MenuConfig& config) {
156 int icon_width; 156 int icon_width;
157 int icon_height; 157 int icon_height;
158 if (type_ == RADIO) { 158 if (type_ == RADIO) {
159 icon_width = config.radio_width; 159 icon_width = config.radio_width;
160 icon_height = config.radio_height; 160 icon_height = config.radio_height;
161 } else { 161 } else {
162 icon_width = config.check_width; 162 icon_width = config.check_width;
163 icon_height = config.check_height; 163 icon_height = config.check_height;
164 } 164 }
165 165
166 int top_margin = GetTopMargin(); 166 int top_margin = GetTopMargin();
167 int icon_x = MenuConfig::instance().item_left_margin; 167 int icon_x = MenuConfig::instance().item_left_margin;
168 int icon_y = top_margin + 168 int icon_y = top_margin +
169 (height() - top_margin - GetBottomMargin() - icon_height) / 2; 169 (height() - top_margin - GetBottomMargin() - icon_height) / 2;
170 NativeTheme::ExtraParams extra; 170 NativeTheme::ExtraParams extra;
171 extra.menu_check.is_radio = type_ == RADIO; 171 extra.menu_check.is_radio = type_ == RADIO;
172 extra.menu_check.is_selected = selection_state == SELECTED; 172 extra.menu_check.is_selected = selection_state == SELECTED;
173 173
174 // Draw the background. 174 // Draw the background.
175 gfx::Rect bg_bounds(0, 0, icon_x + icon_width, height()); 175 gfx::Rect bg_bounds(0, 0, icon_x + icon_width, height());
176 AdjustBoundsForRTLUI(&bg_bounds); 176 AdjustBoundsForRTLUI(&bg_bounds);
177 NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), 177 NativeTheme::instance()->Paint(canvas->GetSkCanvas(),
178 NativeTheme::kMenuCheckBackground, state, bg_bounds, extra); 178 NativeTheme::kMenuCheckBackground, state, bg_bounds, extra);
179 179
180 // And the check. 180 // And the check.
181 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height); 181 gfx::Rect icon_bounds(icon_x / 2, icon_y, icon_width, icon_height);
182 AdjustBoundsForRTLUI(&icon_bounds); 182 AdjustBoundsForRTLUI(&icon_bounds);
183 NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), 183 NativeTheme::instance()->Paint(canvas->GetSkCanvas(),
184 NativeTheme::kMenuCheck, state, bg_bounds, extra); 184 NativeTheme::kMenuCheck, state, bg_bounds, extra);
185 } 185 }
186 186
187 } // namespace views 187 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698