doodle-treeview.c \
tbo-tooltip.c \
text-tool.c \
- textobj.c \
export.c \
- svgimage.c \
- piximage.c \
dnd.c \
- tbo-object.c \
comic-load.c \
tbo-utils.c \
tbo-files.c \
doodle-tool.h \
doodle-treeview.h \
text-tool.h \
- svgimage.h \
- piximage.h \
- textobj.h \
tbo-tooltip.h \
dnd.h \
- tbo-object.h \
comic-load.h \
tbo-utils.h \
export.h \
#include "comic.h"
#include "page.h"
#include "frame.h"
-#include "tbo-object.h"
-#include "svgimage.h"
-#include "textobj.h"
-#include "piximage.h"
+#include "tbo-object-svg.h"
+#include "tbo-object-text.h"
+#include "tbo-object-pixmap.h"
#include "tbo-utils.h"
char *TITLE;
Comic *COMIC = NULL;
Page *CURRENT_PAGE;
Frame *CURRENT_FRAME;
-TextObj *CURRENT_TEXT = NULL;
+TboObjectText *CURRENT_TEXT = NULL;
struct attr {
char *name;
void
create_tbo_piximage (const gchar **attribute_names, const gchar **attribute_values)
{
- PIXImage *pix;
+ TboObjectPixmap *pix;
+ TboObjectBase *obj;
int x=0, y=0;
int width=0, height=0;
float angle=0.0;
parse_attrs (attrs, G_N_ELEMENTS (attrs), attribute_names, attribute_values);
- pix = tbo_piximage_new_with_params (x, y, width, height, path);
- pix->angle = angle;
- pix->flipv = flipv;
- pix->fliph = fliph;
- tbo_frame_add_obj (CURRENT_FRAME, pix);
+ pix = TBO_OBJECT_PIXMAP (tbo_object_pixmap_new_with_params (x, y, width, height, path));
+ obj = TBO_OBJECT_BASE (pix);
+ obj->angle = angle;
+ obj->flipv = flipv;
+ obj->fliph = fliph;
+ tbo_frame_add_obj (CURRENT_FRAME, obj);
}
void
create_tbo_svgimage (const gchar **attribute_names, const gchar **attribute_values)
{
- SVGImage *svg;
+ TboObjectSvg *svg;
+ TboObjectBase *obj;
int x=0, y=0;
int width=0, height=0;
float angle=0.0;
parse_attrs (attrs, G_N_ELEMENTS (attrs), attribute_names, attribute_values);
- svg = tbo_svgimage_new_with_params (x, y, width, height, path);
- svg->angle = angle;
- svg->flipv = flipv;
- svg->fliph = fliph;
- tbo_frame_add_obj (CURRENT_FRAME, svg);
+ svg = TBO_OBJECT_SVG (tbo_object_svg_new_with_params (x, y, width, height, path));
+ obj = TBO_OBJECT_BASE (svg);
+ obj->angle = angle;
+ obj->flipv = flipv;
+ obj->fliph = fliph;
+ tbo_frame_add_obj (CURRENT_FRAME, obj);
}
void
create_tbo_text (const gchar **attribute_names, const gchar **attribute_values)
{
- TextObj *textobj;
+ TboObjectText *textobj;
+ TboObjectBase *obj;
+ GdkColor color;
int x=0, y=0;
int width=0, height=0;
float angle=0.0;
{"b", "%f", &b},
};
+ color.red = (int)(r * COLORMAX);
+ color.green = (int)(g * COLORMAX);
+ color.blue = (int)(b * COLORMAX);
+
parse_attrs (attrs, G_N_ELEMENTS (attrs), attribute_names, attribute_values);
- textobj = tbo_text_new_with_params (x, y, width, height, "text", font, r, g, b);
- textobj->angle = angle;
- textobj->flipv = flipv;
- textobj->fliph = fliph;
+ textobj = TBO_OBJECT_TEXT (tbo_object_text_new_with_params (x, y, width, height, "text", font, &color));
+ obj = TBO_OBJECT_BASE (textobj);
+ obj->angle = angle;
+ obj->flipv = flipv;
+ obj->fliph = fliph;
CURRENT_TEXT = textobj;
- tbo_frame_add_obj (CURRENT_FRAME, textobj);
-
+ tbo_frame_add_obj (CURRENT_FRAME, obj);
}
/* The handler functions. */
void
start_element (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- gpointer user_data,
- GError **error) {
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ gpointer user_data,
+ GError **error)
+{
if (strcmp (element_name, "tbo") == 0)
{
if (CURRENT_TEXT)
{
char *text2 = g_strndup (text, text_len);
- tbo_text_set_text (CURRENT_TEXT, g_strstrip (text2));
+ tbo_object_text_set_text (CURRENT_TEXT, g_strstrip (text2));
g_free (text2);
}
}
void
end_element (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error)
+ const gchar *element_name,
+ gpointer user_data,
+ GError **error)
{
if (strcmp (element_name, "tbo") == 0)
{
#include "dnd.h"
#include "ui-drawing.h"
#include "frame.h"
-#include "svgimage.h"
+#include "tbo-object-svg.h"
#include "tbo-window.h"
static GtkWidget *DND_IMAGE = NULL;
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (tbo->dw_scroll));
int ry = tbo_frame_get_base_y ((y + gtk_adjustment_get_value(adj)) / zoom);
- SVGImage *svgimage = tbo_svgimage_new_with_params (rx, ry, 0, 0, _sdata);
+ TboObjectSvg *svgimage = TBO_OBJECT_SVG (tbo_object_svg_new_with_params (rx, ry, 0, 0, _sdata));
update_drawing (tbo);
- tbo_frame_add_obj (frame, svgimage);
+ tbo_frame_add_obj (frame, TBO_OBJECT_BASE (svgimage));
dnd_success = TRUE;
break;
#include <string.h>
#include <sys/stat.h>
#include <gtk/gtk.h>
-#include "svgimage.h"
+#include "tbo-object-svg.h"
#include "ui-drawing.h"
#include "frame.h"
#include "doodle-treeview.h"
gpointer *data)
{
Frame *frame = get_frame_view ();
- SVGImage *svgimage = tbo_svgimage_new_with_params (0, 0, 0, 0, (char*)data);
+ TboObjectSvg *svgimage = tbo_object_svg_new_with_params (0, 0, 0, 0, (char*)data);
+ tbo_frame_add_obj (frame, TBO_OBJECT_BASE (svgimage));
update_drawing (TBO);
- tbo_frame_add_obj (frame, svgimage);
}
void
#include <string.h>
#include "frame.h"
#include "tbo-types.h"
-#include "tbo-object.h"
+#include "tbo-object-base.h"
static int BASE_X = 0;
static int BASE_Y = 0;
free_objects (gpointer data,
gpointer user_data)
{
- tbo_object *obj = (tbo_object *)data;
- obj->free (obj);
+ TboObjectBase *obj = TBO_OBJECT_BASE (data);
+ g_object_unref (obj);
}
void
gpointer user_data)
{
void **pdata = user_data;
- tbo_object *obj = (tbo_object *)data;
+ TboObjectBase *obj = TBO_OBJECT_BASE (data);
cairo_t *cr = (cairo_t *)pdata[0];
Frame *frame = (Frame *)pdata[1];
obj->draw (obj, frame, cr);
}
int
-tbo_frame_point_inside_obj (tbo_object *obj, int x, int y)
+tbo_frame_point_inside_obj (TboObjectBase *obj, int x, int y)
{
int ox, oy, ow, oh;
}
void
-tbo_frame_get_obj_relative (tbo_object *obj, int *x, int *y, int *w, int *h)
+tbo_frame_get_obj_relative (TboObjectBase *obj, int *x, int *y, int *w, int *h)
{
*x = (BASE_X + obj->x) * SCALE_FACTOR;
*w = obj->width * SCALE_FACTOR;
}
void
-tbo_frame_add_obj (Frame *frame, tbo_object *obj)
+tbo_frame_add_obj (Frame *frame, TboObjectBase *obj)
{
frame->objects = g_list_append (frame->objects, obj);
}
}
void
-tbo_frame_del_obj (Frame *frame, tbo_object *obj)
+tbo_frame_del_obj (Frame *frame, TboObjectBase *obj)
{
frame->objects = g_list_remove (g_list_first (frame->objects), obj);
- obj->free (obj);
+ g_object_unref (obj);
}
void
{
char buffer[255];
GList *o;
+ TboObjectBase *obj;
snprintf (buffer, 255, " <frame x=\"%d\" y=\"%d\" width=\"%d\" "
"height=\"%d\" border=\"%d\" "
for (o=g_list_first (frame->objects); o; o = g_list_next(o))
{
- tbo_object_save ((tbo_object *) o->data, file);
+ obj = TBO_OBJECT_BASE (o->data);
+ obj->save (obj, file);
}
snprintf (buffer, 255, " </frame>\n");
tbo_frame_clone (Frame *frame)
{
GList *o;
- tbo_object *cur_object;
+ TboObjectBase *cur_object;
Frame *newframe = tbo_frame_new (frame->x, frame->y,
frame->width, frame->height);
for (o=g_list_first (frame->objects); o; o = g_list_next(o))
{
- cur_object = (tbo_object *) o->data;
+ cur_object = TBO_OBJECT_BASE (o->data);
tbo_frame_add_obj (newframe, cur_object->clone (cur_object));
}
newframe->border = frame->border;
#include <cairo.h>
#include <stdio.h>
#include "tbo-types.h"
+#include "tbo-object-base.h"
Frame *tbo_frame_new (int x, int y, int witdh, int heigth);
void tbo_frame_free (Frame *frame);
void tbo_frame_draw (Frame *frame, cairo_t *cr);
void tbo_frame_draw_scaled (Frame *frame, cairo_t *cr, int width, int height);
int tbo_frame_point_inside (Frame *frame, int x, int y);
-int tbo_frame_point_inside_obj (tbo_object *obj, int x, int y);
-void tbo_frame_add_obj (Frame *frame, tbo_object *obj);
-void tbo_frame_del_obj (Frame *frame, tbo_object *obj);
-void tbo_frame_get_obj_relative (tbo_object *obj, int *x, int *y, int *w, int *h);
+int tbo_frame_point_inside_obj (TboObjectBase *obj, int x, int y);
+void tbo_frame_add_obj (Frame *frame, TboObjectBase *obj);
+void tbo_frame_del_obj (Frame *frame, TboObjectBase *obj);
+void tbo_frame_get_obj_relative (TboObjectBase *obj, int *x, int *y, int *w, int *h);
float tbo_frame_get_scale_factor ();
int tbo_frame_get_base_y (int y);
int tbo_frame_get_base_x (int x);
+++ /dev/null
-/*
- * This file is part of TBO, a gnome comic editor
- * Copyright (C) 2010 Daniel Garcia Moreno <dani@danigm.net>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <cairo.h>
-#include "piximage.h"
-#include "tbo-types.h"
-
-#define DOODLE_DIR DATA_DIR "/doodle/"
-
-
-PIXImage *
-tbo_piximage_new ()
-{
- PIXImage *image;
- image = malloc (sizeof(PIXImage));
- image->data = malloc(sizeof(char)*255);
- image->free = tbo_pix_image_free;
- image->draw = tbo_pix_image_draw;
- image->save = tbo_pix_image_save;
- image->clone = tbo_pix_image_clone;
- image->angle = 0.0;
- image->type = PIXOBJ;
- image->flipv = FALSE;
- image->fliph = FALSE;
- return image;
-}
-
-PIXImage *
-tbo_piximage_new_with_params (int x,
- int y,
- int width,
- int height,
- const char *path)
-{
- PIXImage *image;
- image = tbo_piximage_new ();
- image->x = x;
- image->y = y;
- image->width = width;
- image->height = height;
- snprintf (image->data, 255, "%s", path);
- image->type = PIXOBJ;
- image->flipv = FALSE;
- image->fliph = FALSE;
- return image;
-}
-
-void
-tbo_pix_image_free (PIXImage *self)
-{
- free (self->data);
- free (self);
-}
-
-void
-tbo_pix_image_draw (PIXImage *self, Frame *frame, cairo_t *cr)
-{
- int w, h;
- cairo_surface_t *image;
-
- image = cairo_image_surface_create_from_png (self->data);
- w = cairo_image_surface_get_width (image);
- h = cairo_image_surface_get_height (image);
-
- if (!self->width) self->width = w;
- if (!self->height) self->height = h;
-
- float factorw = (float)self->width / (float)w;
- float factorh = (float)self->height / (float)h;
-
- cairo_matrix_t mx = {1, 0, 0, 1, 0, 0};
- tbo_object_get_flip_matrix (self, &mx);
-
- cairo_rectangle(cr, frame->x+2, frame->y+2, frame->width-4, frame->height-4);
- cairo_clip (cr);
- cairo_translate (cr, frame->x+self->x, frame->y+self->y);
- cairo_rotate (cr, self->angle);
- cairo_transform (cr, &mx);
- cairo_scale (cr, factorw, factorh);
-
- cairo_set_source_surface (cr, image, 0, 0);
- cairo_paint (cr);
-
- cairo_scale (cr, 1/factorw, 1/factorh);
- cairo_transform (cr, &mx);
- cairo_rotate (cr, -self->angle);
- cairo_translate (cr, -(frame->x+self->x), -(frame->y+self->y));
- cairo_reset_clip (cr);
-
-
- cairo_surface_destroy (image);
-}
-
-void
-tbo_pix_image_save (PIXImage *self, FILE *file)
-{
- char buffer[1024];
-
- snprintf (buffer, 1024, " <piximage x=\"%d\" y=\"%d\" "
- "width=\"%d\" height=\"%d\" "
- "angle=\"%f\" flipv=\"%d\" fliph=\"%d\" "
- "path=\"%s\">\n ",
- self->x, self->y, self->width, self->height,
- self->angle, self->flipv, self->fliph, (char*)self->data);
- fwrite (buffer, sizeof (char), strlen (buffer), file);
-
- snprintf (buffer, 1024, " </piximage>\n");
- fwrite (buffer, sizeof (char), strlen (buffer), file);
-}
-
-PIXImage *
-tbo_pix_image_clone (PIXImage *self)
-{
- PIXImage *newimage;
-
- newimage = tbo_piximage_new_with_params (self->x,
- self->y,
- self->width,
- self->height,
- self->data);
- newimage->angle = self->angle;
- newimage->flipv = self->flipv;
- newimage->fliph = self->fliph;
-
- return newimage;
-}
+++ /dev/null
-/*
- * This file is part of TBO, a gnome comic editor
- * Copyright (C) 2010 Daniel Garcia Moreno <dani@danigm.net>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef __TBO_PIX_IMAGE__
-#define __TBO_PIX_IMAGE__
-
-#include <cairo.h>
-#include <stdio.h>
-#include "tbo-types.h"
-
-typedef tbo_object PIXImage;
-
-PIXImage * tbo_piximage_new ();
-PIXImage * tbo_piximage_new_with_params (int x, int y, int width, int height, const char *path);
-void tbo_pix_image_free (PIXImage *self);
-void tbo_pix_image_draw (PIXImage *self, Frame *frame, cairo_t *cr);
-void tbo_pix_image_save (PIXImage *self, FILE *file);
-PIXImage * tbo_pix_image_clone (PIXImage *self);
-
-#endif
#include "selector-tool.h"
#include "tbo-window.h"
#include "tbo-types.h"
-#include "tbo-object.h"
+#include "tbo-object-base.h"
#include "page.h"
#include "frame.h"
#include "comic.h"
#define R_SIZE 10
static Frame *SELECTED = NULL;
-static tbo_object *OBJ = NULL;
+static TboObjectBase *OBJ = NULL;
static int START_X=0, START_Y=0;
static int START_M_X=0, START_M_Y=0;
static int START_M_W=0, START_M_H=0;
}
void
-set_selected_obj (tbo_object *obj, TboWindow *tbo)
+set_selected_obj (TboObjectBase *obj, TboWindow *tbo)
{
OBJ = obj;
update_menubar (tbo);
}
gboolean
-over_resizer_obj (tbo_object *obj, int x, int y)
+over_resizer_obj (TboObjectBase *obj, int x, int y)
{
int rx, ry;
int ox, oy, ow, oh;
}
gboolean
-over_rotater_obj (tbo_object *obj, int x, int y)
+over_rotater_obj (TboObjectBase *obj, int x, int y)
{
int rx, ry;
int ox, oy, ow, oh;
int x, y;
GList *obj_list;
Frame *frame;
- tbo_object *obj;
+ TboObjectBase *obj;
gboolean found = FALSE;
x = (int)event->x;
frame = get_frame_view ();
for (obj_list = g_list_first (frame->objects); obj_list; obj_list = obj_list->next)
{
- obj = (tbo_object *)obj_list->data;
+ obj = (TboObjectBase *)obj_list->data;
if (tbo_frame_point_inside_obj (obj, x, y))
{
// Selecting last occurrence.
set_selected_obj (NULL, tbo);
break;
case GDK_v:
- tbo_object_flipv (OBJ);
+ tbo_object_base_flipv (OBJ);
break;
case GDK_h:
- tbo_object_fliph (OBJ);
+ tbo_object_base_fliph (OBJ);
break;
case GDK_Page_Up:
- tbo_object_order_up (OBJ);
+ tbo_object_base_order_up (OBJ);
break;
case GDK_Page_Down:
- tbo_object_order_down (OBJ);
+ tbo_object_base_order_down (OBJ);
break;
case GDK_Up:
- tbo_object_move (OBJ, MOVE_UP);
+ tbo_object_base_move (OBJ, MOVE_UP);
break;
case GDK_less:
- tbo_object_resize (OBJ, RESIZE_LESS);
+ tbo_object_base_resize (OBJ, RESIZE_LESS);
break;
case GDK_greater:
- tbo_object_resize (OBJ, RESIZE_GREATER);
+ tbo_object_base_resize (OBJ, RESIZE_GREATER);
break;
case GDK_Down:
- tbo_object_move (OBJ, MOVE_DOWN);
+ tbo_object_base_move (OBJ, MOVE_DOWN);
break;
case GDK_Left:
- tbo_object_move (OBJ, MOVE_LEFT);
+ tbo_object_base_move (OBJ, MOVE_LEFT);
break;
case GDK_Right:
- tbo_object_move (OBJ, MOVE_RIGHT);
+ tbo_object_base_move (OBJ, MOVE_RIGHT);
break;
case GDK_d:
if (event->state & GDK_CONTROL_MASK)
{
- tbo_object *cloned_obj = OBJ->clone (OBJ);
+ TboObjectBase *cloned_obj = OBJ->clone (OBJ);
cloned_obj->x += 10;
cloned_obj->y -= 10;
tbo_frame_add_obj (SELECTED, cloned_obj);
}
-tbo_object *
+TboObjectBase *
selector_tool_get_selected_obj ()
{
return OBJ;
#include <gtk/gtk.h>
#include <cairo.h>
#include "tbo-window.h"
+#include "tbo-object-base.h"
void selector_tool_on_select (TboWindow *tbo);
void selector_tool_on_unselect (TboWindow *tbo);
void selector_tool_drawing (cairo_t *cr);
Frame *selector_tool_get_selected_frame ();
-tbo_object *selector_tool_get_selected_obj ();
+TboObjectBase *selector_tool_get_selected_obj ();
void frame_view_on_move (GtkWidget *widget, GdkEventMotion *event, TboWindow *tbo);
void page_view_on_move (GtkWidget *widget, GdkEventMotion *event, TboWindow *tbo);
void frame_view_on_click (GtkWidget *widget, GdkEventButton *event, TboWindow *tbo);
+++ /dev/null
-/*
- * This file is part of TBO, a gnome comic editor
- * Copyright (C) 2010 Daniel Garcia Moreno <dani@danigm.net>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <gtk/gtk.h>
-#include <glib/gi18n.h>
-#include <cairo.h>
-#include <librsvg/rsvg.h>
-#include <librsvg/rsvg-cairo.h>
-#include "svgimage.h"
-#include "tbo-types.h"
-#include "tbo-files.h"
-
-
-SVGImage *
-tbo_svgimage_new ()
-{
- SVGImage *image;
- image = malloc (sizeof(SVGImage));
- image->data = malloc(sizeof(char)*255);
- image->free = tbo_svg_image_free;
- image->draw = tbo_svg_image_draw;
- image->save = tbo_svg_image_save;
- image->clone = tbo_svg_image_clone;
- image->angle = 0.0;
- image->type = SVGOBJ;
- image->flipv = FALSE;
- image->fliph = FALSE;
- return image;
-}
-
-SVGImage *
-tbo_svgimage_new_with_params (int x,
- int y,
- int width,
- int height,
- const char *path)
-{
- SVGImage *image;
- image = tbo_svgimage_new ();
- image->x = x;
- image->y = y;
- image->width = width;
- image->height = height;
- snprintf (image->data, 255, "%s", path);
- image->type = SVGOBJ;
- image->flipv = FALSE;
- image->fliph = FALSE;
- return image;
-}
-
-void
-tbo_svg_image_free (SVGImage *self)
-{
- free (self->data);
- free (self);
-}
-
-void
-tbo_svg_image_draw (SVGImage *self, Frame *frame, cairo_t *cr)
-{
- GError *error = NULL;
- RsvgHandle *rsvg_handle = NULL;
- RsvgDimensionData rsvg_dimension_data;
- char path[255];
- tbo_files_expand_path (self->data, &path);
- rsvg_handle = rsvg_handle_new_from_file (path, &error);
- if (!rsvg_handle)
- {
- g_print (_("Couldn't load %s\n"), path);
- return;
- }
- if (error != NULL)
- {
- g_print ("%s\n", error->message);
- g_error_free (error);
- return;
- }
- else
- {
- rsvg_handle_get_dimensions (rsvg_handle, &rsvg_dimension_data);
- int w = rsvg_dimension_data.width;
- int h = rsvg_dimension_data.height;
- if (!self->width) self->width = w;
- if (!self->height) self->height = h;
-
- float factorw = (float)self->width / (float)w;
- float factorh = (float)self->height / (float)h;
-
- cairo_matrix_t mx = {1, 0, 0, 1, 0, 0};
- tbo_object_get_flip_matrix (self, &mx);
-
- cairo_rectangle(cr, frame->x+2, frame->y+2, frame->width-4, frame->height-4);
- cairo_clip (cr);
- cairo_translate (cr, frame->x+self->x, frame->y+self->y);
- cairo_rotate (cr, self->angle);
- cairo_transform (cr, &mx);
- cairo_scale (cr, factorw, factorh);
-
- rsvg_handle_render_cairo (rsvg_handle, cr);
-
- cairo_scale (cr, 1/factorw, 1/factorh);
- cairo_transform (cr, &mx);
- cairo_rotate (cr, -self->angle);
- cairo_translate (cr, -(frame->x+self->x), -(frame->y+self->y));
- cairo_reset_clip (cr);
-
- g_object_unref (rsvg_handle);
- }
-}
-
-void
-tbo_svg_image_save (SVGImage *self, FILE *file)
-{
- char buffer[1024];
-
- snprintf (buffer, 1024, " <svgimage x=\"%d\" y=\"%d\" "
- "width=\"%d\" height=\"%d\" "
- "angle=\"%f\" flipv=\"%d\" fliph=\"%d\" "
- "path=\"%s\">\n ",
- self->x, self->y, self->width, self->height,
- self->angle, self->flipv, self->fliph, (char*)self->data);
- fwrite (buffer, sizeof (char), strlen (buffer), file);
-
- snprintf (buffer, 1024, " </svgimage>\n");
- fwrite (buffer, sizeof (char), strlen (buffer), file);
-}
-
-SVGImage *
-tbo_svg_image_clone (SVGImage *self)
-{
- SVGImage *newimage;
-
- newimage = tbo_svgimage_new_with_params (self->x,
- self->y,
- self->width,
- self->height,
- self->data);
- newimage->angle = self->angle;
- newimage->flipv = self->flipv;
- newimage->fliph = self->fliph;
-
- return newimage;
-}
+++ /dev/null
-/*
- * This file is part of TBO, a gnome comic editor
- * Copyright (C) 2010 Daniel Garcia Moreno <dani@danigm.net>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef __TBO_SVG_IMAGE__
-#define __TBO_SVG_IMAGE__
-
-#include <cairo.h>
-#include <stdio.h>
-#include "tbo-types.h"
-
-typedef tbo_object SVGImage;
-
-SVGImage * tbo_svgimage_new ();
-SVGImage * tbo_svgimage_new_with_params (int x, int y, int width, int height, const char *path);
-void tbo_svg_image_free (SVGImage *self);
-void tbo_svg_image_draw (SVGImage *self, Frame *frame, cairo_t *cr);
-void tbo_svg_image_save (SVGImage *self, FILE *file);
-SVGImage * tbo_svg_image_clone (SVGImage *self);
-
-#endif
self->angle = 0.0;
self->flipv = FALSE;
self->fliph = FALSE;
+
+ self->draw = draw;
+ self->save = save;
+ self->clone = clone;
}
static void
tbo_object_base_class_init (TboObjectBaseClass *klass)
{
- klass->draw = draw;
- klass->save = save;
- klass->clone = clone;
}
/* object functions */
gdouble angle;
gboolean flipv;
gboolean fliph;
+
+ void (*draw) (TboObjectBase *, Frame *, cairo_t *);
+ void (*save) (TboObjectBase *, FILE *);
+ TboObjectBase * (*clone) (TboObjectBase *);
};
struct _TboObjectBaseClass
GObjectClass parent_class;
/* class members */
- void (*draw) (TboObjectBase *, Frame *, cairo_t *);
- void (*save) (TboObjectBase *, FILE *);
- TboObjectBase * (*clone) (TboObjectBase *);
};
/* used by TBO_TYPE_OBJECT_BASE */
float factorh = (float)self->height / (float)h;
cairo_matrix_t mx = {1, 0, 0, 1, 0, 0};
- tbo_object_get_flip_matrix (self, &mx);
+ tbo_object_base_get_flip_matrix (self, &mx);
cairo_rectangle(cr, frame->x+2, frame->y+2, frame->width-4, frame->height-4);
cairo_clip (cr);
tbo_object_pixmap_init (TboObjectPixmap *self)
{
self->path = NULL;
+
+ self->parent_instance.draw = draw;
+ self->parent_instance.save = save;
+ self->parent_instance.clone = clone;
}
static void
tbo_object_pixmap_class_init (TboObjectPixmapClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- TboObjectBaseClass *object_class = TBO_OBJECT_BASE_CLASS (klass);
- object_class->draw = draw;
- object_class->save = save;
- object_class->clone = clone;
-
gobject_class->finalize = tbo_object_pixmap_finalize;
}
tbo_object_svg_init (TboObjectSvg *self)
{
self->path = NULL;
+
+ self->parent_instance.draw = draw;
+ self->parent_instance.save = save;
+ self->parent_instance.clone = clone;
}
static void
tbo_object_svg_class_init (TboObjectSvgClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- TboObjectBaseClass *object_class = TBO_OBJECT_BASE_CLASS (klass);
- object_class->draw = draw;
- object_class->save = save;
- object_class->clone = clone;
-
gobject_class->finalize = tbo_object_svg_finalize;
}
#include "tbo-types.h"
#include "tbo-object-text.h"
-#define COLORMAX 65535
-
G_DEFINE_TYPE (TboObjectText, tbo_object_text, TBO_TYPE_OBJECT_BASE);
static void draw (TboObjectBase *, Frame *, cairo_t *);
self->text = NULL;
self->description = NULL;
self->font_color = NULL;
+
+ self->parent_instance.draw = draw;
+ self->parent_instance.save = save;
+ self->parent_instance.clone = clone;
}
static void
tbo_object_text_class_init (TboObjectTextClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- TboObjectBaseClass *object_class = TBO_OBJECT_BASE_CLASS (klass);
- object_class->draw = draw;
- object_class->save = save;
- object_class->clone = clone;
-
gobject_class->finalize = tbo_object_text_finalize;
}
self->font_color = gdk_color_copy (color);
}
-void
-tbo_object_text_get_color (TboObjectText *self, GdkColor *color)
-{
- color = self->font_color;
-}
-
gchar *
tbo_object_text_get_string (TboObjectText *self)
{
#define TBO_IS_OBJECT_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TBO_TYPE_OBJECT_TEXT))
#define TBO_OBJECT_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TBO_TYPE_OBJECT_TEXT, TboObjectTextClass))
+#define COLORMAX 65535
+
typedef struct _TboObjectText TboObjectText;
typedef struct _TboObjectTextClass TboObjectTextClass;
void tbo_object_text_set_text (TboObjectText *self, const gchar *text);
void tbo_object_text_change_font (TboObjectText *self, gchar *font);
void tbo_object_text_change_color (TboObjectText *self, GdkColor *color);
-void tbo_object_text_get_color (TboObjectText *self, GdkColor *color);
gchar * tbo_object_text_get_string (TboObjectText *self);
#endif /* __TBO_OBJECT_TEXT_H__ */
+++ /dev/null
-/*
- * This file is part of TBO, a gnome comic editor
- * Copyright (C) 2010 Daniel Garcia Moreno <dani@danigm.net>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include <gtk/gtk.h>
-#include <cairo.h>
-#include <stdio.h>
-#include "ui-drawing.h"
-#include "tbo-types.h"
-#include "tbo-object.h"
-#include "svgimage.h"
-#include "textobj.h"
-
-void
-tbo_object_flipv (tbo_object *self)
-{
- if (self->flipv)
- self->flipv = FALSE;
- else
- self->flipv = TRUE;
-}
-
-void
-tbo_object_fliph (tbo_object *self)
-{
- if (self->fliph)
- self->fliph = FALSE;
- else
- self->fliph = TRUE;
-}
-
-void
-tbo_object_get_flip_matrix (tbo_object *self, cairo_matrix_t *mx)
-{
- cairo_matrix_t flipv = {1, 0, 0, 1, 0, 0};
- cairo_matrix_t fliph = {1, 0, 0, 1, 0, 0};
-
- if (self->flipv)
- {
- cairo_matrix_init (&flipv, 1, 0, 0, -1, 0, self->height);
- }
- if (self->fliph)
- {
- cairo_matrix_init (&fliph, -1, 0, 0, 1, self->width, 0);
- }
-
- cairo_matrix_multiply (mx, &flipv, &fliph);
-}
-
-void
-tbo_object_order_down (tbo_object *self)
-{
- Frame *frame = get_frame_view ();
- GList *list = g_list_find (frame->objects, self);
- GList *prev = g_list_previous (list);
- tbo_object *tmp;
- if (prev)
- {
- tmp = (tbo_object*)list->data;
- list->data = prev->data;
- prev->data = tmp;
- }
-}
-
-void
-tbo_object_order_up (tbo_object *self)
-{
- Frame *frame = get_frame_view ();
- GList *list = g_list_find (frame->objects, self);
- GList *next = g_list_next (list);
- tbo_object *tmp;
- if (next)
- {
- tmp = (tbo_object*)list->data;
- list->data = next->data;
- next->data = tmp;
- }
-}
-
-void
-tbo_object_move (tbo_object *self, enum MOVE_OPT type)
-{
- switch (type)
- {
- case MOVE_UP:
- self->y -= MOVING_OFFSET;
- break;
- case MOVE_DOWN:
- self->y += MOVING_OFFSET;
- break;
- case MOVE_LEFT:
- self->x -= MOVING_OFFSET;
- break;
- case MOVE_RIGHT:
- self->x += MOVING_OFFSET;
- break;
- default:
- break;
- }
-}
-
-void
-tbo_object_resize (tbo_object *self, enum RESIZE_OPT type)
-{
- switch (type)
- {
- case RESIZE_LESS:
- if (self->width > 10 && self->height > 10)
- {
- self->width *= 0.95;
- self->height *= 0.95;
- }
- break;
- case RESIZE_GREATER:
- self->width *= 1.05;
- self->height *= 1.05;
- break;
- default:
- break;
- }
-}
-
-void
-tbo_object_save (tbo_object *self, FILE *file)
-{
- self->save (self, file);
-}
+++ /dev/null
-/*
- * This file is part of TBO, a gnome comic editor
- * Copyright (C) 2010 Daniel Garcia Moreno <dani@danigm.net>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include <gtk/gtk.h>
-#include <cairo.h>
-#include <stdio.h>
-#include "tbo-types.h"
-
-enum MOVE_OPT
-{
- MOVE_UP,
- MOVE_DOWN,
- MOVE_LEFT,
- MOVE_RIGHT,
-};
-
-enum RESIZE_OPT
-{
- RESIZE_LESS,
- RESIZE_GREATER,
-};
-
-static int MOVING_OFFSET = 10;
-
-void tbo_object_flipv (tbo_object *self);
-void tbo_object_fliph (tbo_object *self);
-void tbo_object_get_flip_matrix (tbo_object *self, cairo_matrix_t *mx);
-void tbo_object_order_down (tbo_object *self);
-void tbo_object_order_up (tbo_object *self);
-void tbo_object_move (tbo_object *self, enum MOVE_OPT type);
-void tbo_object_resize (tbo_object *self, enum RESIZE_OPT type);
-void tbo_object_save (tbo_object *self, FILE *file);
} Frame;
-enum TYPE
-{
- SVGOBJ,
- PIXOBJ,
- TEXTOBJ,
-};
-
-struct tbo_object
-{
- int x;
- int y;
- int width;
- int height;
- double angle;
- gboolean flipv;
- gboolean fliph;
- void (*free) (struct tbo_object *);
- void (*draw) (struct tbo_object *, Frame *, cairo_t *);
- void (*save) (struct tbo_object *, FILE *);
- struct tbo_object * (*clone) (struct tbo_object *);
- enum TYPE type;
- gpointer data;
-};
-
-typedef struct tbo_object tbo_object;
-
#endif
tbo = tbo_new_tbo (800, 450);
if (argc == 2)
tbo_comic_open (tbo, argv[1]);
+
gtk_main ();
return 0;
#include <glib/gi18n.h>
#include <cairo.h>
#include "tbo-window.h"
-#include "textobj.h"
+#include "tbo-object-text.h"
#include "text-tool.h"
#include "frame.h"
#include "ui-drawing.h"
static GtkWidget *FONT = NULL;
static GtkWidget *FONT_COLOR = NULL;
-static TextObj *TEXT_SELECTED = NULL;
+static TboObjectText *TEXT_SELECTED = NULL;
static GtkTextBuffer *TEXT_BUFFER = NULL;
gboolean
if (TEXT_SELECTED)
{
- tbo_text_set_text (TEXT_SELECTED, gtk_text_buffer_get_text (buf, &start, &end, FALSE));
+ tbo_object_text_set_text (TEXT_SELECTED, gtk_text_buffer_get_text (buf, &start, &end, FALSE));
update_drawing (tbo);
}
return FALSE;
{
if (TEXT_SELECTED)
{
- tbo_text_change_font (TEXT_SELECTED, text_tool_get_pango_font ());
+ tbo_object_text_change_font (TEXT_SELECTED, text_tool_get_pango_font ());
update_drawing (tbo);
}
return FALSE;
{
if (TEXT_SELECTED)
{
- double r, g, b;
- text_tool_get_color (&r, &g, &b);
- tbo_text_change_color (TEXT_SELECTED, r, g, b);
+ GdkColor color;
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (FONT_COLOR), &color);
+ tbo_object_text_change_color (TEXT_SELECTED, &color);
update_drawing (tbo);
}
return FALSE;
int y = (int)event->y;
gboolean found = FALSE;
GList *obj_list;
- tbo_object * obj;
- TextObj *text;
+ TboObjectBase *obj;
+ TboObjectText *text;
+ GdkColor color;
for (obj_list = g_list_first (frame->objects); obj_list; obj_list = obj_list->next)
{
- obj = (tbo_object *)obj_list->data;
- if (obj->type == TEXTOBJ && tbo_frame_point_inside_obj (obj, x, y))
+ obj = TBO_OBJECT_BASE (obj_list->data);
+ if (TBO_IS_OBJECT_TEXT (obj) && tbo_frame_point_inside_obj (obj, x, y))
{
- text = (TextObj *)obj;
+ text = TBO_OBJECT_TEXT (obj);
found = TRUE;
}
}
{
x = tbo_frame_get_base_x (x);
y = tbo_frame_get_base_y (y);
- text_tool_get_color (&r, &g, &b);
- text = tbo_text_new_with_params (x, y, 100, 0,
- _("Texto"),
- (char *)text_tool_get_pango_font (),
- r, g, b);
- tbo_frame_add_obj (frame, text);
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (FONT_COLOR), &color);
+ text = TBO_OBJECT_TEXT (tbo_object_text_new_with_params (x, y, 100, 0,
+ _("Text"),
+ (gchar *)text_tool_get_pango_font (),
+ &color));
+ tbo_frame_add_obj (frame, TBO_OBJECT_BASE (text));
}
text_tool_set_selected (text);
update_drawing (tbo);
if (TEXT_SELECTED)
{
- tbo_object *OBJ = TEXT_SELECTED;
+ TboObjectBase *OBJ = TBO_OBJECT_BASE (TEXT_SELECTED);
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
cairo_set_line_width (cr, 1);
cairo_set_dash (cr, dashes, G_N_ELEMENTS (dashes), 0);
}
void
-text_tool_get_color (double *r, double *g, double *b)
+text_tool_set_selected (TboObjectText *text)
{
- GdkColor color;
- gtk_color_button_get_color (GTK_COLOR_BUTTON (FONT_COLOR), &color);
- *r = color.red / 65535.0;
- *g = color.green / 65535.0;
- *b = color.blue / 65535.0;
-}
-
-void
-text_tool_set_selected (TextObj *text)
-{
- GdkColor color;
- char *str = tbo_text_get_text (text);
+ char *str = tbo_object_text_get_text (text);
TEXT_SELECTED = NULL;
- gtk_font_button_set_font_name (GTK_FONT_BUTTON (FONT), tbo_text_get_string (text));
- tbo_text_get_color (text, &color);
- gtk_color_button_set_color (GTK_COLOR_BUTTON (FONT_COLOR), &color);
+ gtk_font_button_set_font_name (GTK_FONT_BUTTON (FONT), tbo_object_text_get_string (text));
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (FONT_COLOR), text->font_color);
gtk_text_buffer_set_text (TEXT_BUFFER, str, -1);
TEXT_SELECTED = text;
}
#include <gtk/gtk.h>
#include <cairo.h>
-#include "textobj.h"
+#include "tbo-object-text.h"
#include "tbo-window.h"
void text_tool_on_select (TboWindow *tbo);
void text_tool_drawing (cairo_t *cr);
char * text_tool_get_pango_font ();
const gchar * text_tool_get_font_name ();
-void text_tool_get_color (double *r, double *g, double *b);
-void text_tool_set_selected (TextObj *text);
+void text_tool_set_selected (TboObjectText *text);
#endif
+++ /dev/null
-/*
- * This file is part of TBO, a gnome comic editor
- * Copyright (C) 2010 Daniel Garcia Moreno <dani@danigm.net>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#include <stdlib.h>
-#include <string.h>
-#include <gtk/gtk.h>
-#include <cairo.h>
-#include "textobj.h"
-#include "text-tool.h"
-#include "tbo-types.h"
-
-typedef struct
-{
- GString *text;
- PangoFontDescription *description;
- Color *font_color;
-} text_data;
-
-text_data *
-text_data_new (const char *text, char *font, double r, double g, double b)
-{
- text_data *txt = malloc (sizeof (text_data));
- txt->text = g_string_new (text);
- Color *color = malloc (sizeof (Color));
- color->r = r;
- color->g = g;
- color->b = b;
- txt->font_color = color;
- txt->description = pango_font_description_from_string (font);
-
- return txt;
-}
-
-void
-text_data_free (text_data *txt)
-{
- free (txt->font_color);
- g_string_free (txt->text, TRUE);
- pango_font_description_free (txt->description);
- free (txt);
-}
-
-void
-tbo_text_change_font (TextObj *self, char *font)
-{
- text_data *txt = (text_data*)self->data;
- pango_font_description_free (txt->description);
- txt->description = pango_font_description_from_string (font);
-}
-
-void
-tbo_text_change_color (TextObj *self, double r, double g, double b)
-{
- text_data *txt = (text_data*)self->data;
- txt->font_color->r = r;
- txt->font_color->g = g;
- txt->font_color->b = b;
-}
-
-TextObj *
-tbo_text_new ()
-{
- TextObj *text;
- text = malloc (sizeof(TextObj));
- text->data = text_data_new ("text", "Sans Normal 27", 0, 0, 0);
- text->free = tbo_text_free;
- text->draw = tbo_text_draw;
- text->save = tbo_text_save;
- text->clone = tbo_text_clone;
- text->angle = 0.0;
- text->type = TEXTOBJ;
- text->flipv = FALSE;
- text->fliph = FALSE;
- return text;
-}
-
-TextObj *
-tbo_text_new_with_params (int x,
- int y,
- int width,
- int height,
- const char *text,
- char *font,
- double r, double g, double b)
-{
- TextObj *textobj;
- textobj = tbo_text_new ();
- textobj->x = x;
- textobj->y = y;
- textobj->width = width;
- textobj->height = height;
- textobj->data = text_data_new (text, font, r, g, b);
- textobj->type = TEXTOBJ;
- textobj->flipv = FALSE;
- textobj->fliph = FALSE;
- return textobj;
-}
-
-void
-tbo_text_free (TextObj *self)
-{
- text_data_free (self->data);
- free (self);
-}
-
-void
-tbo_text_draw (TextObj *self, Frame *frame, cairo_t *cr)
-{
- text_data *data = self->data;
- gchar *text = data->text->str;
-
- PangoLayout *layout;
- PangoFontDescription *desc = data->description;
-
- int w;
- int h;
-
- cairo_set_source_rgb(cr, data->font_color->r, data->font_color->g, data->font_color->b);
-
- layout = pango_cairo_create_layout (cr);
- pango_layout_set_text (layout, text, -1);
- pango_layout_set_font_description (layout, desc);
- pango_layout_get_size (layout, &w, &h);
- pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
- w = (double)w / PANGO_SCALE;
- h = (double)h / PANGO_SCALE;
-
- if (!self->width) self->width = w;
- if (!self->height) self->height = h;
-
- float factorw = (float)self->width / (float)w;
- float factorh = (float)self->height / (float)h;
- if (factorh == 1)
- {
- factorh = factorw;
- self->height = self->height * factorw;
- }
-
- cairo_matrix_t mx = {1, 0, 0, 1, 0, 0};
- tbo_object_get_flip_matrix (self, &mx);
-
- cairo_rectangle(cr, frame->x+2, frame->y+2, frame->width-4, frame->height-4);
- cairo_clip (cr);
- cairo_translate (cr, frame->x+self->x, frame->y+self->y);
- cairo_rotate (cr, self->angle);
- cairo_transform (cr, &mx);
- cairo_scale (cr, factorw, factorh);
-
- pango_cairo_show_layout (cr, layout);
-
- cairo_scale (cr, 1/factorw, 1/factorh);
- cairo_transform (cr, &mx);
- cairo_rotate (cr, -self->angle);
- cairo_translate (cr, -(frame->x+self->x), -(frame->y+self->y));
- cairo_reset_clip (cr);
-}
-
-char *
-tbo_text_get_text (TextObj *self)
-{
- return ((text_data *)self->data)->text->str;
-}
-
-void
-tbo_text_set_text (TextObj *self, const char *text)
-{
- g_string_assign (((text_data *)self->data)->text, text);
- self->height = 0;
-}
-
-void
-tbo_text_get_color (TextObj *self, GdkColor *color)
-{
- text_data *data = (text_data*)self->data;
- color->red = data->font_color->r * 65535;
- color->green = data->font_color->g * 65535;
- color->blue = data->font_color->b * 65535;
-}
-
-char *
-tbo_text_get_string (TextObj *self)
-{
- text_data *data = (text_data *)self->data;
- return pango_font_description_to_string (data->description);
-}
-
-void
-tbo_text_save (TextObj *self, FILE *file)
-{
- char buffer[1024];
-
- text_data *data = (text_data*)self->data;
- snprintf (buffer, 1024, " <text x=\"%d\" y=\"%d\" "
- "width=\"%d\" height=\"%d\" "
- "angle=\"%f\" flipv=\"%d\" fliph=\"%d\" "
- "font=\"%s\" "
- "r=\"%f\" g=\"%f\" b=\"%f\">\n",
- self->x, self->y, self->width, self->height,
- self->angle, self->flipv, self->fliph,
- pango_font_description_to_string (data->description),
- data->font_color->r, data->font_color->g,
- data->font_color->b);
- fwrite (buffer, sizeof (char), strlen (buffer), file);
-
- snprintf (buffer, 1024, "%s", g_markup_escape_text (data->text->str, strlen (data->text->str)));
- fwrite (buffer, sizeof (char), strlen (buffer), file);
-
- snprintf (buffer, 1024, "\n </text>\n");
- fwrite (buffer, sizeof (char), strlen (buffer), file);
-}
-
-TextObj *
-tbo_text_clone (TextObj *self)
-{
- TextObj *newtext;
- text_data *data;
- data = (text_data*)self->data;
-
- newtext = tbo_text_new ();
- newtext->flipv = self->flipv;
- newtext->fliph = self->fliph;
- tbo_text_change_color (newtext, data->font_color->r,
- data->font_color->g,
- data->font_color->b);
- tbo_text_change_font (newtext, tbo_text_get_string (self));
- tbo_text_set_text (newtext, data->text->str);
- newtext->angle = self->angle;
- newtext->x = self->x;
- newtext->y = self->y;
- newtext->width = self->width;
- newtext->height = self->height;
-
- return newtext;
-}
+++ /dev/null
-/*
- * This file is part of TBO, a gnome comic editor
- * Copyright (C) 2010 Daniel Garcia Moreno <dani@danigm.net>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-
-#ifndef __TBO_TEXT_OBJ__
-#define __TBO_TEXT_OBJ__
-
-#include <cairo.h>
-#include <stdio.h>
-#include "tbo-types.h"
-
-typedef tbo_object TextObj;
-
-TextObj * tbo_text_new ();
-TextObj * tbo_text_new_with_params (int x, int y, int width, int height, const char *text, char *font_name, double r, double g, double b);
-void tbo_text_free (TextObj *self);
-void tbo_text_draw (TextObj *self, Frame *frame, cairo_t *cr);
-char *tbo_text_get_text (TextObj *self);
-void tbo_text_set_text (TextObj *self, const char *text);
-void tbo_text_change_font (TextObj *self, char *font);
-void tbo_text_change_color (TextObj *self, double r, double g, double b);
-void tbo_text_get_color (TextObj *self, GdkColor *color);
-char * tbo_text_get_string (TextObj *self);
-void tbo_text_save (TextObj *self, FILE *file);
-TextObj * tbo_text_clone (TextObj *self);
-
-#endif
#include "comic.h"
#include "frame.h"
#include "page.h"
+#include "tbo-object-base.h"
static GtkActionGroup *MENU_ACTION_GROUP = NULL;
int obj_n_elements = 4;
gboolean activated = FALSE;
- tbo_object *obj = selector_tool_get_selected_obj ();
+ TboObjectBase *obj = selector_tool_get_selected_obj ();
Frame *frame = selector_tool_get_selected_frame ();
if (!MENU_ACTION_GROUP)
gboolean
clone_obj_cb (GtkWidget *widget, gpointer data)
{
- tbo_object *obj = selector_tool_get_selected_obj ();
+ TboObjectBase *obj = selector_tool_get_selected_obj ();
Frame *frame = selector_tool_get_selected_frame ();
Page *page = tbo_comic_get_current_page (((TboWindow*)data)->comic);
}
else if (obj && get_frame_view ())
{
- tbo_object *cloned_obj = obj->clone (obj);
+ TboObjectBase *cloned_obj = obj->clone (obj);
cloned_obj->x += 10;
cloned_obj->y -= 10;
tbo_frame_add_obj (frame, cloned_obj);
{
TboWindow *tbo = (TboWindow *)data;
- tbo_object *obj = selector_tool_get_selected_obj ();
+ TboObjectBase *obj = selector_tool_get_selected_obj ();
Frame *frame = selector_tool_get_selected_frame ();
Page *page = tbo_comic_get_current_page (((TboWindow*)data)->comic);
gboolean
flip_v_cb (GtkWidget *widget, gpointer data)
{
- tbo_object *obj = selector_tool_get_selected_obj ();
+ TboObjectBase *obj = selector_tool_get_selected_obj ();
if (obj)
- tbo_object_flipv (obj);
+ tbo_object_base_flipv (obj);
update_drawing ((TboWindow *)data);
return FALSE;
}
gboolean
flip_h_cb (GtkWidget *widget, gpointer data)
{
- tbo_object *obj = selector_tool_get_selected_obj ();
+ TboObjectBase *obj = selector_tool_get_selected_obj ();
if (obj)
- tbo_object_fliph (obj);
+ tbo_object_base_fliph (obj);
update_drawing ((TboWindow *)data);
return FALSE;
}
gboolean
order_up_cb (GtkWidget *widget, gpointer data)
{
- tbo_object *obj = selector_tool_get_selected_obj ();
+ TboObjectBase *obj = selector_tool_get_selected_obj ();
if (obj)
- tbo_object_order_up (obj);
+ tbo_object_base_order_up (obj);
update_drawing ((TboWindow *)data);
return FALSE;
}
gboolean
order_down_cb (GtkWidget *widget, gpointer data)
{
- tbo_object *obj = selector_tool_get_selected_obj ();
+ TboObjectBase *obj = selector_tool_get_selected_obj ();
if (obj)
- tbo_object_order_down (obj);
+ tbo_object_base_order_down (obj);
update_drawing ((TboWindow *)data);
return FALSE;
}
#include "selector-tool.h"
#include "doodle-tool.h"
#include "text-tool.h"
-#include "piximage.h"
+#include "tbo-object-pixmap.h"
static int SELECTED_TOOL = NONE;
static GtkActionGroup *ACTION_GROUP = NULL;
{
char *filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- PIXImage *piximage = tbo_piximage_new_with_params (0, 0, 0, 0, filename);
- tbo_frame_add_obj (get_frame_view(), piximage);
+ TboObjectPixmap *piximage = TBO_OBJECT_PIXMAP (tbo_object_pixmap_new_with_params (0, 0, 0, 0, filename));
+ tbo_frame_add_obj (get_frame_view(), TBO_OBJECT_BASE (piximage));
update_drawing (tbo);
g_free (filename);
}