~3v1n0/unity/shield-notify-grabs

« back to all changes in this revision

Viewing changes to standalone-clients/TestDashStyle.cpp

  • Committer: Tarmac
  • Author(s): Gord Allott
  • Date: 2012-05-08 02:32:33 UTC
  • mfrom: (2350.2.9 unity-relayout)
  • Revision ID: tarmac-20120508023233-4123btyqarvu35q1
re-architectures the physical file structure of unity
now several souce directories inside of unity that each house their own specific files. Fixes: . Approved by Gord Allott, Tim Penhey.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2011 Canonical Ltd
3
 
 *
4
 
 * This program is free software: you can redistribute it and/or modify
5
 
 * it under the terms of the GNU 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,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 * GNU General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU General Public License
14
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 
 *
16
 
 * Authored by: Mirco Müller <mirco.mueller@canonical.com
17
 
 */
18
 
 
19
 
#include "DashStyle.h"
20
 
 
21
 
namespace unity
22
 
{
23
 
  class DashStyleO : public dash::Style
24
 
  {
25
 
    public:
26
 
      DashStyleO();
27
 
      ~DashStyleO();
28
 
 
29
 
      bool ScrollbarVert (cairo_t* cr, nux::ButtonVisualState state);
30
 
      bool TrackView (cairo_t* cr, nux::ButtonVisualState state);
31
 
  };
32
 
 
33
 
  class DashStyleP : public dash::Style
34
 
  {
35
 
    public:
36
 
      DashStyleP();
37
 
      ~DashStyleP();
38
 
 
39
 
      bool ScrollbarVert (cairo_t* cr, nux::ButtonVisualState state);
40
 
      bool TrackView (cairo_t* cr, nux::ButtonVisualState state);
41
 
  };
42
 
 
43
 
  DashStyleO::DashStyleO ()
44
 
  {
45
 
  }
46
 
 
47
 
  DashStyleO::~DashStyleO ()
48
 
  {
49
 
  }
50
 
 
51
 
  bool DashStyleO::ScrollbarVert (cairo_t* cr, nux::ButtonVisualState state)
52
 
  {
53
 
    cairo_set_source_rgba (cr, 0.0, 1.0, 0.0, 1.0);
54
 
    cairo_paint (cr);
55
 
 
56
 
    return true;
57
 
  }
58
 
 
59
 
  bool DashStyleO::TrackView (cairo_t* cr, nux::ButtonVisualState state)
60
 
  {
61
 
    cairo_set_source_rgba (cr, 0.0, 1.0, 1.0, 1.0);
62
 
    cairo_paint (cr);
63
 
 
64
 
    return true;
65
 
  }
66
 
 
67
 
  DashStyleP::DashStyleP ()
68
 
  {
69
 
  }
70
 
 
71
 
  DashStyleP::~DashStyleP ()
72
 
  {
73
 
  }
74
 
 
75
 
  bool DashStyleP::ScrollbarVert (cairo_t* cr, nux::ButtonVisualState state)
76
 
  {
77
 
    cairo_set_source_rgba (cr, 1.0, 0.0, 0.0, 1.0);
78
 
    cairo_paint (cr);
79
 
 
80
 
    return true;
81
 
  }
82
 
 
83
 
  bool DashStyleP::TrackView (cairo_t* cr, nux::ButtonVisualState state)
84
 
  {
85
 
    cairo_set_source_rgba (cr, 1.0, 1.0, 0.0, 1.0);
86
 
    cairo_paint (cr);
87
 
 
88
 
    return true;
89
 
  }
90
 
}
91
 
 
92
 
void wipe (cairo_t* cr)
93
 
{
94
 
  // sanity check
95
 
  if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
96
 
    return;
97
 
 
98
 
  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
99
 
  cairo_paint (cr);
100
 
  cairo_scale (cr, 1.0, 1.0);
101
 
  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
102
 
}
103
 
 
104
 
int main (int    argc,
105
 
          char** argv)
106
 
{
107
 
  g_type_init();
108
 
  // setup
109
 
  unity::DashStyleP* pDashStyle = new unity::DashStyleP ();
110
 
  cairo_surface_t* surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
111
 
                                                         100,
112
 
                                                         30);
113
 
  cairo_t* cr = cairo_create (surface);
114
 
  wipe (cr);
115
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/empty.png");
116
 
 
117
 
  // render some elements from different styles to PNG-images
118
 
  pDashStyle->Button (cr, nux::VISUAL_STATE_NORMAL, "Play");
