aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2014-12-08 23:41:10 +0100
committerThomas White <taw@bitwiz.org.uk>2014-12-08 23:41:10 +0100
commit61d8ee107cb9a2af29184290389244b92b0d638d (patch)
treed92f717b78e033fc44f4f846659b1ca4f05e7b33 /src
parent5ae5202020cb11e7760c881c88c24252f231f232 (diff)
Add minimum border size
Diffstat (limited to 'src')
-rw-r--r--src/narrative_window.c1
-rw-r--r--src/sc_editor.c35
-rw-r--r--src/sc_editor.h2
3 files changed, 30 insertions, 8 deletions
diff --git a/src/narrative_window.c b/src/narrative_window.c
index 0cc3b34..2d5727f 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -271,6 +271,7 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *app)
sc_editor_set_size(nw->sceditor, 640, 1024);
sc_editor_set_logical_size(nw->sceditor, 640.0, 1024.0);
sc_editor_set_background(nw->sceditor, 0.9, 0.9, 0.9);
+ sc_editor_set_min_border(nw->sceditor, 40.0);
g_signal_connect(G_OBJECT(nw->sceditor), "button-press-event",
G_CALLBACK(button_press_sig), nw);
diff --git a/src/sc_editor.c b/src/sc_editor.c
index 1a081aa..d8d93a1 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -415,7 +415,6 @@ static void tile_pixbuf(cairo_t *cr, GdkPixbuf *pb, int width, int height)
static gboolean draw_sig(GtkWidget *da, cairo_t *cr,
SCEditor *e)
{
- double xoff, yoff;
int width, height;
width = gtk_widget_get_allocated_width(GTK_WIDGET(da));
@@ -428,20 +427,25 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr,
cairo_fill(cr);
/* Get the overall size */
- xoff = (width - e->w)/2.0;
- yoff = (height - e->h)/2.0;
- e->border_offs_x = xoff;
- e->border_offs_y = yoff;
+ e->border_offs_x = (width - e->w)/2.0;
+ e->border_offs_y = (height - e->h)/2.0;
+ if ( e->border_offs_x < e->min_border ) {
+ e->border_offs_x = e->min_border;
+ }
+ if ( e->border_offs_y < e->min_border ) {
+ e->border_offs_y = e->min_border;
+ }
/* Draw the slide from the cache */
if ( e->surface != NULL ) {
- cairo_set_source_surface(cr, e->surface, xoff, yoff);
+ cairo_set_source_surface(cr, e->surface, e->border_offs_x,
+ e->border_offs_y);
cairo_paint(cr);
} else {
fprintf(stderr, "Current slide not rendered yet!\n");
}
- cairo_translate(cr, xoff, yoff);
+ cairo_translate(cr, e->border_offs_x, e->border_offs_y);
draw_overlay(cr, e);
return FALSE;
@@ -1396,11 +1400,18 @@ void sc_editor_set_scblock(SCEditor *e, SCBlock *scblocks)
}
+static void update_size_request(SCEditor *e)
+{
+ gtk_widget_set_size_request(GTK_WIDGET(e), e->w + 2.0*e->min_border,
+ e->h + 2.0*e->min_border);
+}
+
+
void sc_editor_set_size(SCEditor *e, int w, int h)
{
e->w = w;
e->h = h;
- gtk_widget_set_size_request(GTK_WIDGET(e), w, h);
+ update_size_request(e);
}
@@ -1417,6 +1428,13 @@ void sc_editor_set_slidenum(SCEditor *e, int slidenum)
}
+void sc_editor_set_min_border(SCEditor *e, double min_border)
+{
+ e->min_border = min_border;
+ update_size_request(e);
+}
+
+
SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock *stylesheet)
{
SCEditor *sceditor;
@@ -1434,6 +1452,7 @@ SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock *stylesheet)
sceditor->is = imagestore_new();
sceditor->stylesheet = stylesheet;
sceditor->slidenum = 0;
+ sceditor->min_border = 0.0;
err = NULL;
sceditor->bg_pixbuf = gdk_pixbuf_new_from_file(DATADIR"/colloquium/sky.png", &err);
diff --git a/src/sc_editor.h b/src/sc_editor.h
index 509ce0e..ef05b56 100644
--- a/src/sc_editor.h
+++ b/src/sc_editor.h
@@ -109,6 +109,7 @@ struct _sceditor
/* Border surrounding actual slide within drawingarea */
double border_offs_x;
double border_offs_y;
+ double min_border;
double bgcol[3];
GdkPixbuf *bg_pixbuf;
@@ -154,5 +155,6 @@ extern void sc_editor_set_logical_size(SCEditor *e, double w, double h);
extern void sc_editor_redraw(SCEditor *e);
extern void sc_editor_set_background(SCEditor *e, double r, double g, double b);
extern void sc_editor_set_slidenum(SCEditor *e, int slidenum);
+extern void sc_editor_set_min_border(SCEditor *e, double min_border);
#endif /* SC_EDITOR_H */