~azzar1/unity/fix-1028810

« back to all changes in this revision

Viewing changes to unity-shared/RatingsButton.h

  • Committer: Andrea Azzarone
  • Date: 2012-08-22 13:14:18 UTC
  • mfrom: (2516.1.92 unity)
  • Revision ID: azzaronea@gmail.com-20120822131418-mrfwx82k39xnvl9e
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2011 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License version 3, as
 
6
 * published by the  Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the applicable version of the GNU Lesser General Public
 
12
 * License for more details.
 
13
 *
 
14
 * You should have received a copy of both the GNU Lesser General Public
 
15
 * License version 3 along with this program.  If not, see
 
16
 * <http://www.gnu.org/licenses/>
 
17
 **
 
18
 * Authored by: Gordon Allott <gord.allott@canonical.com>
 
19
 *
 
20
 */
 
21
 
 
22
#ifndef UNITYSHELL_RATINGSBUTTONWIDGET_H
 
23
#define UNITYSHELL_RATINGSBUTTONWIDGET_H
 
24
 
 
25
#include <memory>
 
26
 
 
27
#include <Nux/Nux.h>
 
28
#include <Nux/ToggleButton.h>
 
29
#include "unity-shared/Introspectable.h"
 
30
 
 
31
namespace unity
 
32
{
 
33
 
 
34
class RatingsButton : public unity::debug::Introspectable, public nux::ToggleButton
 
35
{
 
36
public:
 
37
  RatingsButton(int star_size, int star_gap, NUX_FILE_LINE_PROTO);
 
38
  virtual ~RatingsButton();
 
39
 
 
40
  void SetEditable(bool editable);
 
41
  virtual void SetRating(float rating);
 
42
  virtual float GetRating() const;
 
43
 
 
44
protected:
 
45
  virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
 
46
 
 
47
  // Key-nav
 
48
  virtual bool AcceptKeyNavFocus();
 
49
  virtual bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
 
50
 
 
51
  // Introspectable methods
 
52
  std::string GetName() const;
 
53
  void AddProperties(GVariantBuilder* builder);
 
54
 
 
55
private:
 
56
  void OnKeyDown(unsigned long event_type, unsigned long event_keysym,
 
57
                 unsigned long event_state, const TCHAR* character,
 
58
                 unsigned short key_repeat_count);
 
59
 
 
60
  void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
 
61
  void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
 
62
  void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
 
63
  void UpdateRatingToMouse(int x);
 
64
 
 
65
 
 
66
protected:
 
67
  bool editable_;
 
68
  float rating_;
 
69
  int focused_star_;
 
70
  int star_size_;
 
71
  int star_gap_;
 
72
};
 
73
 
 
74
} // namespace unity
 
75
 
 
76
#endif // UNITYSHELL_RATINGSBUTTONWIDGET_H
 
77