aboutsummaryrefslogtreecommitdiff
path: root/libstorycode
diff options
context:
space:
mode:
Diffstat (limited to 'libstorycode')
-rw-r--r--libstorycode/gtk/gtkslideview.c47
-rw-r--r--libstorycode/slide.c18
-rw-r--r--libstorycode/slide.h8
3 files changed, 45 insertions, 28 deletions
diff --git a/libstorycode/gtk/gtkslideview.c b/libstorycode/gtk/gtkslideview.c
index e9abfb5..1e2a952 100644
--- a/libstorycode/gtk/gtkslideview.c
+++ b/libstorycode/gtk/gtkslideview.c
@@ -809,13 +809,31 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, GtkSlideView *e
}
+static SlideItem *create_frame(GtkSlideView *e, double cx, double cy,
+ double w, double h)
+{
+ struct frame_geom geom;
+ char *text;
+
+ text = strdup("");
+ if ( text == NULL ) return NULL;
+
+ geom.x.len = cx; geom.x.unit = LENGTH_UNIT;
+ geom.y.len = cy; geom.y.unit = LENGTH_UNIT;
+ geom.w.len = w; geom.w.unit = LENGTH_UNIT;
+ geom.h.len = h; geom.h.unit = LENGTH_UNIT;
+ return slide_add_text(e->slide, &text, 1, geom, ALIGN_INHERIT);
+}
+
+
static gboolean button_release_sig(GtkWidget *da, GdkEventButton *event,
GtkSlideView *e)
{
gdouble x, y;
+ SlideItem *fr;
- x = event->x + e->h_scroll_pos;
- y = event->y + e->v_scroll_pos;
+ x = event->x - e->border_offs_x + e->h_scroll_pos;
+ y = event->y - e->border_offs_y + e->v_scroll_pos;
x /= e->view_scale;
y /= e->view_scale;
@@ -834,19 +852,18 @@ static gboolean button_release_sig(GtkWidget *da, GdkEventButton *event,
break;
case DRAG_REASON_CREATE :
- //fr = create_frame(e, e->start_corner_x, e->start_corner_y,
- // e->drag_corner_x - e->start_corner_x,
- // e->drag_corner_y - e->start_corner_y);
- //if ( fr != NULL ) {
- // check_paragraph(fr, e->pc, sc_block_child(fr->scblocks));
- // e->selection = fr;
- // e->cursor_frame = fr;
- // e->cpos.para = 0;
- // e->cpos.pos = 0;
- // e->cpos.trail = 0;
- //} else {
- // fprintf(stderr, _("Failed to create frame!\n"));
- //}
+ fr = create_frame(e, e->start_corner_x, e->start_corner_y,
+ e->drag_corner_x - e->start_corner_x,
+ e->drag_corner_y - e->start_corner_y);
+ if ( fr != NULL ) {
+ e->cursor_frame = fr;
+ e->cpos.para = 0;
+ e->cpos.pos = 0;
+ e->cpos.trail = 0;
+ unset_selection(e);
+ } else {
+ fprintf(stderr, _("Failed to create frame!\n"));
+ }
break;
case DRAG_REASON_IMPORT :
diff --git a/libstorycode/slide.c b/libstorycode/slide.c
index a3dfcc7..075a237 100644
--- a/libstorycode/slide.c
+++ b/libstorycode/slide.c
@@ -89,20 +89,20 @@ int slide_add_image(Slide *s, char *filename, struct frame_geom geom)
}
-int add_text_item(Slide *s, char **text, int n_text, struct frame_geom geom,
- enum alignment alignment, enum slide_item_type slide_item)
+static SlideItem *add_text_item(Slide *s, char **text, int n_text, struct frame_geom geom,
+ enum alignment alignment, enum slide_item_type slide_item)
{
int i;
SlideItem *item;
item = add_item(s);
- if ( item == NULL ) return 1;
+ if ( item == NULL ) return NULL;
item->type = slide_item;
item->paras = malloc(n_text*sizeof(struct slide_text_paragraph));
if ( item->paras == NULL ) {
s->n_items--;
- return 1;
+ return NULL;
}
for ( i=0; i<n_text; i++ ) {
@@ -121,7 +121,7 @@ int add_text_item(Slide *s, char **text, int n_text, struct frame_geom geom,
item->resizable = 0;
}
- return 0;
+ return item;
}
@@ -138,15 +138,15 @@ int slide_add_footer(Slide *s)
}
-int slide_add_text(Slide *s, char **text, int n_text, struct frame_geom geom,
- enum alignment alignment)
+SlideItem *slide_add_text(Slide *s, char **text, int n_text, struct frame_geom geom,
+ enum alignment alignment)
{
return add_text_item(s, text, n_text, geom, alignment,
SLIDE_ITEM_TEXT);
}
-int slide_add_slidetitle(Slide *s, char **text, int n_text)
+SlideItem *slide_add_slidetitle(Slide *s, char **text, int n_text)
{
struct frame_geom geom;
@@ -165,7 +165,7 @@ int slide_add_slidetitle(Slide *s, char **text, int n_text)
}
-int slide_add_prestitle(Slide *s, char **text, int n_text)
+SlideItem *slide_add_prestitle(Slide *s, char **text, int n_text)
{
struct frame_geom geom;
diff --git a/libstorycode/slide.h b/libstorycode/slide.h
index 9d114fb..23406fa 100644
--- a/libstorycode/slide.h
+++ b/libstorycode/slide.h
@@ -36,11 +36,11 @@ extern Slide *slide_new(void);
extern void slide_free(Slide *s);
extern int slide_add_image(Slide *s, char *filename, struct frame_geom geom);
-extern int slide_add_text(Slide *s, char **text, int n_text,
- struct frame_geom geom, enum alignment alignment);
+extern SlideItem *slide_add_text(Slide *s, char **text, int n_text,
+ struct frame_geom geom, enum alignment alignment);
extern int slide_add_footer(Slide *s);
-extern int slide_add_slidetitle(Slide *s, char **text, int n_text);
-extern int slide_add_prestitle(Slide *s, char **text, int n_text);
+extern SlideItem *slide_add_slidetitle(Slide *s, char **text, int n_text);
+extern SlideItem *slide_add_prestitle(Slide *s, char **text, int n_text);
extern int slide_set_logical_size(Slide *s, double w, double h);
extern int slide_get_logical_size(Slide *s, Stylesheet *ss, double *w, double *h);