aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2014-09-28 14:59:05 +0200
committerThomas White <taw@bitwiz.org.uk>2014-09-28 14:59:05 +0200
commit2931d57e2bb25d44e6b70e18935fe1530b8dd4a5 (patch)
tree8c5f1d44963e6bce76d8802804fc2b5883b9cfbe
parentbee5e2fd263d81b7dc8180e831cbc96500cece1f (diff)
SCEditor, part III
-rw-r--r--src/presentation.c4
-rw-r--r--src/presentation.h7
-rw-r--r--src/slide_sorter.c44
-rw-r--r--src/slideshow.c23
-rw-r--r--tests/render_test.c10
-rw-r--r--tests/render_test_sc1.c10
6 files changed, 33 insertions, 65 deletions
diff --git a/src/presentation.c b/src/presentation.c
index e565edf..d6c7429 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -129,10 +129,6 @@ struct slide *new_slide()
new = calloc(1, sizeof(struct slide));
if ( new == NULL ) return NULL;
- new->rendered_edit = NULL;
- new->rendered_proj = NULL;
- new->rendered_thumb = NULL;
-
new->top = frame_new();
/* FIXME: Set zero margins etc on top level frame */
diff --git a/src/presentation.h b/src/presentation.h
index f3b11b4..0fa7d71 100644
--- a/src/presentation.h
+++ b/src/presentation.h
@@ -44,13 +44,6 @@ struct slide
struct presentation *parent;
struct slide_template *st;
- /* Any of these may be NULL */
- cairo_surface_t *rendered_proj;
- cairo_surface_t *rendered_edit;
-
- /* This should always be present (and up to date). */
- cairo_surface_t *rendered_thumb;
-
struct frame *top;
SCBlock *scblocks;
diff --git a/src/slide_sorter.c b/src/slide_sorter.c
index 8130ffa..54b6804 100644
--- a/src/slide_sorter.c
+++ b/src/slide_sorter.c
@@ -99,7 +99,7 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, struct slide_sorter *n)
int x = i % n->width;
int y = i / n->width;
- struct slide *s = n->p->slides[i];
+ //struct slide *s = n->p->slides[i];
cairo_save(cr);
@@ -120,17 +120,9 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, struct slide_sorter *n)
cairo_rectangle(cr, 0.0, 0.0, n->tw, n->th);
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
cairo_fill_preserve(cr);
- if ( (s != NULL) && (s->rendered_thumb != NULL) ) {
- cairo_set_source_surface(cr, s->rendered_thumb,
- 0.0, 0.0);
- } else {
- printf("Slide %i: %p", i, s);
- if ( s != NULL ) {
- printf(" %p\n", s->rendered_thumb);
- } else {
- printf("\n");
- }
- }
+ /* FIXME */
+ //cairo_set_source_surface(cr, s->rendered_thumb,
+ // 0.0, 0.0);
cairo_fill(cr);
cairo_rectangle(cr, 0.5, 0.5, n->tw, n->th);
@@ -348,10 +340,10 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context,
} else {
- const char *sc;
+ //const char *sc;
struct slide *s = NULL;
- sc = (const char *)gtk_selection_data_get_data(seldata);
+ //sc = (const char *)gtk_selection_data_get_data(seldata);
n->dragging = 0;
gtk_drag_finish(drag_context, TRUE, TRUE, time);
@@ -363,23 +355,17 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context,
if ( s != NULL ) {
/* FIXME: Do something */
- int sn = slide_number(n->p, s);
+ //int sn = slide_number(n->p, s);
- s->rendered_thumb = render_slide(s, n->tw,
- n->p->slide_width,
- n->p->slide_height,
- n->p->is,
- ISZ_THUMBNAIL, sn);
+ //s->rendered_thumb = render_slide(s, n->tw,
+ // n->p->slide_width,
+ // n->p->slide_height,
+ // n->p->is,
+ // ISZ_THUMBNAIL, sn);
/* FIXME: Transfer the notes as well */
- if ( n->dragging_cur_edit_slide ) {
- change_edit_slide(n->p, s);
- } else {
- /* Slide order has changed, so slide change
- * buttons might need to be greyed out */
- update_toolbar(n->p);
- }
+ change_edit_slide(n->p->slidewindow, s);
if ( n->dragging_cur_proj_slide ) {
fixup_proj(n->p, s);
@@ -413,6 +399,7 @@ static void dnd_get(GtkWidget *widget, GdkDragContext *drag_context,
char *sc;
/* FIXME: packed sc */
//sc = packed_sc(n->p->slides[n->selection]->top, n->p->ss);
+ sc = NULL;
gtk_selection_data_set(seldata, target, 8, (guchar *)sc,
strlen(sc));
@@ -468,8 +455,7 @@ static void dnd_delete(GtkWidget *widget, GdkDragContext *drag_context,
ct = sn - 1;
}
- change_edit_slide(n->p, n->p->slides[ct]);
- update_toolbar(n->p);
+ change_edit_slide(n->p->slidewindow, n->p->slides[ct]);
}
diff --git a/src/slideshow.c b/src/slideshow.c
index c0a9200..800d9b5 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -50,6 +50,7 @@ struct _slideshow
int slide_width;
struct inhibit_sys *inhibit;
int linked;
+ cairo_surface_t *surface;
};
@@ -69,15 +70,12 @@ void slideshow_rerender(SlideShow *ss)
{
int n;
- if ( ss->cur_slide->rendered_proj != NULL ) return;
-
n = slide_number(ss->p, ss->cur_slide);
- ss->cur_slide->rendered_proj = render_slide(ss->cur_slide,
- ss->slide_width,
- ss->p->slide_width,
- ss->p->slide_height,
- ss->p->is, ISZ_SLIDESHOW,
- n);
+ ss->surface = render_slide(ss->cur_slide,
+ ss->slide_width,
+ ss->p->slide_width,
+ ss->p->slide_height,
+ ss->p->is, ISZ_SLIDESHOW, n);
}
@@ -116,8 +114,7 @@ static gboolean ss_draw_sig(GtkWidget *da, cairo_t *cr, SlideShow *ss)
/* Draw the slide from the cache */
cairo_rectangle(cr, xoff, yoff, ss->slide_width, h);
- cairo_set_source_surface(cr, ss->cur_slide->rendered_proj,
- xoff, yoff);
+ cairo_set_source_surface(cr, ss->surface, xoff, yoff);
cairo_fill(cr);
}
@@ -143,7 +140,7 @@ static gint prev_slide_sig(GtkWidget *widget, SlideShow *ss)
int cur_slide_number;
cur_slide_number = slide_number(ss->p, ss->p->cur_edit_slide);
if ( cur_slide_number == 0 ) return FALSE;
- change_edit_slide(ss->p, ss->p->slides[cur_slide_number-1]);
+ change_edit_slide(ss->p->slidewindow, ss->p->slides[cur_slide_number-1]);
return FALSE;
}
@@ -153,7 +150,7 @@ static gint next_slide_sig(GtkWidget *widget, SlideShow *ss)
int cur_slide_number;
cur_slide_number = slide_number(ss->p, ss->p->cur_edit_slide);
if ( cur_slide_number == ss->p->num_slides-1 ) return FALSE;
- change_edit_slide(ss->p, ss->p->slides[cur_slide_number+1]);
+ change_edit_slide(ss->p->slidewindow, ss->p->slides[cur_slide_number+1]);
return FALSE;
}
@@ -165,7 +162,7 @@ void end_slideshow(SlideShow *ss)
gtk_widget_destroy(ss->slideshow);
free(ss);
ss->p->slideshow = NULL;
- redraw_editor(ss->p);
+ redraw_editor(ss->p->slidewindow);
}
diff --git a/tests/render_test.c b/tests/render_test.c
index eec2be2..eab6108 100644
--- a/tests/render_test.c
+++ b/tests/render_test.c
@@ -49,6 +49,7 @@ static gint mw_destroy(GtkWidget *w, void *p)
static gboolean draw_sig(GtkWidget *da, cairo_t *cr, gpointer data)
{
gint w, h;
+ cairo_surface_t *surface;
struct slide *s = data;
w = gtk_widget_get_allocated_width(da);
@@ -59,11 +60,11 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, gpointer data)
cairo_set_source_rgb(cr, 0.9, 0.9, 0.9);
cairo_fill(cr);
- if ( s->rendered_edit != NULL ) cairo_surface_destroy(s->rendered_edit);
- s->rendered_edit = render_slide(s, w, w, h, NULL, ISZ_EDITOR, 1);
+ surface = render_slide(s, w, w, h, NULL, ISZ_EDITOR, 1);
cairo_rectangle(cr, 0.0, 0.0, w, h);
- cairo_set_source_surface(cr, s->rendered_edit, 0.0, 0.0);
+ cairo_set_source_surface(cr, surface, 0.0, 0.0);
cairo_fill(cr);
+ cairo_surface_destroy(surface);
return FALSE;
}
@@ -93,9 +94,6 @@ int main(int argc, char *argv[])
fr->pad_b = 20.0;
s.top = fr;
- s.rendered_edit = NULL;
- s.rendered_proj = NULL;
- s.rendered_thumb = NULL;
s.parent = &p;
s.scblocks = fr->scblocks;
diff --git a/tests/render_test_sc1.c b/tests/render_test_sc1.c
index d8172cd..590f21e 100644
--- a/tests/render_test_sc1.c
+++ b/tests/render_test_sc1.c
@@ -47,6 +47,7 @@ static gint mw_destroy(GtkWidget *w, void *p)
static gboolean draw_sig(GtkWidget *da, cairo_t *cr, gpointer data)
{
gint w, h;
+ cairo_surface_t *surface;
struct slide *s = data;
w = gtk_widget_get_allocated_width(da);
@@ -57,11 +58,11 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, gpointer data)
cairo_set_source_rgb(cr, 0.9, 0.9, 0.9);
cairo_fill(cr);
- if ( s->rendered_edit != NULL ) cairo_surface_destroy(s->rendered_edit);
- s->rendered_edit = render_slide(s, w, w, h, NULL, ISZ_EDITOR, 1);
+ surface = render_slide(s, w, w, h, NULL, ISZ_EDITOR, 1);
cairo_rectangle(cr, 0.0, 0.0, w, h);
- cairo_set_source_surface(cr, s->rendered_edit, 0.0, 0.0);
+ cairo_set_source_surface(cr, surface, 0.0, 0.0);
cairo_fill(cr);
+ cairo_surface_destroy(surface);
return FALSE;
}
@@ -91,9 +92,6 @@ int main(int argc, char *argv[])
fr->pad_b = 20.0;
s.top = fr;
- s.rendered_edit = NULL;
- s.rendered_proj = NULL;
- s.rendered_thumb = NULL;
s.parent = &p;
s.scblocks = fr->scblocks;