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

Side by Side Diff: ui/views/controls/scrollbar/bitmap_scroll_bar.cc

Issue 10382144: Change SetImage, SetBackground, and SetToggledImage to take in a gfx::ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 7 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
« no previous file with comments | « ui/views/controls/scrollbar/bitmap_scroll_bar.h ('k') | ui/views/examples/button_example.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/views/controls/scrollbar/bitmap_scroll_bar.h" 5 #include "ui/views/controls/scrollbar/bitmap_scroll_bar.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 canvas->DrawBitmapInt(*end_cap_bitmap(), 0, 127 canvas->DrawBitmapInt(*end_cap_bitmap(), 0,
128 height() - bottom_cap_height); 128 height() - bottom_cap_height);
129 129
130 // Paint the grippy over the track. 130 // Paint the grippy over the track.
131 int grippy_x = (width() - grippy_bitmap()->width()) / 2; 131 int grippy_x = (width() - grippy_bitmap()->width()) / 2;
132 int grippy_y = (thumb_body_height - grippy_bitmap()->height()) / 2; 132 int grippy_y = (thumb_body_height - grippy_bitmap()->height()) / 2;
133 canvas->DrawBitmapInt(*grippy_bitmap(), grippy_x, grippy_y); 133 canvas->DrawBitmapInt(*grippy_bitmap(), grippy_x, grippy_y);
134 } 134 }
135 135
136 private: 136 private:
137 // Returns the bitmap rendered at the start of the thumb. 137 // Returns the image rendered at the start of the thumb.
138 SkBitmap* start_cap_bitmap() const { 138 gfx::ImageSkia* start_cap_bitmap() const {
139 return scroll_bar_->images_[BitmapScrollBar::THUMB_START_CAP][GetState()]; 139 return scroll_bar_->images_[BitmapScrollBar::THUMB_START_CAP][GetState()];
140 } 140 }
141 141
142 // Returns the bitmap rendered at the end of the thumb. 142 // Returns the image rendered at the end of the thumb.
143 SkBitmap* end_cap_bitmap() const { 143 gfx::ImageSkia* end_cap_bitmap() const {
144 return scroll_bar_->images_[BitmapScrollBar::THUMB_END_CAP][GetState()]; 144 return scroll_bar_->images_[BitmapScrollBar::THUMB_END_CAP][GetState()];
145 } 145 }
146 146
147 // Returns the bitmap that is tiled in the background of the thumb between 147 // Returns the image that is tiled in the background of the thumb between
148 // the start and the end caps. 148 // the start and the end caps.
149 SkBitmap* background_bitmap() const { 149 gfx::ImageSkia* background_bitmap() const {
150 return scroll_bar_->images_[BitmapScrollBar::THUMB_MIDDLE][GetState()]; 150 return scroll_bar_->images_[BitmapScrollBar::THUMB_MIDDLE][GetState()];
151 } 151 }
152 152
153 // Returns the bitmap that is rendered in the middle of the thumb 153 // Returns the image that is rendered in the middle of the thumb
154 // transparently over the background bitmap. 154 // transparently over the background bitmap.
155 SkBitmap* grippy_bitmap() const { 155 gfx::ImageSkia* grippy_bitmap() const {
156 return scroll_bar_->images_[BitmapScrollBar::THUMB_GRIPPY] 156 return scroll_bar_->images_[BitmapScrollBar::THUMB_GRIPPY]
157 [CustomButton::BS_NORMAL]; 157 [CustomButton::BS_NORMAL];
158 } 158 }
159 159
160 // The BitmapScrollBar that owns us. 160 // The BitmapScrollBar that owns us.
161 BitmapScrollBar* scroll_bar_; 161 BitmapScrollBar* scroll_bar_;
162 162
163 DISALLOW_COPY_AND_ASSIGN(BitmapScrollBarThumb); 163 DISALLOW_COPY_AND_ASSIGN(BitmapScrollBarThumb);
164 }; 164 };
165 165
(...skipping 15 matching lines...) Expand all
181 AddChildView(prev_button_); 181 AddChildView(prev_button_);
182 AddChildView(next_button_); 182 AddChildView(next_button_);
183 183
184 set_context_menu_controller(this); 184 set_context_menu_controller(this);
185 prev_button_->set_context_menu_controller(this); 185 prev_button_->set_context_menu_controller(this);
186 next_button_->set_context_menu_controller(this); 186 next_button_->set_context_menu_controller(this);
187 } 187 }
188 188
189 void BitmapScrollBar::SetImage(ScrollBarPart part, 189 void BitmapScrollBar::SetImage(ScrollBarPart part,
190 CustomButton::ButtonState state, 190 CustomButton::ButtonState state,
191 SkBitmap* bitmap) { 191 gfx::ImageSkia* image_skia) {
192 DCHECK(part < PART_COUNT); 192 DCHECK(part < PART_COUNT);
193 DCHECK(state < CustomButton::BS_COUNT); 193 DCHECK(state < CustomButton::BS_COUNT);
194 switch (part) { 194 switch (part) {
195 case PREV_BUTTON: 195 case PREV_BUTTON:
196 prev_button_->SetImage(state, bitmap); 196 prev_button_->SetImage(state, image_skia);
197 break; 197 break;
198 case NEXT_BUTTON: 198 case NEXT_BUTTON:
199 next_button_->SetImage(state, bitmap); 199 next_button_->SetImage(state, image_skia);
200 break; 200 break;
201 case THUMB_START_CAP: 201 case THUMB_START_CAP:
202 case THUMB_MIDDLE: 202 case THUMB_MIDDLE:
203 case THUMB_END_CAP: 203 case THUMB_END_CAP:
204 case THUMB_GRIPPY: 204 case THUMB_GRIPPY:
205 case THUMB_TRACK: 205 case THUMB_TRACK:
206 images_[part][state] = bitmap; 206 images_[part][state] = image_skia;
207 break; 207 break;
208 } 208 }
209 } 209 }
210 210
211 int BitmapScrollBar::GetLayoutSize() const { 211 int BitmapScrollBar::GetLayoutSize() const {
212 gfx::Size prefsize = prev_button_->GetPreferredSize(); 212 gfx::Size prefsize = prev_button_->GetPreferredSize();
213 return IsHorizontal() ? prefsize.height() : prefsize.width(); 213 return IsHorizontal() ? prefsize.height() : prefsize.width();
214 } 214 }
215 215
216 gfx::Rect BitmapScrollBar::GetTrackBounds() const { 216 gfx::Rect BitmapScrollBar::GetTrackBounds() const {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 301
302 void BitmapScrollBar::ButtonPressed(Button* sender, const views::Event& event) { 302 void BitmapScrollBar::ButtonPressed(Button* sender, const views::Event& event) {
303 if (sender == prev_button_) { 303 if (sender == prev_button_) {
304 ScrollByAmount(SCROLL_PREV_LINE); 304 ScrollByAmount(SCROLL_PREV_LINE);
305 } else if (sender == next_button_) { 305 } else if (sender == next_button_) {
306 ScrollByAmount(SCROLL_NEXT_LINE); 306 ScrollByAmount(SCROLL_NEXT_LINE);
307 } 307 }
308 } 308 }
309 309
310 } // namespace views 310 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scrollbar/bitmap_scroll_bar.h ('k') | ui/views/examples/button_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698