~bilalakhtar/unity/fix-queuedraw-after-addlaunchericon

« back to all changes in this revision

Viewing changes to dash/previews/ActionButton.h

  • Committer: Tarmac
  • Author(s): Nick Dedekind, Gord Allott
  • Date: 2012-08-15 15:17:58 UTC
  • mfrom: (2419.4.70 unity.Preview)
  • Revision ID: tarmac-20120815151758-7tf3zgnndg5gocou
Added Music, App, Movie (basic) & Generic dash preview UIs and preview standalones.. Fixes: . Approved by Neil J. Patel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
 
2
/*
 
3
 * Copyright 2011 Canonical Ltd.
 
4
 *
 
5
 * This program is free software: you can redistribute it and/or modify it
 
6
 * under the terms of the GNU Lesser General Public License version 3, as
 
7
 * published by the  Free Software Foundation.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful, but
 
10
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
11
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
 
12
 * PURPOSE.  See the applicable version of the GNU Lesser General Public
 
13
 * License for more details.
 
14
 *
 
15
 * You should have received a copy of both the GNU Lesser General Public
 
16
 * License version 3 along with this program.  If not, see
 
17
 * <http://www.gnu.org/licenses/>
 
18
 *
 
19
 * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
 
20
 *
 
21
 */
 
22
 
 
23
#ifndef ACTIONBUTTON_H
 
24
#define ACTIONBUTTON_H
 
25
 
 
26
#include <Nux/Nux.h>
 
27
#include <Nux/CairoWrapper.h>
 
28
#include <Nux/AbstractButton.h>
 
29
 
 
30
namespace nux
 
31
{
 
32
class StaticCairoText;
 
33
}
 
34
 
 
35
namespace unity
 
36
{
 
37
class IconTexture;
 
38
 
 
39
namespace dash
 
40
{
 
41
 
 
42
class ActionButton : public nux::AbstractButton
 
43
{
 
44
public:
 
45
  ActionButton(std::string const& label, std::string const& icon_hint, NUX_FILE_LINE_PROTO);
 
46
  ~ActionButton();
 
47
 
 
48
  sigc::signal<void, ActionButton*> click;
 
49
 
 
50
  void SetFont(std::string const& font_hint);
 
51
 
 
52
  void Activate();
 
53
  void Deactivate();
 
54
 
 
55
protected:
 
56
  virtual long ComputeContentSize();
 
57
  virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
 
58
  virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) {}
 
59
  virtual void RecvClick(int x, int y, unsigned long button_flags, unsigned long key_flags);
 
60
 
 
61
  void Init();
 
62
  void InitTheme();
 
63
  void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state);
 
64
  void RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr);
 
65
 
 
66
  void BuildLayout(std::string const& label, std::string const& icon_hint);
 
67
 
 
68
private:
 
69
  typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;
 
70
 
 
71
  NuxCairoPtr cr_prelight_;
 
72
  NuxCairoPtr cr_active_;
 
73
  NuxCairoPtr cr_normal_;
 
74
  NuxCairoPtr cr_focus_;
 
75
 
 
76
  nux::Geometry cached_geometry_;
 
77
 
 
78
  std::string icon_hint_;
 
79
  std::string font_hint_;
 
80
 
 
81
  nux::ObjectPtr<IconTexture> image_;
 
82
  nux::ObjectPtr<nux::StaticCairoText> static_text_;
 
83
};
 
84
 
 
85
} // namespace dash
 
86
} // namespace unity
 
87
 
 
88
#endif // ACTIONBUTTON_H