~mial/ubuntu/oneiric/unity/bug-791810

« back to all changes in this revision

Viewing changes to src/Tooltip.h

Import the work done so far with Compiz

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef TOOLTIP_H
 
2
#define TOOLTIP_H
 
3
 
 
4
#include "Nux/Nux.h"
 
5
#include "Nux/BaseWindow.h"
 
6
#include "NuxGraphics/OpenGLEngine.h"
 
7
#include "NuxGraphics/GfxEventsX11.h"
 
8
#include "NuxGraphics/GfxSetupX11.h"
 
9
#include "Nux/TextureArea.h"
 
10
#include "NuxImage/CairoGraphics.h"
 
11
 
 
12
#include <pango/pango.h>
 
13
#include <pango/pangocairo.h>
 
14
 
 
15
#if defined(NUX_OS_LINUX)
 
16
#include <X11/Xlib.h>
 
17
#endif
 
18
 
 
19
#define ANCHOR_WIDTH         10.0f
 
20
#define ANCHOR_HEIGHT        18.0f
 
21
#define HIGH_LIGHT_Y         -30.0f
 
22
#define HIGH_LIGHT_MIN_WIDTH 200.0f 
 
23
#define RADIUS               5.0f
 
24
#define BLUR_INTENSITY       8
 
25
#define LINE_WIDTH           1.0f
 
26
#define PADDING_SIZE         1
 
27
#define H_MARGIN             30
 
28
#define V_MARGIN             4
 
29
#define FONT_FACE            "Ubuntu 13"
 
30
 
 
31
namespace nux
 
32
{
 
33
  class Tooltip : public BaseWindow
 
34
  {
 
35
    NUX_DECLARE_OBJECT_TYPE (Tooltip, BaseWindow);
 
36
    public:
 
37
      Tooltip ();
 
38
 
 
39
      ~Tooltip ();
 
40
 
 
41
      long ProcessEvent (IEvent& iEvent,
 
42
                         long    traverseInfo,
 
43
                         long    processEventInfo);
 
44
 
 
45
      void Draw (GraphicsContext& gfxContext,
 
46
                 bool             forceDraw);
 
47
 
 
48
      void DrawContent (GraphicsContext& gfxContext,
 
49
                        bool             forceDraw);
 
50
 
 
51
      void SetText (NString text);
 
52
 
 
53
    protected:
 
54
      void PreLayoutManagement ();
 
55
 
 
56
      long PostLayoutManagement (long layoutResult);
 
57
 
 
58
      void PositionChildLayout (float offsetX,
 
59
                                float offsetY);
 
60
 
 
61
      void LayoutWindowElements ();
 
62
 
 
63
      void NotifyConfigurationChange (int width,
 
64
                                      int height);
 
65
                                      
 
66
      nux::CairoGraphics*   _cairo_graphics;
 
67
      nux::BaseTexture*        _texture2D;
 
68
      int                   _anchorX;
 
69
      int                   _anchorY;
 
70
      nux::NString          _labelText;
 
71
      int                   _dpiX;
 
72
      int                   _dpiY;
 
73
      cairo_font_options_t* _fontOpts;
 
74
 
 
75
    private:
 
76
      void UpdateTexture ();
 
77
 
 
78
      void ComputeFullMaskPath (cairo_t* cr,
 
79
                                gfloat   anchor_width,
 
80
                                gfloat   anchor_height,
 
81
                                gint     width,
 
82
                                gint     height,
 
83
                                gint     upper_size,
 
84
                                gfloat   radius,
 
85
                                guint    pad);
 
86
 
 
87
      void DrawDraw (cairo_t* cr,
 
88
                     gboolean outline,
 
89
                     gfloat   line_width,
 
90
                     gfloat*  rgba,
 
91
                     gboolean negative,
 
92
                     gboolean stroke);
 
93
 
 
94
      void DrawTintDotHighlight (cairo_t* cr,
 
95
                                 gint     width,
 
96
                                 gint     height,
 
97
                                 gfloat   hl_x,
 
98
                                 gfloat   hl_y,
 
99
                                 gfloat   hl_size,
 
100
                                 gfloat*  rgba_tint,
 
101
                                 gfloat*  rgba_hl);
 
102
 
 
103
      void DrawOutlineShadow (cairo_t* cr,
 
104
                              gint     width,
 
105
                              gint     height,
 
106
                              gfloat   anchor_width,
 
107
                              gfloat   anchor_height,
 
108
                              gint     upper_size,
 
109
                              gfloat   corner_radius,
 
110
                              guint    blur_coeff,
 
111
                              gfloat*  rgba_shadow,
 
112
                              gfloat   line_width,
 
113
                              gint     padding_size,
 
114
                              gfloat*  rgba_line);
 
115
 
 
116
      void ComputeOutline (cairo_t* cr,
 
117
                           gfloat   line_width,
 
118
                           gfloat*  rgba_line,
 
119
                           gint     width,
 
120
                           gfloat   anchor_width,
 
121
                           gfloat   corner_radius,
 
122
                           gint     padding_size);
 
123
 
 
124
      void DrawMask (cairo_t* cr,
 
125
                     gint     width,
 
126
                     gint     height,
 
127
                     gfloat   radius,
 
128
                     guint    shadow_radius,
 
129
                     gfloat   anchor_width,
 
130
                     gfloat   anchor_height,
 
131
                     gint     upper_size,
 
132
                     gboolean negative,
 
133
                     gboolean outline,
 
134
                     gfloat   line_width,
 
135
                     gint     padding_size,
 
136
                     gfloat*  rgba);
 
137
 
 
138
      void GetDPI ();
 
139
 
 
140
      void GetTextExtents (char* font,
 
141
                           int*  width,
 
142
                           int*  height);
 
143
 
 
144
      void DrawLabel (cairo_t* cr,
 
145
                      gint     width,
 
146
                      gint     height,
 
147
                      gfloat*  rgba);
 
148
  };
 
149
}
 
150
 
 
151
#endif // TOOLTIP_H
 
152