~azzar1/unity/fix-trash-li-blocking

« back to all changes in this revision

Viewing changes to plugins/unityshell/src/Tooltip.h

  • Committer: Daniel van Vugt
  • Date: 2012-03-14 06:24:18 UTC
  • mfrom: (2108 unity)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: daniel.van.vugt@canonical.com-20120314062418-nprucpbr0m7qky5e
Merged latest lp:unity

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
2
2
/*
3
 
 * Copyright (C) 2010 Canonical Ltd
 
3
 * Copyright (C) 2010-2012 Canonical Ltd
4
4
 *
5
5
 * This program is free software: you can redistribute it and/or modify
6
6
 * it under the terms of the GNU General Public License version 3 as
15
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
16
 *
17
17
 * Authored by: Jay Taoko <jay.taoko@canonical.com>
18
 
 * Authored by: Mirco Müller <mirco.mueller@canonical.com
 
18
 *              Mirco Müller <mirco.mueller@canonical.com
 
19
 *              Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
19
20
 */
20
21
 
21
22
#ifndef TOOLTIP_H
22
23
#define TOOLTIP_H
23
24
 
24
 
 
25
25
#include <Nux/Nux.h>
26
26
#include <Nux/BaseWindow.h>
27
 
#include <NuxGraphics/GraphicsEngine.h>
28
 
#include <Nux/TextureArea.h>
29
 
#include <NuxImage/CairoGraphics.h>
 
27
#include <Nux/HLayout.h>
 
28
#include <Nux/VLayout.h>
 
29
 
 
30
#include "CairoBaseWindow.h"
30
31
#include "StaticCairoText.h"
31
 
 
32
 
#include <pango/pango.h>
33
 
#include <pango/pangocairo.h>
34
 
 
35
32
#include "Introspectable.h"
36
33
 
37
 
#if defined(NUX_OS_LINUX)
38
 
#include <X11/Xlib.h>
39
 
#endif
40
 
 
41
 
#define ANCHOR_WIDTH         10.0f
42
 
#define ANCHOR_HEIGHT        18.0f
43
 
#define HIGH_LIGHT_Y         -30.0f
44
 
#define HIGH_LIGHT_MIN_WIDTH 200.0f
45
 
#define RADIUS               5.0f
46
 
#define BLUR_INTENSITY       8
47
 
#define LINE_WIDTH           1.0f
48
 
#define PADDING_SIZE         1
49
 
#define H_MARGIN             30
50
 
#define V_MARGIN             4
51
 
#define FONT_FACE            "Ubuntu 13"
52
 
 
53
 
class QuicklistMenuItem;
54
 
 
55
 
namespace nux
56
 
{
57
 
class VLayout;
58
 
class HLayout;
59
 
class SpaceLayout;
60
 
 
61
 
class Tooltip : public BaseWindow, public unity::debug::Introspectable
62
 
{
63
 
  NUX_DECLARE_OBJECT_TYPE(Tooltip, BaseWindow);
 
34
namespace unity
 
35
{
 
36
class Tooltip : public CairoBaseWindow, public debug::Introspectable
 
37
{
 
38
  NUX_DECLARE_OBJECT_TYPE(Tooltip, CairoBaseWindow);
64
39
public:
65
40
  Tooltip();
66
41
 
67
 
  ~Tooltip();
68
 
 
69
 
  void Draw(GraphicsEngine& gfxContext,
70
 
            bool             forceDraw);
71
 
 
72
 
  void DrawContent(GraphicsEngine& gfxContext,
73
 
                   bool             forceDraw);
74
 
 
75
 
  void SetText(NString text);
 
42
  void Draw(nux::GraphicsEngine& gfxContext, bool forceDraw);
 
43
  void DrawContent(nux::GraphicsEngine& gfxContext, bool forceDraw);
 
44
 
 
45
  void SetText(std::string const& text);
76
46
 
77
47
  void ShowTooltipWithTipAt(int anchor_tip_x, int anchor_tip_y);
78
48
 
80
50
  std::string GetName() const;
81
51
  void AddProperties(GVariantBuilder* builder);
82
52
 
83
 
  virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
 
53
  virtual nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, nux::NuxEventType event_type);
84
54
 
85
55
private:
86
 
  void RecvCairoTextChanged(StaticCairoText* cairo_text);
 
56
  void RecvCairoTextChanged(nux::StaticCairoText* cairo_text);
87
57
 
88
58
  void PreLayoutManagement();
89
59
 
97
67
  void NotifyConfigurationChange(int width,
98
68
                                 int height);
99
69
 
100
 
  //nux::CairoGraphics*   _cairo_graphics;
101
70
  int                   _anchorX;
102
71
  int                   _anchorY;
103
 
  nux::NString          _labelText;
104
 
  int                   _top_size; // size of the segment from point 13 to 14. See figure in _compute_full_mask_path.
105
 
 
106
 
  nux::StaticCairoText* _tooltip_text;
107
 
  nux::BaseTexture*     _texture_bg;
108
 
  nux::BaseTexture*     _texture_mask;
109
 
  nux::BaseTexture*     _texture_outline;
110
 
 
111
 
  float _anchor_width;
112
 
  float _anchor_height;
113
 
  float _corner_radius;
114
 
  float _padding;
 
72
  std::string           _labelText;
 
73
 
 
74
  nux::ObjectPtr<nux::StaticCairoText> _tooltip_text;
 
75
 
115
76
  nux::HLayout* _hlayout;
116
 
  VLayout* _vlayout;
 
77
  nux::VLayout* _vlayout;
117
78
  nux::SpaceLayout* _left_space;  //!< Space from the left of the widget to the left of the text.
118
79
  nux::SpaceLayout* _right_space; //!< Space from the right of the text to the right of the widget.
119
80
  nux::SpaceLayout* _top_space;  //!< Space from the left of the widget to the left of the text.