2
* Copyright (C) 2011 Canonical Ltd
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.
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.
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/>.
16
* Authored by: Mirco Müller <mirco.mueller@canonical.com
19
#include "DashStyle.h"
23
class DashStyleO : public dash::Style
29
bool ScrollbarVert (cairo_t* cr, nux::ButtonVisualState state);
30
bool TrackView (cairo_t* cr, nux::ButtonVisualState state);
33
class DashStyleP : public dash::Style
39
bool ScrollbarVert (cairo_t* cr, nux::ButtonVisualState state);
40
bool TrackView (cairo_t* cr, nux::ButtonVisualState state);
43
DashStyleO::DashStyleO ()
47
DashStyleO::~DashStyleO ()
51
bool DashStyleO::ScrollbarVert (cairo_t* cr, nux::ButtonVisualState state)
53
cairo_set_source_rgba (cr, 0.0, 1.0, 0.0, 1.0);
59
bool DashStyleO::TrackView (cairo_t* cr, nux::ButtonVisualState state)
61
cairo_set_source_rgba (cr, 0.0, 1.0, 1.0, 1.0);
67
DashStyleP::DashStyleP ()
71
DashStyleP::~DashStyleP ()
75
bool DashStyleP::ScrollbarVert (cairo_t* cr, nux::ButtonVisualState state)
77
cairo_set_source_rgba (cr, 1.0, 0.0, 0.0, 1.0);
83
bool DashStyleP::TrackView (cairo_t* cr, nux::ButtonVisualState state)
85
cairo_set_source_rgba (cr, 1.0, 1.0, 0.0, 1.0);
92
void wipe (cairo_t* cr)
95
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
98
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
100
cairo_scale (cr, 1.0, 1.0);
101
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
109
unity::DashStyleP* pDashStyle = new unity::DashStyleP ();
110
cairo_surface_t* surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
113
cairo_t* cr = cairo_create (surface);
115
cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/empty.png");
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");
122
pDashStyle->Button (cr, nux::VISUAL_STATE_PRESSED, "Pause");
123
cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/button-active.png");
126
pDashStyle->Button (cr, nux::VISUAL_STATE_PRELIGHT, "Record");
127
cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/button-prelight.png");
130
//pDashStyle->Button (cr, nux::NUX_STATE_SELECTED, "Rewind");
131
//cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/button-selected.png");
134
//pDashStyle->Button (cr, nux::NUX_STATE_INSENSITIVE, "Forward");
135
//cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/button-insensitive.png");
138
pDashStyle->StarEmpty (cr, nux::VISUAL_STATE_NORMAL);
139
cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/star-empty.png");
142
pDashStyle->StarHalf (cr, nux::VISUAL_STATE_NORMAL);
143
cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/star-half.png");
146
pDashStyle->StarFull (cr, nux::VISUAL_STATE_NORMAL);
147
cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/star-full.png");
150
pDashStyle->MultiRangeSegment (cr,
151
nux::VISUAL_STATE_NORMAL,
153
unity::dash::Arrow::LEFT,
154
unity::dash::Segment::LEFT);
155
cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/multirange-left.png");
158
pDashStyle->MultiRangeSegment (cr,
159
nux::VISUAL_STATE_PRESSED,
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");
166
pDashStyle->MultiRangeSegment (cr,
167
nux::VISUAL_STATE_PRESSED,
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");
174
pDashStyle->MultiRangeSegment (cr,
175
nux::VISUAL_STATE_PRESSED,
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");
182
pDashStyle->MultiRangeSegment (cr,
183
nux::VISUAL_STATE_PRESSED,
185
unity::dash::Arrow::LEFT,
186
unity::dash::Segment::RIGHT);
187
cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/multirange-right.png");
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");
194
pDashStyle->TrackViewPlay (cr, nux::VISUAL_STATE_NORMAL);
195
cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/track-view-play-normal.png");
198
pDashStyle->TrackViewPause (cr, nux::VISUAL_STATE_NORMAL);
199
cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/track-view-pause-normal.png");
202
pDashStyle->TrackViewProgress (cr);
203
cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/track-view-progress.png");
206
pDashStyle->SeparatorVert (cr);
207
cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/separator-vert.png");
210
pDashStyle->SeparatorHoriz (cr);
211
cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/separator-horiz.png");
215
cairo_surface_destroy (surface);