298
294
AnnoScreen::draw (CompAction *action,
299
295
CompAction::State state,
300
CompOption::Vector& options)
296
CompOption::Vector &options)
298
cairo_t *cr = cairoContext ();
304
cr = cairoContext ();
308
unsigned short *fillColor, *strokeColor;
312
CompOption::getStringOptionNamed (options, "tool", "line").c_str ();
314
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
315
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
317
fillColor = optionGetFillColor ();
318
fillColor = CompOption::getColorOptionNamed (options, "fill_color",
321
strokeColor = optionGetStrokeColor ();
322
strokeColor = CompOption::getColorOptionNamed (options,
323
"stroke_color", strokeColor);
325
strokeWidth = optionGetStrokeWidth ();
326
strokeWidth = CompOption::getFloatOptionNamed (options, "stroke_width",
329
if (strcasecmp (tool, "rectangle") == 0)
333
x = CompOption::getFloatOptionNamed (options, "x", 0);
334
y = CompOption::getFloatOptionNamed (options, "y", 0);
335
w = CompOption::getFloatOptionNamed (options, "w", 100);
336
h = CompOption::getFloatOptionNamed (options, "h", 100);
303
unsigned short *fillColor, *strokeColor;
305
tool = CompOption::getStringOptionNamed (options, "tool", "line").c_str ();
307
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
308
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
310
fillColor = optionGetFillColor ();
311
fillColor = CompOption::getColorOptionNamed (options, "fill_color",
314
strokeColor = optionGetStrokeColor ();
315
strokeColor = CompOption::getColorOptionNamed (options,
316
"stroke_color", strokeColor);
318
double strokeWidth = optionGetStrokeWidth ();
319
strokeWidth = CompOption::getFloatOptionNamed (options, "stroke_width",
322
if (strcasecmp (tool, "rectangle") == 0)
324
double x = CompOption::getFloatOptionNamed (options, "x", 0);
325
double y = CompOption::getFloatOptionNamed (options, "y", 0);
326
double w = CompOption::getFloatOptionNamed (options, "w", 100);
327
double h = CompOption::getFloatOptionNamed (options, "h", 100);
338
329
drawRectangle (x, y, w, h, fillColor, strokeColor,
341
else if (strcasecmp (tool, "ellipse") == 0)
343
double xc, yc, xr, yr;
345
xc = CompOption::getFloatOptionNamed (options, "xc", 0);
346
yc = CompOption::getFloatOptionNamed (options, "yc", 0);
347
xr = CompOption::getFloatOptionNamed (options, "radiusX", 100);
348
yr = CompOption::getFloatOptionNamed (options, "radiusY", 100);
332
else if (strcasecmp (tool, "ellipse") == 0)
334
double xc = CompOption::getFloatOptionNamed (options, "xc", 0);
335
double yc = CompOption::getFloatOptionNamed (options, "yc", 0);
336
double xr = CompOption::getFloatOptionNamed (options, "radiusX", 100);
337
double yr = CompOption::getFloatOptionNamed (options, "radiusY", 100);
350
339
drawEllipse (xc, yc, xr, yr, fillColor, strokeColor,
353
else if (strcasecmp (tool, "line") == 0)
355
double x1, y1, x2, y2;
357
x1 = CompOption::getFloatOptionNamed (options, "x1", 0);
358
y1 = CompOption::getFloatOptionNamed (options, "y1", 0);
359
x2 = CompOption::getFloatOptionNamed (options, "x2", 100);
360
y2 = CompOption::getFloatOptionNamed (options, "y2", 100);
342
else if (strcasecmp (tool, "line") == 0)
344
double x1 = CompOption::getFloatOptionNamed (options, "x1", 0);
345
double y1 = CompOption::getFloatOptionNamed (options, "y1", 0);
346
double x2 = CompOption::getFloatOptionNamed (options, "x2", 100);
347
double y2 = CompOption::getFloatOptionNamed (options, "y2", 100);
362
349
drawLine (x1, y1, x2, y2, strokeWidth, fillColor);
364
else if (strcasecmp (tool, "text") == 0)
367
const char *text, *family;
368
cairo_font_slant_t slant;
351
else if (strcasecmp (tool, "text") == 0)
353
const char *text, *family;
354
cairo_font_slant_t slant;
369
355
cairo_font_weight_t weight;
373
CompOption::getStringOptionNamed (options, "slant", "").c_str ();
358
str = CompOption::getStringOptionNamed (options, "slant", "").c_str ();
374
360
if (strcasecmp (str, "oblique") == 0)
375
slant = CAIRO_FONT_SLANT_OBLIQUE;
361
slant = CAIRO_FONT_SLANT_OBLIQUE;
376
362
else if (strcasecmp (str, "italic") == 0)
377
slant = CAIRO_FONT_SLANT_ITALIC;
363
slant = CAIRO_FONT_SLANT_ITALIC;
379
slant = CAIRO_FONT_SLANT_NORMAL;
382
CompOption::getStringOptionNamed (options, "weight", "").c_str ();
365
slant = CAIRO_FONT_SLANT_NORMAL;
367
str = CompOption::getStringOptionNamed (options, "weight", "").c_str ();
383
369
if (strcasecmp (str, "bold") == 0)
384
weight = CAIRO_FONT_WEIGHT_BOLD;
370
weight = CAIRO_FONT_WEIGHT_BOLD;
386
weight = CAIRO_FONT_WEIGHT_NORMAL;
388
x = CompOption::getFloatOptionNamed (options, "x", 0);
389
y = CompOption::getFloatOptionNamed (options, "y", 0);
391
CompOption::getStringOptionNamed (options, "text", "").c_str ();
372
weight = CAIRO_FONT_WEIGHT_NORMAL;
374
double x = CompOption::getFloatOptionNamed (options, "x", 0);
375
double y = CompOption::getFloatOptionNamed (options, "y", 0);
377
text = CompOption::getStringOptionNamed (options, "text", "").c_str ();
392
379
family = CompOption::getStringOptionNamed (options, "family",
394
size = CompOption::getFloatOptionNamed (options, "size", 36.0);
382
double size = CompOption::getFloatOptionNamed (options, "size", 36.0);
396
384
drawText (x, y, text, family, size, slant, weight,
397
fillColor, strokeColor, strokeWidth);
385
fillColor, strokeColor, strokeWidth);
764
748
streamingBuffer->render (sTransform);
766
750
/* draw rectangle outline */
767
/* streamingBuffer->begin ();
751
vertexData[0] = rectangle.x1 ();
752
vertexData[1] = rectangle.y1 ();
753
vertexData[2] = 0.0f;
754
vertexData[3] = rectangle.x2 ();
755
vertexData[4] = rectangle.y1 ();
756
vertexData[5] = 0.0f;
757
vertexData[6] = rectangle.x2 ();
758
vertexData[7] = rectangle.y2 ();
759
vertexData[8] = 0.0f;
760
vertexData[9] = rectangle.x1 ();
761
vertexData[10] = rectangle.y2 ();
762
vertexData[11] = 0.0f;
764
glLineWidth (optionGetStrokeWidth ());
766
streamingBuffer->begin (GL_LINE_LOOP);
769
768
streamingBuffer->addColors (1, optionGetStrokeColor ());
771
vertexData[0] = rectangle.x1 () - offset;
772
vertexData[3] = rectangle.x1 () - offset;
773
769
streamingBuffer->addVertices (4, vertexData);
775
glRecti (rectangle.x2 () - offset, rectangle.y2 (),
776
rectangle.x2 () + offset, rectangle.y1 ());
777
glRecti (rectangle.x1 () - offset, rectangle.y1 () + offset,
778
rectangle.x2 () + offset, rectangle.y1 () - offset);
779
glRecti (rectangle.x1 () - offset, rectangle.y2 () + offset,
780
rectangle.x2 () + offset, rectangle.y2 () - offset);*/
771
streamingBuffer->end ();
772
streamingBuffer->render (sTransform);
783
776
case EllipseMode: