212
120
nux::CairoGraphics* cairoGraphics = NULL;
213
121
cairo_t* cr = NULL;
214
122
nux::NBitmapData* bitmap = NULL;
215
double half_height = 0.0f;
217
// update texture of off-state of slider
218
width = m_SlideBar->GetBaseWidth ();
219
height = m_SlideBar->GetBaseHeight ();
220
cairoGraphics = new nux::CairoGraphics (CAIRO_FORMAT_ARGB32, width, height);
221
width -= 2 * BLUR_SIZE;
222
height -= 2 * BLUR_SIZE;
224
cr = cairoGraphics->GetContext ();
226
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
229
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
230
cairo_set_line_width (cr, 1.0f);
231
cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 0.75f);
232
cairoGraphics->DrawRoundedRectangle (cr,
236
(double) (width - 1) / 2.0f,
237
(double) width - 3.0f,
238
(double) height - 3.0f);
239
cairo_fill_preserve (cr);
240
cairoGraphics->BlurSurface (BLUR_SIZE - 3);
241
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
242
cairo_fill_preserve (cr);
243
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
244
cairo_set_source_rgba (cr, 0.125f, 0.125f, 0.125f, 0.75f);
245
cairo_fill_preserve (cr);
246
cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 0.5f);
249
cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 1.0f);
250
half_height = (double) (height + 2 * BLUR_SIZE) / 2.0f;
251
cairo_move_to (cr, BLUR_SIZE + 2.5f, half_height - 2.0f);
252
cairo_line_to (cr, BLUR_SIZE + 2.5f + 5.0f, half_height - 2.0f);
253
cairo_move_to (cr, BLUR_SIZE + 2.5f, half_height);
254
cairo_line_to (cr, BLUR_SIZE + 2.5f + 5.0f, half_height);
255
cairo_move_to (cr, BLUR_SIZE + 2.5f, half_height + 2.0f);
256
cairo_line_to (cr, BLUR_SIZE + 2.5f + 5.0f, half_height + 2.0f);
259
//cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/slider_off.png");
261
bitmap = cairoGraphics->GetBitmap ();
263
if (_slider[STATE_OFF])
264
_slider[STATE_OFF]->UnReference ();
266
_slider[STATE_OFF] = nux::GetThreadGLDeviceFactory()->CreateSystemCapableTexture ();
267
_slider[STATE_OFF]->Update (bitmap);
271
delete cairoGraphics;
273
// update texture of over-state of slider
274
width = m_SlideBar->GetBaseWidth ();
275
height = m_SlideBar->GetBaseHeight ();
276
cairoGraphics = new nux::CairoGraphics (CAIRO_FORMAT_ARGB32, width, height);
277
width -= 2 * BLUR_SIZE;
278
height -= 2 * BLUR_SIZE;
280
cr = cairoGraphics->GetContext ();
282
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
285
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
286
cairo_set_line_width (cr, 1.0f);
287
cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 0.25f);
288
cairoGraphics->DrawRoundedRectangle (cr,
292
(double) (width - 1) / 2.0f,
293
(double) width - 3.0f,
294
(double) height - 3.0f);
296
cairo_fill_preserve (cr);
297
cairoGraphics->BlurSurface (BLUR_SIZE - 3);
298
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
299
cairo_fill_preserve (cr);
300
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
302
cairo_surface_t* tmp_surf = NULL;
303
cairo_t* tmp_cr = NULL;
304
tmp_surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 6, 4);
305
tmp_cr = cairo_create (tmp_surf);
306
cairo_set_line_width (tmp_cr, 1.0f);
307
cairo_set_antialias (tmp_cr, CAIRO_ANTIALIAS_NONE);
308
cairo_set_operator (tmp_cr, CAIRO_OPERATOR_CLEAR);
309
cairo_paint (tmp_cr);
310
cairo_set_operator (tmp_cr, CAIRO_OPERATOR_OVER);
311
cairo_set_source_rgba (tmp_cr, 1.0f, 1.0f, 1.0f, 0.25f);
312
cairo_paint (tmp_cr);
313
cairo_set_source_rgba (tmp_cr, 1.0f, 1.0f, 1.0f, 0.5f);
314
cairo_rectangle (tmp_cr, 0.f, 0.f, 1.0f, 1.0f);
315
cairo_rectangle (tmp_cr, 1.f, 1.f, 1.0f, 1.0f);
316
cairo_rectangle (tmp_cr, 2.f, 2.f, 1.0f, 1.0f);
317
cairo_rectangle (tmp_cr, 3.f, 3.f, 1.0f, 1.0f);
318
cairo_rectangle (tmp_cr, 4.f, 0.f, 1.0f, 1.0f);
319
cairo_rectangle (tmp_cr, 5.f, 1.f, 1.0f, 1.0f);
321
cairo_destroy (tmp_cr);
322
cairo_set_source_surface (cr, tmp_surf, BLUR_SIZE + 1.5f, BLUR_SIZE + 1.5f);
323
cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT);
324
//cairo_surface_write_to_png (tmp_surf, "/tmp/tmp_surf.png");
326
cairo_fill_preserve (cr);
327
cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 0.5f);
330
cairo_set_source_rgba (cr, 1.0f, 1.0f, 1.0f, 1.0f);
331
cairo_move_to (cr, BLUR_SIZE + 2.5f, half_height - 2.0f);
332
cairo_line_to (cr, BLUR_SIZE + 2.5f + 5.0f, half_height - 2.0f);
333
cairo_move_to (cr, BLUR_SIZE + 2.5f, half_height);
334
cairo_line_to (cr, BLUR_SIZE + 2.5f + 5.0f, half_height);
335
cairo_move_to (cr, BLUR_SIZE + 2.5f, half_height + 2.0f);
336
cairo_line_to (cr, BLUR_SIZE + 2.5f + 5.0f, half_height + 2.0f);
339
//cairo_surface_write_to_png (cairo_get_target (cr), "/tmp/slider_over.png");
341
bitmap = cairoGraphics->GetBitmap ();
343
if (_slider[STATE_OVER])
344
_slider[STATE_OVER]->UnReference ();
346
_slider[STATE_OVER] = nux::GetThreadGLDeviceFactory()->CreateSystemCapableTexture ();
347
_slider[STATE_OVER]->Update (bitmap);
351
delete cairoGraphics;
353
// update texture of down-state of slider
124
// update texture of slider
354
125
width = m_SlideBar->GetBaseWidth ();
355
126
height = m_SlideBar->GetBaseHeight ();
356
127
cairoGraphics = new nux::CairoGraphics (CAIRO_FORMAT_ARGB32, width, height);