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

Side by Side Diff: ui/views/controls/button/text_button.h

Issue 10437006: Converts ui/views/controls, ui/views/examples, ui/base/models to 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
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 #ifndef UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_
6 #define UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ 6 #define UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "ui/gfx/image/image_skia.h"
msw 2012/05/29 07:50:51 nit: alphabetize.
14 #include "third_party/skia/include/core/SkColor.h" 14 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/gfx/font.h" 15 #include "ui/gfx/font.h"
16 #include "ui/views/border.h" 16 #include "ui/views/border.h"
17 #include "ui/views/controls/button/custom_button.h" 17 #include "ui/views/controls/button/custom_button.h"
18 #include "ui/views/native_theme_delegate.h" 18 #include "ui/views/native_theme_delegate.h"
19 19
20 namespace views { 20 namespace views {
21 21
22 //////////////////////////////////////////////////////////////////////////////// 22 ////////////////////////////////////////////////////////////////////////////////
23 // 23 //
(...skipping 13 matching lines...) Expand all
37 virtual ~TextButtonBorder(); 37 virtual ~TextButtonBorder();
38 38
39 // By default BS_NORMAL is drawn with no border. Call this to instead draw it 39 // By default BS_NORMAL is drawn with no border. Call this to instead draw it
40 // with the same border as the "hot" state. 40 // with the same border as the "hot" state.
41 // TODO(pkasting): You should also call set_animate_on_state_change(false) on 41 // TODO(pkasting): You should also call set_animate_on_state_change(false) on
42 // the button in this case... we should fix this. 42 // the button in this case... we should fix this.
43 void copy_normal_set_to_hot_set() { set_normal_set(hot_set_); } 43 void copy_normal_set_to_hot_set() { set_normal_set(hot_set_); }
44 44
45 protected: 45 protected:
46 struct BorderImageSet { 46 struct BorderImageSet {
47 const SkBitmap* top_left; 47 const gfx::ImageSkia* top_left;
48 const SkBitmap* top; 48 const gfx::ImageSkia* top;
49 const SkBitmap* top_right; 49 const gfx::ImageSkia* top_right;
50 const SkBitmap* left; 50 const gfx::ImageSkia* left;
51 const SkBitmap* center; 51 const gfx::ImageSkia* center;
52 const SkBitmap* right; 52 const gfx::ImageSkia* right;
53 const SkBitmap* bottom_left; 53 const gfx::ImageSkia* bottom_left;
54 const SkBitmap* bottom; 54 const gfx::ImageSkia* bottom;
55 const SkBitmap* bottom_right; 55 const gfx::ImageSkia* bottom_right;
56 }; 56 };
57 57
58 void Paint(const View& view, 58 void Paint(const View& view,
59 gfx::Canvas* canvas, 59 gfx::Canvas* canvas,
60 const BorderImageSet& set) const; 60 const BorderImageSet& set) const;
61 61
62 void set_normal_set(const BorderImageSet& set) { normal_set_ = set; } 62 void set_normal_set(const BorderImageSet& set) { normal_set_ = set; }
63 void set_hot_set(const BorderImageSet& set) { hot_set_ = set; } 63 void set_hot_set(const BorderImageSet& set) { hot_set_ = set; }
64 void set_pushed_set(const BorderImageSet& set) { pushed_set_ = set; } 64 void set_pushed_set(const BorderImageSet& set) { pushed_set_ = set; }
65 void set_vertical_padding(int vertical_padding) { 65 void set_vertical_padding(int vertical_padding) {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 static const char kViewClassName[]; 313 static const char kViewClassName[];
314 314
315 TextButton(ButtonListener* listener, const string16& text); 315 TextButton(ButtonListener* listener, const string16& text);
316 virtual ~TextButton(); 316 virtual ~TextButton();
317 317
318 void set_icon_text_spacing(int icon_text_spacing) { 318 void set_icon_text_spacing(int icon_text_spacing) {
319 icon_text_spacing_ = icon_text_spacing; 319 icon_text_spacing_ = icon_text_spacing;
320 } 320 }
321 321
322 // Sets the icon. 322 // Sets the icon.
323 virtual void SetIcon(const SkBitmap& icon); 323 virtual void SetIcon(const gfx::ImageSkia& icon);
324 virtual void SetHoverIcon(const SkBitmap& icon); 324 virtual void SetHoverIcon(const gfx::ImageSkia& icon);
325 virtual void SetPushedIcon(const SkBitmap& icon); 325 virtual void SetPushedIcon(const gfx::ImageSkia& icon);
326 326
327 bool HasIcon() const { return !icon_.empty(); } 327 bool HasIcon() const { return !icon_.empty(); }
328 328
329 // Meanings are reversed for right-to-left layouts. 329 // Meanings are reversed for right-to-left layouts.
330 enum IconPlacement { 330 enum IconPlacement {
331 ICON_ON_LEFT, 331 ICON_ON_LEFT,
332 ICON_ON_RIGHT 332 ICON_ON_RIGHT
333 }; 333 };
334 334
335 IconPlacement icon_placement() { return icon_placement_; } 335 IconPlacement icon_placement() { return icon_placement_; }
336 void set_icon_placement(IconPlacement icon_placement) { 336 void set_icon_placement(IconPlacement icon_placement) {
337 icon_placement_ = icon_placement; 337 icon_placement_ = icon_placement;
338 } 338 }
339 339
340 void set_ignore_minimum_size(bool ignore_minimum_size); 340 void set_ignore_minimum_size(bool ignore_minimum_size);
341 341
342 // Overridden from View: 342 // Overridden from View:
343 virtual gfx::Size GetPreferredSize() OVERRIDE; 343 virtual gfx::Size GetPreferredSize() OVERRIDE;
344 virtual std::string GetClassName() const OVERRIDE; 344 virtual std::string GetClassName() const OVERRIDE;
345 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; 345 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
346 346
347 // Overridden from TextButtonBase: 347 // Overridden from TextButtonBase:
348 virtual void PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) OVERRIDE; 348 virtual void PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) OVERRIDE;
349 349
350 protected: 350 protected:
351 SkBitmap icon() const { return icon_; } 351 gfx::ImageSkia icon() const { return icon_; }
352 352
353 virtual const SkBitmap& GetImageToPaint() const; 353 virtual const gfx::ImageSkia& GetImageToPaint() const;
354 354
355 // Overridden from NativeThemeDelegate: 355 // Overridden from NativeThemeDelegate:
356 virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE; 356 virtual ui::NativeTheme::Part GetThemePart() const OVERRIDE;
357 357
358 // Overridden from TextButtonBase: 358 // Overridden from TextButtonBase:
359 virtual void GetExtraParams( 359 virtual void GetExtraParams(
360 ui::NativeTheme::ExtraParams* params) const OVERRIDE; 360 ui::NativeTheme::ExtraParams* params) const OVERRIDE;
361 virtual gfx::Rect GetTextBounds() const OVERRIDE; 361 virtual gfx::Rect GetTextBounds() const OVERRIDE;
362 362
363 private: 363 private:
364 // The position of the icon. 364 // The position of the icon.
365 IconPlacement icon_placement_; 365 IconPlacement icon_placement_;
366 366
367 // An icon displayed with the text. 367 // An icon displayed with the text.
368 SkBitmap icon_; 368 gfx::ImageSkia icon_;
369 369
370 // An optional different version of the icon for hover state. 370 // An optional different version of the icon for hover state.
371 SkBitmap icon_hover_; 371 gfx::ImageSkia icon_hover_;
372 bool has_hover_icon_; 372 bool has_hover_icon_;
373 373
374 // An optional different version of the icon for pushed state. 374 // An optional different version of the icon for pushed state.
375 SkBitmap icon_pushed_; 375 gfx::ImageSkia icon_pushed_;
376 bool has_pushed_icon_; 376 bool has_pushed_icon_;
377 377
378 // Space between icon and text. 378 // Space between icon and text.
379 int icon_text_spacing_; 379 int icon_text_spacing_;
380 380
381 // True if the button should ignore the minimum size for the platform. Default 381 // True if the button should ignore the minimum size for the platform. Default
382 // is true. Set to false to prevent narrower buttons. 382 // is true. Set to false to prevent narrower buttons.
383 bool ignore_minimum_size_; 383 bool ignore_minimum_size_;
384 384
385 DISALLOW_COPY_AND_ASSIGN(TextButton); 385 DISALLOW_COPY_AND_ASSIGN(TextButton);
(...skipping 28 matching lines...) Expand all
414 // Overridden from TextButton: 414 // Overridden from TextButton:
415 virtual void GetExtraParams( 415 virtual void GetExtraParams(
416 ui::NativeTheme::ExtraParams* params) const OVERRIDE; 416 ui::NativeTheme::ExtraParams* params) const OVERRIDE;
417 417
418 DISALLOW_COPY_AND_ASSIGN(NativeTextButton); 418 DISALLOW_COPY_AND_ASSIGN(NativeTextButton);
419 }; 419 };
420 420
421 } // namespace views 421 } // namespace views
422 422
423 #endif // UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ 423 #endif // UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698