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

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

Issue 11262002: Merge TextButton and LabelButton border images util structs, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add friend tests, remove unused variable. Created 8 years, 1 month 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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/string16.h" 11 #include "base/string16.h"
12 #include "third_party/skia/include/core/SkColor.h" 12 #include "third_party/skia/include/core/SkColor.h"
13 #include "ui/gfx/font.h" 13 #include "ui/gfx/font.h"
14 #include "ui/gfx/image/image_skia.h" 14 #include "ui/gfx/image/image_skia.h"
15 #include "ui/views/border.h" 15 #include "ui/views/border.h"
16 #include "ui/views/controls/button/border_images.h"
16 #include "ui/views/controls/button/custom_button.h" 17 #include "ui/views/controls/button/custom_button.h"
17 #include "ui/views/native_theme_delegate.h" 18 #include "ui/views/native_theme_delegate.h"
18 19
19 namespace views { 20 namespace views {
20 21
21 //////////////////////////////////////////////////////////////////////////////// 22 ////////////////////////////////////////////////////////////////////////////////
22 // 23 //
23 // TextButtonBorder 24 // TextButtonBorder
24 // 25 //
25 // A Border subclass that paints a TextButton's background layer - 26 // A Border subclass that paints a TextButton's background layer -
26 // basically the button frame in the hot/pushed states. 27 // basically the button frame in the hot/pushed states.
27 // 28 //
28 // Note that this type of button is not focusable by default and will not be 29 // Note that this type of button is not focusable by default and will not be
29 // part of the focus chain. Call set_focusable(true) to make it part of the 30 // part of the focus chain. Call set_focusable(true) to make it part of the
30 // focus chain. 31 // focus chain.
31 // 32 //
32 //////////////////////////////////////////////////////////////////////////////// 33 ////////////////////////////////////////////////////////////////////////////////
33 class VIEWS_EXPORT TextButtonBorder : public Border { 34 class VIEWS_EXPORT TextButtonBorder : public Border {
34 public: 35 public:
35 TextButtonBorder(); 36 TextButtonBorder();
36 virtual ~TextButtonBorder(); 37 virtual ~TextButtonBorder();
37 38
38 // 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
39 // with the same border as the "hot" state. 40 // with the same border as the "hot" state.
40 // 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
41 // the button in this case... we should fix this. 42 // the button in this case... we should fix this.
42 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_); }
43 44
44 protected: 45 protected:
45 struct BorderImageSet { 46 void set_normal_set(const BorderImages& set) { normal_set_ = set; }
46 const gfx::ImageSkia* top_left; 47 void set_hot_set(const BorderImages& set) { hot_set_ = set; }
47 const gfx::ImageSkia* top; 48 void set_pushed_set(const BorderImages& set) { pushed_set_ = set; }
48 const gfx::ImageSkia* top_right;
49 const gfx::ImageSkia* left;
50 const gfx::ImageSkia* center;
51 const gfx::ImageSkia* right;
52 const gfx::ImageSkia* bottom_left;
53 const gfx::ImageSkia* bottom;
54 const gfx::ImageSkia* bottom_right;
55 };
56 49
57 void Paint(const View& view,
58 gfx::Canvas* canvas,
59 const BorderImageSet& set) const;
60
61 void set_normal_set(const BorderImageSet& set) { normal_set_ = set; }
62 void set_hot_set(const BorderImageSet& set) { hot_set_ = set; }
63 void set_pushed_set(const BorderImageSet& set) { pushed_set_ = set; }
64 void set_vertical_padding(int vertical_padding) { 50 void set_vertical_padding(int vertical_padding) {
65 vertical_padding_ = vertical_padding; 51 vertical_padding_ = vertical_padding;
66 } 52 }
67 53
68 private: 54 private:
69 // Border: 55 // Border:
70 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE; 56 virtual void Paint(const View& view, gfx::Canvas* canvas) const OVERRIDE;
71 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE; 57 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE;
72 58
73 BorderImageSet normal_set_; 59 BorderImages normal_set_;
74 BorderImageSet hot_set_; 60 BorderImages hot_set_;
75 BorderImageSet pushed_set_; 61 BorderImages pushed_set_;
76 62
77 int vertical_padding_; 63 int vertical_padding_;
78 64
79 DISALLOW_COPY_AND_ASSIGN(TextButtonBorder); 65 DISALLOW_COPY_AND_ASSIGN(TextButtonBorder);
80 }; 66 };
81 67
82 68
83 //////////////////////////////////////////////////////////////////////////////// 69 ////////////////////////////////////////////////////////////////////////////////
84 // 70 //
85 // TextButtonNativeThemeBorder 71 // TextButtonNativeThemeBorder
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 // Overridden from TextButton: 402 // Overridden from TextButton:
417 virtual void GetExtraParams( 403 virtual void GetExtraParams(
418 ui::NativeTheme::ExtraParams* params) const OVERRIDE; 404 ui::NativeTheme::ExtraParams* params) const OVERRIDE;
419 405
420 DISALLOW_COPY_AND_ASSIGN(NativeTextButton); 406 DISALLOW_COPY_AND_ASSIGN(NativeTextButton);
421 }; 407 };
422 408
423 } // namespace views 409 } // namespace views
424 410
425 #endif // UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_ 411 #endif // UI_VIEWS_CONTROLS_BUTTON_TEXT_BUTTON_H_
OLDNEW
« no previous file with comments | « ui/views/controls/button/label_button_border.cc ('k') | ui/views/controls/button/text_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698