sodipodi-ctrl.cpp revision e7c94a7b49db8d5e89cd0fe8a3190b230c4655e2
#define INKSCAPE_CTRL_C
/*
* SPCtrl
*
* (non-aa) images
*
*/
#include "sp-canvas-util.h"
#include "display-forward.h"
#include "sodipodi-ctrl.h"
#include "libnr/nr-pixops.h"
#include "display/inkscape-cairo.h"
enum {
};
static SPCanvasItemClass *parent_class;
sp_ctrl_get_type (void)
{
if (!ctrl_type) {
sizeof (SPCtrlClass),
NULL, /* base_init */
NULL, /* base_finalize */
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (SPCtrl),
0, /* n_preallocs */
};
}
return ctrl_type;
}
static void
{
gtk_object_add_arg_type ("SPCtrl::stroke_color", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_STROKE_COLOR);
}
static void
{
}
static void
{
}
}
static void
{
switch (arg_id) {
case ARG_SHAPE:
break;
case ARG_MODE:
break;
case ARG_ANCHOR:
break;
case ARG_SIZE:
break;
case ARG_FILLED:
break;
case ARG_FILL_COLOR: {
// treat colors with zero alpha as opaque
} break;
case ARG_STROKED:
break;
case ARG_STROKE_COLOR: {
// treat colors with zero alpha as opaque
} break;
case ARG_PIXBUF:
if (gdk_pixbuf_get_has_alpha (pixbuf)) {
} else {
}
break;
default:
break;
}
}
static void
{
gint x, y;
sp_canvas_request_redraw (item->canvas, ctrl->box.x0, ctrl->box.y0, ctrl->box.x1 + 1, ctrl->box.y1 + 1);
}
if (!ctrl->defined) return;
case GTK_ANCHOR_N:
case GTK_ANCHOR_CENTER:
case GTK_ANCHOR_S:
break;
case GTK_ANCHOR_NW:
case GTK_ANCHOR_W:
case GTK_ANCHOR_SW:
break;
case GTK_ANCHOR_NE:
case GTK_ANCHOR_E:
case GTK_ANCHOR_SE:
break;
}
case GTK_ANCHOR_W:
case GTK_ANCHOR_CENTER:
case GTK_ANCHOR_E:
break;
case GTK_ANCHOR_NW:
case GTK_ANCHOR_N:
case GTK_ANCHOR_NE:
break;
case GTK_ANCHOR_SW:
case GTK_ANCHOR_S:
case GTK_ANCHOR_SE:
break;
}
}
static double
{
*actual_item = item;
double const x = p[Geom::X];
double const y = p[Geom::Y];
if ((x >= ctrl->box.x0) && (x <= ctrl->box.x1) && (y >= ctrl->box.y0) && (y <= ctrl->box.y1)) return 0.0;
return 1e18;
}
static void
{
//guchar * p, *q;
//int size, x, y, z, s, a, side, c;
//guint8 fr, fg, fb, fa, sr, sg, sb, sa;
/*if (ctrl->filled) {
fr = (ctrl->fill_color >> 24) & 0xff;
fg = (ctrl->fill_color >> 16) & 0xff;
fb = (ctrl->fill_color >> 8) & 0xff;
fa = (ctrl->fill_color) & 0xff;
} else {
fr = 0x00; fg = 0x00; fb = 0x00; fa = 0x00;
}
if (ctrl->stroked) {
sr = (ctrl->stroke_color >> 24) & 0xff;
sg = (ctrl->stroke_color >> 16) & 0xff;
sb = (ctrl->stroke_color >> 8) & 0xff;
sa = (ctrl->stroke_color) & 0xff;
} else {
sr = fr; sg = fg; sb = fb; sa = fa;
}*/
int w, h; // for clarity; w and h are always odd
}
bool supress_paint = false;
case SP_CTRL_SHAPE_SQUARE:
cairo_rectangle(cr, 0, 0, w, h);
break;
case SP_CTRL_SHAPE_DIAMOND:
cairo_line_to(cr, w, c);
cairo_line_to(cr, c, h);
cairo_line_to(cr, 0, c);
break;
case SP_CTRL_SHAPE_CIRCLE:
break;
case SP_CTRL_SHAPE_CROSS:
supress_paint = true;
break;
case SP_CTRL_SHAPE_BITMAP:
// TODO lame!!! find a way to do this without direct pixel manipulation.
// fix byte order. fill_color is 0xrrggbbaa, cairo needs 0xaarrggbb.
// both quantities are native-endian, so it should be portable.
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
} else {
}
}
}
supress_paint = true;
} else {
g_print ("control has no pixmap\n");
}
break;
case SP_CTRL_SHAPE_IMAGE:
supress_paint = true;
} else {
g_print ("control has no pixmap\n");
}
break;
default:
break;
}
}
}
}
}
// composite background, foreground, alpha for xor mode
#define COMPOSE_X(b,f,a) ( FAST_DIVIDE<255>( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) ((b ^ ~f) + b/4 - (b>127? 63 : 0))) * ((guchar) a) ) )
// composite background, foreground, alpha for color mode
#define COMPOSE_N(b,f,a) ( FAST_DIVIDE<255>( ((guchar) b) * ((guchar) (0xff - a)) + ((guchar) f) * ((guchar) a) ) )
static void
{
//gint y0, y1, y, x0,x1,x;
//guchar *p, *q, a;
if (!ctrl->defined) return;
// the control-image is rendered into ctrl->cache
}
/*
double x0 = ctrl->box.x0;
double y0 = ctrl->box.y0;
double w = ctrl->box.x1 - ctrl->box.x0 + 1;
double h = ctrl->box.y1 - ctrl->box.y0 + 1;
//guint32 fill = ctrl->fill_color;
//fill = (fill & 0xff == 0 && fill) ? fill | 0xff : fill;
switch (ctrl->shape) {
case SP_CTRL_SHAPE_SQUARE:
cairo_rectangle(buf->ct, x0, y0, w, h);
break;
case SP_CTRL_SHAPE_DIAMOND:
cairo_move_to(buf->ct, x0 + w/2, y0);
cairo_line_to(buf->ct, x0 + w, y0 + h/2);
cairo_line_to(buf->ct, x0 + w/2, y0 + h);
cairo_line_to(buf->ct, x0, y0 + h/2);
cairo_close_path(buf->ct);
break;
//case SP_CTRL_SHAPE_CIRCLE:
default:
cairo_arc(buf->ct, x0 + w/2, y0 + h/2, w/2, 0, 2*M_PI);
cairo_close_path(buf->ct);
break;
}
//if (ctrl->mode == SP_CTRL_MODE_XOR) {
// cairo_set_operator(buf->ct, CAIRO_OPERATOR_XOR);
//}
if (ctrl->filled) {
ink_cairo_set_source_rgba32(buf->ct, ctrl->fill_color);
cairo_fill_preserve(buf->ct);
}
if (ctrl->stroked) {
ink_cairo_set_source_rgba32(buf->ct, ctrl->stroke_color);
cairo_set_line_width(buf->ct, 2);
cairo_clip_preserve(buf->ct);
cairo_stroke_preserve(buf->ct);
}
cairo_new_path(buf->ct);
cairo_restore(buf->ct);*/
#if 0
// then we render from ctrl->cache
a = *(q + 3);
// 00000000 is the only way to get invisible; all other colors with alpha 00 are treated as mode_color with alpha ff
colormode = false;
if (a == 0x00 && !(q[0] == 0x00 && q[1] == 0x00 && q[2] == 0x00)) {
a = 0xff;
colormode = true;
}
p[0] = COMPOSE_N (p[0], q[0], a);
q += 4;
p += 4;
p[0] = COMPOSE_X (p[0], q[0], a);
q += 4;
p += 4;
}
}
}
#endif
}
if (p != _point) {
_moved = true;
}
_point = p;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :