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

Side by Side Diff: chrome/browser/views/star_toggle.h

Issue 543215: Added Star button to compact navigation mode.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_VIEWS_STAR_TOGGLE_H_
6 #define CHROME_BROWSER_VIEWS_STAR_TOGGLE_H_
7
8 #include "views/view.h"
9 #include "views/event.h"
10
11 class SkBitmap;
12
13 ////////////////////////////////////////////////////////////////////////////////
14 //
15 // A view subclass to implement the star button. The star button notifies its
16 // Delegate when the state changes.
17 //
18 ////////////////////////////////////////////////////////////////////////////////
19 class StarToggle : public views::View {
20 public:
21 class Delegate {
22 public:
23 // Called when the star is toggled.
24 virtual void StarStateChanged(bool state) = 0;
25 };
26
27 explicit StarToggle(Delegate* delegate);
28 virtual ~StarToggle();
29
30 // Set whether the star is checked.
31 void SetState(bool s);
32 bool GetState() const;
33
34 // If true (the default) the state is immediately changed on a mouse release.
35 // If false, on mouse release the delegate is notified, but the state is not
36 // changed.
37 void set_change_state_immediately(bool value) {
38 change_state_immediately_ = value;
39 }
40
41 // Check/uncheck the star.
42 void SwitchState();
43
44 // Overriden from view.
45 void Paint(gfx::Canvas* canvas);
46 gfx::Size GetPreferredSize();
47 virtual bool OnMousePressed(const views::MouseEvent& e);
48 virtual bool OnMouseDragged(const views::MouseEvent& event);
49 virtual void OnMouseReleased(const views::MouseEvent& e, bool canceled);
50 bool OnKeyPressed(const views::KeyEvent& e);
51
52 private:
53 // The state.
54 bool state_;
55
56 // Our bitmap.
57 SkBitmap* state_off_;
58 SkBitmap* state_on_;
59
60 // Parent to be notified.
61 Delegate* delegate_;
62
63 // See note in setter.
64 bool change_state_immediately_;
65
66 DISALLOW_EVIL_CONSTRUCTORS(StarToggle);
67 };
68
69 #endif // CHROME_BROWSER_VIEWS_STAR_TOGGLE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/compact_location_bar_view.cc ('k') | chrome/browser/views/star_toggle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698