aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/frame.c38
-rw-r--r--src/frame.h1
-rw-r--r--src/mainwindow.c42
-rw-r--r--src/render.c101
-rw-r--r--src/wrap.c2
5 files changed, 87 insertions, 97 deletions
diff --git a/src/frame.c b/src/frame.c
index 9a4f9e6..56e8f77 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -85,27 +85,6 @@ struct frame *add_subframe(struct frame *fr)
}
-static void show_heirarchy(struct frame *fr, const char *t)
-{
- int i;
- char tn[1024];
-
- strcpy(tn, t);
- strcat(tn, " |-> ");
-
- printf("%s%p %s\n", t, fr, fr->sc);
-
- for ( i=0; i<fr->num_children; i++ ) {
- if ( fr->children[i] != fr ) {
- show_heirarchy(fr->children[i], tn);
- } else {
- printf("%s<this frame>\n", tn);
- }
- }
-
-}
-
-
static int recursive_unpack(struct frame *fr, const char *sc)
{
SCBlockList *bl;
@@ -151,3 +130,20 @@ struct frame *sc_unpack(const char *sc)
return fr;
}
+
+void show_heirarchy(struct frame *fr, const char *t)
+{
+ int i;
+ char tn[1024];
+
+ strcpy(tn, t);
+ strcat(tn, " ");
+
+ printf("%s%p %s %p (%i x %i) / (%.2f x %.2f)\n", t, fr, fr->sc, fr->contents,
+ fr->pix_w, fr->pix_h, fr->w, fr->h);
+
+ for ( i=0; i<fr->num_children; i++ ) {
+ show_heirarchy(fr->children[i], tn);
+ }
+
+}
diff --git a/src/frame.h b/src/frame.h
index bce1009..5fb5297 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -115,5 +115,6 @@ struct frame
extern struct frame *frame_new(void);
extern struct frame *add_subframe(struct frame *fr);
extern struct frame *sc_unpack(const char *sc);
+extern void show_heirarchy(struct frame *fr, const char *t);
#endif /* FRAME_H */
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 3fb9fc2..d43b926 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -1028,8 +1028,8 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event,
}
-static void create_frame(struct presentation *p, double x, double y,
- double w, double h)
+static struct frame *create_frame(struct presentation *p, double x, double y,
+ double w, double h)
{
struct frame *parent;
struct frame *fr;
@@ -1041,15 +1041,15 @@ static void create_frame(struct presentation *p, double x, double y,
}
fr = add_subframe(parent);
- fr->sc = strdup("New frame!");
+ fr->sc = NULL;
fr->style = find_style(p->ss, "Content");
fr->lop_from_style = 0;
fr->lop.x = x;
fr->lop.y = y;
fr->lop.w = w;
fr->lop.h = h;
- rerender_slide(p);
- set_selection(p, fr);
+
+ return fr;
}
@@ -1057,6 +1057,7 @@ static gboolean button_release_sig(GtkWidget *da, GdkEventButton *event,
struct presentation *p)
{
gdouble x, y;
+ struct frame *fr;
x = event->x - p->border_offs_x;
y = event->y - p->border_offs_y;
@@ -1076,9 +1077,12 @@ static gboolean button_release_sig(GtkWidget *da, GdkEventButton *event,
break;
case DRAG_REASON_CREATE :
- create_frame(p, p->start_corner_x, p->start_corner_y,
- p->drag_corner_x - p->start_corner_x,
- p->drag_corner_y - p->start_corner_y);
+ fr = create_frame(p, p->start_corner_x, p->start_corner_y,
+ p->drag_corner_x - p->start_corner_x,
+ p->drag_corner_y - p->start_corner_y);
+ fr->sc = strdup("");
+ rerender_slide(p);
+ set_selection(p, fr);
break;
case DRAG_REASON_IMPORT :
@@ -1300,7 +1304,6 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context,
}
g_strfreev(uris);
- printf("Testing '%s'\n", filename);
if ( filename == NULL ) {
/* This doesn't even look like a sensible URI.
@@ -1363,10 +1366,27 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context,
if ( filename != NULL ) {
+ struct frame *fr;
+ char *sc;
+
gtk_drag_finish(drag_context, TRUE, FALSE, time);
chomp(filename);
- printf("Adding '%s'\n", filename);
- /* FIXME: Actually add it */
+
+ sc = malloc(strlen(filename)+10);
+ if ( sc == NULL ) {
+ free(filename);
+ fprintf(stderr, "Failed to allocate SC\n");
+ return;
+ }
+
+ fr = create_frame(p, p->start_corner_x,
+ p->start_corner_y,
+ p->drag_corner_x - p->start_corner_x,
+ p->drag_corner_y - p->start_corner_y);
+ fr->sc = sc;
+ rerender_slide(p);
+ set_selection(p, fr);
+ redraw_editor(p);
free(filename);
}
diff --git a/src/render.c b/src/render.c
index fe52a26..3555455 100644
--- a/src/render.c
+++ b/src/render.c
@@ -279,66 +279,60 @@ static int render_sc(struct frame *fr, double scale)
static int render_frame(struct frame *fr, double scale)
{
- if ( fr->num_children > 0 ) {
-
- int i;
-
- /* Render all subframes */
- for ( i=0; i<fr->num_children; i++ ) {
-
- struct frame *ch = fr->children[i];
- double mtot;
-
- if ( (ch->style != NULL) && ch->lop_from_style ) {
- memcpy(&ch->lop, &ch->style->lop,
- sizeof(struct layout_parameters));
- }
+ int i;
+ /* Render all subframes */
+ for ( i=0; i<fr->num_children; i++ ) {
- mtot = ch->lop.margin_l + ch->lop.margin_r;
- mtot += fr->lop.pad_l + fr->lop.pad_r;
- switch ( ch->lop.w_units ) {
+ struct frame *ch = fr->children[i];
+ double mtot;
- case UNITS_SLIDE :
- ch->w = ch->lop.w;
- break;
+ if ( (ch->style != NULL) && ch->lop_from_style ) {
+ memcpy(&ch->lop, &ch->style->lop,
+ sizeof(struct layout_parameters));
+ }
- case UNITS_FRAC :
- ch->w = fr->w * ch->lop.w - mtot;
- break;
- }
+ mtot = ch->lop.margin_l + ch->lop.margin_r;
+ mtot += fr->lop.pad_l + fr->lop.pad_r;
+ switch ( ch->lop.w_units ) {
- mtot = ch->lop.margin_t + ch->lop.margin_b;
- mtot += fr->lop.pad_t + fr->lop.pad_b;
- switch ( ch->lop.h_units ) {
+ case UNITS_SLIDE :
+ ch->w = ch->lop.w;
+ break;
- case UNITS_SLIDE :
- ch->h = ch->lop.h;
- break;
+ case UNITS_FRAC :
+ ch->w = fr->w * ch->lop.w - mtot;
+ break;
- case UNITS_FRAC :
- ch->h = fr->h * ch->lop.h - mtot;
- break;
+ }
- }
+ mtot = ch->lop.margin_t + ch->lop.margin_b;
+ mtot += fr->lop.pad_t + fr->lop.pad_b;
+ switch ( ch->lop.h_units ) {
- /* Rounding to get bitmap size */
- ch->pix_w = ch->w*scale;
- ch->pix_h = ch->h*scale;
- render_frame(ch, scale);
+ case UNITS_SLIDE :
+ ch->h = ch->lop.h;
+ break;
- ch->x = ch->lop.x + fr->lop.pad_l + ch->lop.margin_l;
- ch->y = ch->lop.y + fr->lop.pad_t + ch->lop.margin_t;
+ case UNITS_FRAC :
+ ch->h = fr->h * ch->lop.h - mtot;
+ break;
}
- } else {
+ /* Rounding to get bitmap size */
+ ch->pix_w = ch->w*scale;
+ ch->pix_h = ch->h*scale;
+ render_frame(ch, scale);
- render_sc(fr, scale);
+ ch->x = ch->lop.x + fr->lop.pad_l + ch->lop.margin_l;
+ ch->y = ch->lop.y + fr->lop.pad_t + ch->lop.margin_t;
}
+ render_sc(fr, scale);
+
return 0;
}
@@ -435,29 +429,6 @@ static void composite_slide(struct slide *s, cairo_t *cr, double scale)
}
-static void show_heirarchy(struct frame *fr, const char *t)
-{
- int i;
- char tn[1024];
-
- strcpy(tn, t);
- strcat(tn, " |-> ");
-
- printf("%s%p %s (%i x %i) / (%.2f x %.2f)\n", t, fr, fr->sc,
- fr->pix_w, fr->pix_h, fr->w, fr->h);
-
- for ( i=0; i<fr->num_children; i++ ) {
- if ( fr->children[i] != fr ) {
- show_heirarchy(fr->children[i], tn);
- } else {
- printf("%s<this frame>\n", tn);
- }
- }
-
-}
-
-
-
/**
* render_slide:
* @s: A slide.
diff --git a/src/wrap.c b/src/wrap.c
index 5ecd34c..85143a5 100644
--- a/src/wrap.c
+++ b/src/wrap.c
@@ -94,6 +94,8 @@ void get_cursor_pos(struct frame *fr, size_t pos,
*xposd = 0;
*yposd = 0;
+ if ( fr->n_lines == 0 ) return;
+
line = 0;
for ( i=0; i<fr->n_lines; i++ ) {
if ( fr->lines[i].sc_offset > pos ) {