aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2015-11-02 09:33:44 +0100
committerThomas White <taw@bitwiz.org.uk>2015-11-02 09:33:44 +0100
commit4f2a324e715ea835b6be56579d8f8380a9e7370d (patch)
tree62b0f29e53549a44b4a9042499e17334433525af
parent77bdbbbf906dd23045337a8b0ccb79a239188c7f (diff)
Add horizontal scrolling
-rw-r--r--src/sc_editor.c24
-rw-r--r--src/sc_editor.h2
2 files changed, 25 insertions, 1 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c
index 785ecb0..11ec724 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -66,6 +66,21 @@ G_DEFINE_TYPE_WITH_CODE(SCEditor, sc_editor, GTK_TYPE_DRAWING_AREA,
scroll_interface_init))
+static void horizontal_adjust(GtkAdjustment *adj, SCEditor *e)
+{
+ e->h_scroll_pos = gtk_adjustment_get_value(adj);
+ sc_editor_redraw(e);
+}
+
+
+static void set_horizontal_params(SCEditor *e)
+{
+ if ( e->hadj == NULL ) return;
+ gtk_adjustment_configure(e->hadj, e->h_scroll_pos, 0, e->w, 100,
+ e->visible_width, e->visible_width);
+}
+
+
static void vertical_adjust(GtkAdjustment *adj, SCEditor *e)
{
e->scroll_pos = gtk_adjustment_get_value(adj);
@@ -95,6 +110,7 @@ static void update_size(SCEditor *e)
}
set_vertical_params(e);
+ set_horizontal_params(e);
}
@@ -102,6 +118,7 @@ static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event,
SCEditor *e)
{
e->visible_height = event->height;
+ e->visible_width = event->width;
/* Interpret and shape, if not already done */
if ( e->top == NULL ) {
@@ -167,6 +184,11 @@ static void sc_editor_set_property(GObject *obj, guint id, const GValue *val,
case SCEDITOR_HADJ :
e->hadj = g_value_get_object(val);
+ set_horizontal_params(e);
+ if ( e->hadj != NULL ) {
+ g_signal_connect(G_OBJECT(e->hadj), "value-changed",
+ G_CALLBACK(horizontal_adjust), e);
+ }
break;
default :
@@ -659,7 +681,7 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, SCEditor *e)
cairo_fill(cr);
/* Contents */
- cairo_translate(cr, 0.0, -e->scroll_pos);
+ cairo_translate(cr, -e->h_scroll_pos, -e->scroll_pos);
cairo_translate(cr, e->border_offs_x, e->border_offs_y);
recursive_draw(e->top, cr, e->is, ISZ_EDITOR,
e->scroll_pos, e->scroll_pos + e->visible_height);
diff --git a/src/sc_editor.h b/src/sc_editor.h
index f11a842..acbf9cf 100644
--- a/src/sc_editor.h
+++ b/src/sc_editor.h
@@ -103,7 +103,9 @@ struct _sceditor
GtkAdjustment *hadj;
GtkAdjustment *vadj;
double scroll_pos;
+ double h_scroll_pos;
int visible_height;
+ int visible_width;
int flow;
/* Pointers to the frame currently being edited */