119
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/button-normal.png");
120
 
  wipe (cr);
121
 
 
122
 
  pDashStyle->Button (cr, nux::VISUAL_STATE_PRESSED, "Pause");
123
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/button-active.png");
124
 
  wipe (cr);
125
 
 
126
 
  pDashStyle->Button (cr, nux::VISUAL_STATE_PRELIGHT, "Record");
127
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/button-prelight.png");
128
 
  wipe (cr);
129
 
 
130
 
  //pDashStyle->Button (cr, nux::NUX_STATE_SELECTED, "Rewind");
131
 
  //cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/button-selected.png");
132
 
  //wipe (cr);
133
 
 
134
 
  //pDashStyle->Button (cr, nux::NUX_STATE_INSENSITIVE, "Forward");
135
 
  //cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/button-insensitive.png");
136
 
  //wipe (cr);
137
 
 
138
 
  pDashStyle->StarEmpty (cr, nux::VISUAL_STATE_NORMAL);
139
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/star-empty.png");
140
 
  wipe (cr);
141
 
 
142
 
  pDashStyle->StarHalf (cr, nux::VISUAL_STATE_NORMAL);
143
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/star-half.png");
144
 
  wipe (cr);
145
 
 
146
 
  pDashStyle->StarFull (cr, nux::VISUAL_STATE_NORMAL);
147
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/star-full.png");
148
 
  wipe (cr);
149
 
 
150
 
  pDashStyle->MultiRangeSegment (cr,
151
 
                                 nux::VISUAL_STATE_NORMAL,
152
 
                                 "100KB",
153
 
                                 unity::dash::Arrow::LEFT,
154
 
                                 unity::dash::Segment::LEFT);
155
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/multirange-left.png");
156
 
  wipe (cr);
157
 
 
158
 
  pDashStyle->MultiRangeSegment (cr,
159
 
                                 nux::VISUAL_STATE_PRESSED,
160
 
                                 "10GB",
161
 
                                 unity::dash::Arrow::LEFT,
162
 
                                 unity::dash::Segment::MIDDLE);
163
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/multirange-middle-left.png");
164
 
  wipe (cr);
165
 
 
166
 
  pDashStyle->MultiRangeSegment (cr,
167
 
                                 nux::VISUAL_STATE_PRESSED,
168
 
                                 "1MB",
169
 
                                 unity::dash::Arrow::BOTH,
170
 
                                 unity::dash::Segment::MIDDLE);
171
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/multirange-middle-both.png");
172
 
  wipe (cr);
173
 
 
174
 
  pDashStyle->MultiRangeSegment (cr,
175
 
                                 nux::VISUAL_STATE_PRESSED,
176
 
                                 "1TB",
177
 
                                 unity::dash::Arrow::RIGHT,
178
 
                                 unity::dash::Segment::MIDDLE);
179
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/multirange-middle-right.png");
180
 
  wipe (cr);
181
 
 
182
 
  pDashStyle->MultiRangeSegment (cr,
183
 
                                 nux::VISUAL_STATE_PRESSED,
184
 
                                 "100KB",
185
 
                                 unity::dash::Arrow::LEFT,
186
 
                                 unity::dash::Segment::RIGHT);
187
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/multirange-right.png");
188
 
  wipe (cr);
189
 
 
190
 
  pDashStyle->TrackViewNumber (cr, nux::VISUAL_STATE_NORMAL, "42");
191
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/track-view-number-normal.png");
192
 
  wipe (cr);
193
 
 
194
 
  pDashStyle->TrackViewPlay (cr, nux::VISUAL_STATE_NORMAL);
195
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/track-view-play-normal.png");
196
 
  wipe (cr);
197
 
 
198
 
  pDashStyle->TrackViewPause (cr, nux::VISUAL_STATE_NORMAL);
199
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/track-view-pause-normal.png");
200
 
  wipe (cr);
201
 
 
202
 
  pDashStyle->TrackViewProgress (cr);
203
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/track-view-progress.png");
204
 
  wipe (cr);
205
 
 
206
 
  pDashStyle->SeparatorVert (cr);
207
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/separator-vert.png");
208
 
  wipe (cr);
209
 
 
210
 
  pDashStyle->SeparatorHoriz (cr);
211
 
  cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/separator-horiz.png");
212
 
  wipe (cr);
213
 
 
214
 
  // clean up
215
 
  cairo_surface_destroy (surface);
216
 
  cairo_destroy (cr);
217
 
  delete pDashStyle;
218
 
 
219
 
  return 0;
220
 
}