From 77bdbbbf906dd23045337a8b0ccb79a239188c7f Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 1 Nov 2015 23:24:54 +0100 Subject: Vertical scrolling stuff --- src/sc_editor.c | 54 +++++++++++++++++++++++++++++++++++------------------- src/slide_window.c | 4 ++-- 2 files changed, 37 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/sc_editor.c b/src/sc_editor.c index 470faeb..785ecb0 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -83,11 +83,17 @@ static void set_vertical_params(SCEditor *e) static void update_size(SCEditor *e) { - e->w = e->top->w; - e->h = total_height(e->top); - e->log_w = e->w; - e->log_h = e->h; - e->top->h = e->h; + if ( e->flow ) { + e->w = e->top->w; + e->h = total_height(e->top); + e->log_w = e->w; + e->log_h = e->h; + e->top->h = e->h; + } else { + e->top->w = e->log_w; + e->top->h = e->log_h; + } + set_vertical_params(e); } @@ -100,19 +106,29 @@ static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event, /* Interpret and shape, if not already done */ if ( e->top == NULL ) { cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget)); + double w, h; + if ( e->flow ) { + w = event->width; + h = 0.0; + } else { + w = e->log_w; + h = e->log_h; + } e->top = interp_and_shape(e->scblocks, e->stylesheets, e->cbl, - e->is, ISZ_EDITOR, 0, cr, - event->width, 0.0); + e->is, ISZ_EDITOR, 0, cr, w, h); recursive_wrap(e->top, e->is, ISZ_EDITOR); cairo_destroy(cr); } - /* Wrap using current width */ - e->top->w = event->width; - e->top->h = 0.0; /* To be updated in a moment */ - e->top->x = 0.0; - e->top->y = 0.0; - wrap_contents(e->top); /* Only the top level needs to be wrapped */ + if ( e->flow ) { + /* Wrap using current width */ + e->top->w = event->width; + e->top->h = 0.0; /* To be updated in a moment */ + e->top->x = 0.0; + e->top->y = 0.0; + wrap_contents(e->top); /* Only the top level needs to be wrapped */ + } + update_size(e); return FALSE; @@ -204,10 +220,10 @@ static void get_preferred_width(GtkWidget *widget, gint *min, gint *natural) if ( e->flow ) { *min = 100; *natural = 640; + } else { + *min = e->w; + *natural = e->w; } - - *min = e->w; - *natural = e->w; } @@ -217,10 +233,10 @@ static void get_preferred_height(GtkWidget *widget, gint *min, gint *natural) if ( e->flow ) { *min = 1000; *natural = 1000; + } else { + *min = e->h; + *natural = e->h; } - - *min = e->h; - *natural = e->h; } diff --git a/src/slide_window.c b/src/slide_window.c index b25a3b3..42569b2 100644 --- a/src/slide_window.c +++ b/src/slide_window.c @@ -647,10 +647,10 @@ SlideWindow *slide_window_open(struct presentation *p, GApplication *app) sc_editor_set_size(sw->sceditor, 1024, 768); sc_editor_set_logical_size(sw->sceditor, 1024.0, 768.0); - gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(scroll), TRUE, TRUE, 0); /* Default size */ - gtk_window_set_default_size(GTK_WINDOW(sw->window), 1024+100, 768+150); + gtk_window_set_default_size(GTK_WINDOW(sw->window), 1024, 768); gtk_window_set_resizable(GTK_WINDOW(sw->window), TRUE); /* Initial background colour */ -- cgit v1.2.3