summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/common.h2
-rw-r--r--gui/gui.c16
-rw-r--r--gui/index.c16
-rw-r--r--gui/sheet.c16
4 files changed, 32 insertions, 18 deletions
diff --git a/gui/common.h b/gui/common.h
index ace8f82..6088e1d 100644
--- a/gui/common.h
+++ b/gui/common.h
@@ -157,6 +157,7 @@ void add_glabel_aoi(struct gui_sheet *sheet, const struct sch_obj *obj);
/* sheet.c */
void go_to_sheet(struct gui_ctx *ctx, struct gui_sheet *sheet);
+void zoom_to_extents(struct gui_ctx *ctx);
void do_revision_overlays(struct gui_ctx *ctx);
void sheet_setup(struct gui_ctx *ctx);
@@ -167,6 +168,7 @@ void show_history(struct gui_ctx *ctx, enum selecting sel);
/* index.c */
void index_draw_event(const struct gui_ctx *ctx, cairo_t *cr);
+void index_resize(struct gui_ctx *ctx);
void show_index(struct gui_ctx *ctx);
/* gui.c */
diff --git a/gui/gui.c b/gui/gui.c
index 0a0d2b5..2b3e001 100644
--- a/gui/gui.c
+++ b/gui/gui.c
@@ -424,6 +424,20 @@ static void get_history(struct gui_ctx *ctx, const char *sch_name, int limit)
}
+/* ----- Resizing ---------------------------------------------------------- */
+
+
+static void size_allocate_event(GtkWidget *widget, GdkRectangle *allocation,
+ gpointer data)
+{
+ struct gui_ctx *ctx = data;
+
+ zoom_to_extents(ctx);
+ if (ctx->mode == showing_index)
+ index_resize(ctx);
+}
+
+
/* ----- Initialization ---------------------------------------------------- */
@@ -475,6 +489,8 @@ int gui(const struct file_names *fn, bool recurse, int limit)
if (!ctx.new_hist)
fatal("no valid sheets\n");
+ g_signal_connect(G_OBJECT(ctx.da), "size_allocate",
+ G_CALLBACK(size_allocate_event), &ctx);
g_signal_connect(window, "destroy",
G_CALLBACK(gtk_main_quit), NULL);
diff --git a/gui/index.c b/gui/index.c
index d9dd9bd..62dd259 100644
--- a/gui/index.c
+++ b/gui/index.c
@@ -274,6 +274,18 @@ static const struct input_ops index_input_ops = {
};
+/* ----- Resizing ---------------------------------------------------------- */
+
+
+void index_resize(struct gui_ctx *ctx)
+{
+ overlay_remove_all(&ctx->thumb_overlays);
+ best_ratio(ctx);
+ index_render_sheets(ctx);
+ redraw(ctx);
+}
+
+
/* ----- Initialization ---------------------------------------------------- */
@@ -281,7 +293,5 @@ void show_index(struct gui_ctx *ctx)
{
input_push(&index_input_ops, ctx);
ctx->mode = showing_index;
- best_ratio(ctx);
- index_render_sheets(ctx);
- redraw(ctx);
+ index_resize(ctx);
}
diff --git a/gui/sheet.c b/gui/sheet.c
index dfd0f57..3e65f28 100644
--- a/gui/sheet.c
+++ b/gui/sheet.c
@@ -118,7 +118,7 @@ static void curr_sheet_size(struct gui_ctx *ctx, int *w, int *h)
}
-static void zoom_to_extents(struct gui_ctx *ctx)
+void zoom_to_extents(struct gui_ctx *ctx)
{
GtkAllocation alloc;
int w, h;
@@ -596,24 +596,10 @@ static const struct input_ops sheet_input_ops = {
};
-/* ----- Event handlers ---------------------------------------------------- */
-
-
-static void size_allocate_event(GtkWidget *widget, GdkRectangle *allocation,
- gpointer data)
-{
- struct gui_ctx *ctx = data;
-
- zoom_to_extents(ctx);
-}
-
-
/* ----- Initialization ---------------------------------------------------- */
void sheet_setup(struct gui_ctx *ctx)
{
- g_signal_connect(G_OBJECT(ctx->da), "size_allocate",
- G_CALLBACK(size_allocate_event), ctx);
input_push(&sheet_input_ops, ctx);
}