OLD | NEW |
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 "chrome/browser/ui/views/wrench_menu.h" | 5 #include "chrome/browser/ui/views/wrench_menu.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 } | 139 } |
140 | 140 |
141 virtual void Paint(gfx::Canvas* canvas, View* view) const { | 141 virtual void Paint(gfx::Canvas* canvas, View* view) const { |
142 CustomButton::ButtonState state = | 142 CustomButton::ButtonState state = |
143 (view->GetClassName() == views::Label::kViewClassName) ? | 143 (view->GetClassName() == views::Label::kViewClassName) ? |
144 CustomButton::BS_NORMAL : static_cast<CustomButton*>(view)->state(); | 144 CustomButton::BS_NORMAL : static_cast<CustomButton*>(view)->state(); |
145 int w = view->width(); | 145 int w = view->width(); |
146 int h = view->height(); | 146 int h = view->height(); |
147 switch (TypeAdjustedForRTL()) { | 147 switch (TypeAdjustedForRTL()) { |
148 case LEFT_BUTTON: | 148 case LEFT_BUTTON: |
149 canvas->FillRect(background_color(state), gfx::Rect(1, 1, w, h - 2)); | 149 canvas->FillRect(gfx::Rect(1, 1, w, h - 2), background_color(state)); |
150 canvas->FillRect(border_color(state), gfx::Rect(2, 0, w, 1)); | 150 canvas->FillRect(gfx::Rect(2, 0, w, 1), border_color(state)); |
151 canvas->FillRect(border_color(state), gfx::Rect(1, 1, 1, 1)); | 151 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(state)); |
152 canvas->FillRect(border_color(state), gfx::Rect(0, 2, 1, h - 4)); | 152 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(state)); |
153 canvas->FillRect(border_color(state), gfx::Rect(1, h - 2, 1, 1)); | 153 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(state)); |
154 canvas->FillRect(border_color(state), gfx::Rect(2, h - 1, w, 1)); | 154 canvas->FillRect(gfx::Rect(2, h - 1, w, 1), border_color(state)); |
155 break; | 155 break; |
156 | 156 |
157 case CENTER_BUTTON: { | 157 case CENTER_BUTTON: { |
158 canvas->FillRect(background_color(state), | 158 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), |
159 gfx::Rect(1, 1, w - 2, h - 2)); | 159 background_color(state)); |
160 SkColor left_color = state != CustomButton::BS_NORMAL ? | 160 SkColor left_color = state != CustomButton::BS_NORMAL ? |
161 border_color(state) : border_color(left_button_->state()); | 161 border_color(state) : border_color(left_button_->state()); |
162 canvas->FillRect(left_color, gfx::Rect(0, 0, 1, h)); | 162 canvas->FillRect(gfx::Rect(0, 0, 1, h), left_color); |
163 canvas->FillRect(border_color(state), gfx::Rect(1, 0, w - 2, 1)); | 163 canvas->FillRect(gfx::Rect(1, 0, w - 2, 1), border_color(state)); |
164 canvas->FillRect(border_color(state), gfx::Rect(1, h - 1, w - 2, 1)); | 164 canvas->FillRect(gfx::Rect(1, h - 1, w - 2, 1), border_color(state)); |
165 SkColor right_color = state != CustomButton::BS_NORMAL ? | 165 SkColor right_color = state != CustomButton::BS_NORMAL ? |
166 border_color(state) : border_color(right_button_->state()); | 166 border_color(state) : border_color(right_button_->state()); |
167 canvas->FillRect(right_color, gfx::Rect(w - 1, 0, 1, h)); | 167 canvas->FillRect(gfx::Rect(w - 1, 0, 1, h), right_color); |
168 break; | 168 break; |
169 } | 169 } |
170 | 170 |
171 case RIGHT_BUTTON: | 171 case RIGHT_BUTTON: |
172 canvas->FillRect(background_color(state), | 172 canvas->FillRect(gfx::Rect(0, 1, w - 1, h - 2), |
173 gfx::Rect(0, 1, w - 1, h - 2)); | 173 background_color(state)); |
174 canvas->FillRect(border_color(state), gfx::Rect(0, 0, w - 2, 1)); | 174 canvas->FillRect(gfx::Rect(0, 0, w - 2, 1), border_color(state)); |
175 canvas->FillRect(border_color(state), gfx::Rect(w - 2, 1, 1, 1)); | 175 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(state)); |
176 canvas->FillRect(border_color(state), gfx::Rect(w - 1, 2, 1, h - 4)); | 176 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border_color(state)); |
177 canvas->FillRect(border_color(state), gfx::Rect(w - 2, h - 2, 1, 1)); | 177 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border_color(state)); |
178 canvas->FillRect(border_color(state), gfx::Rect(0, h - 1, w - 2, 1)); | 178 canvas->FillRect(gfx::Rect(0, h - 1, w - 2, 1), border_color(state)); |
179 break; | 179 break; |
180 | 180 |
181 case SINGLE_BUTTON: | 181 case SINGLE_BUTTON: |
182 canvas->FillRect(background_color(state), | 182 canvas->FillRect(gfx::Rect(1, 1, w - 2, h - 2), |
183 gfx::Rect(1, 1, w - 2, h - 2)); | 183 background_color(state)); |
184 canvas->FillRect(border_color(state), gfx::Rect(2, 0, w - 4, 1)); | 184 canvas->FillRect(gfx::Rect(2, 0, w - 4, 1), border_color(state)); |
185 canvas->FillRect(border_color(state), gfx::Rect(1, 1, 1, 1)); | 185 canvas->FillRect(gfx::Rect(1, 1, 1, 1), border_color(state)); |
186 canvas->FillRect(border_color(state), gfx::Rect(0, 2, 1, h - 4)); | 186 canvas->FillRect(gfx::Rect(0, 2, 1, h - 4), border_color(state)); |
187 canvas->FillRect(border_color(state), gfx::Rect(1, h - 2, 1, 1)); | 187 canvas->FillRect(gfx::Rect(1, h - 2, 1, 1), border_color(state)); |
188 canvas->FillRect(border_color(state), gfx::Rect(2, h - 1, w - 4, 1)); | 188 canvas->FillRect(gfx::Rect(2, h - 1, w - 4, 1), border_color(state)); |
189 canvas->FillRect(border_color(state), gfx::Rect(w - 2, 1, 1, 1)); | 189 canvas->FillRect(gfx::Rect(w - 2, 1, 1, 1), border_color(state)); |
190 canvas->FillRect(border_color(state), gfx::Rect(w - 1, 2, 1, h - 4)); | 190 canvas->FillRect(gfx::Rect(w - 1, 2, 1, h - 4), border_color(state)); |
191 canvas->FillRect(border_color(state), gfx::Rect(w - 2, h - 2, 1, 1)); | 191 canvas->FillRect(gfx::Rect(w - 2, h - 2, 1, 1), border_color(state)); |
192 break; | 192 break; |
193 | 193 |
194 default: | 194 default: |
195 NOTREACHED(); | 195 NOTREACHED(); |
196 break; | 196 break; |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 private: | 200 private: |
201 static SkColor border_color(CustomButton::ButtonState state) { | 201 static SkColor border_color(CustomButton::ButtonState state) { |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 bookmark_menu_delegate_.reset( | 894 bookmark_menu_delegate_.reset( |
895 new BookmarkMenuDelegate(browser_->profile(), | 895 new BookmarkMenuDelegate(browser_->profile(), |
896 NULL, | 896 NULL, |
897 parent, | 897 parent, |
898 first_bookmark_command_id_)); | 898 first_bookmark_command_id_)); |
899 bookmark_menu_delegate_->Init( | 899 bookmark_menu_delegate_->Init( |
900 this, bookmark_menu_, model->bookmark_bar_node(), 0, | 900 this, bookmark_menu_, model->bookmark_bar_node(), 0, |
901 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, | 901 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, |
902 bookmark_utils::LAUNCH_WRENCH_MENU); | 902 bookmark_utils::LAUNCH_WRENCH_MENU); |
903 } | 903 } |
OLD | NEW |