diff --git a/gui.c b/gui.c index ea7a03b..08b7cc6 100644 --- a/gui.c +++ b/gui.c @@ -322,11 +322,19 @@ static void do_build_frames(void) void change_world(void) { struct bbox before, after; + int reachable_is_active; inst_deselect(); status_begin_reporting(); before = inst_get_bbox(); + reachable_is_active = reachable_pkg && reachable_pkg == active_pkg; + reachable_pkg = NULL; instantiate(); + if (reachable_is_active && reachable_pkg && + reachable_pkg != active_pkg) { + active_pkg = reachable_pkg; + instantiate(); + } after = inst_get_bbox(); label_in_box_bg(active_frame->label, COLOR_FRAME_SELECTED); do_build_frames(); diff --git a/inst.c b/inst.c index 24c1bab..7c58691 100644 --- a/inst.c +++ b/inst.c @@ -35,6 +35,7 @@ struct inst *selected_inst = NULL; struct bbox active_frame_bbox; struct pkg *pkgs, *active_pkg, *curr_pkg; +struct pkg *reachable_pkg = NULL; struct inst *frame_instantiating = NULL; static struct pkg *prev_pkgs; @@ -1173,7 +1174,7 @@ void inst_end_frame(const struct frame *frame) /* ----- package ----------------------------------------------------------- */ -void inst_select_pkg(const char *name) +void inst_select_pkg(const char *name, int active) { struct pkg **pkg; enum inst_prio prio; @@ -1192,6 +1193,8 @@ void inst_select_pkg(const char *name) (*pkg)->n_samples = n_samples; } curr_pkg = *pkg; + if (active && name) + reachable_pkg = curr_pkg; } @@ -1246,7 +1249,7 @@ void inst_start(void) active_frame_bbox = bbox_zero; prev_pkgs = pkgs; pkgs = NULL; - inst_select_pkg(NULL); + inst_select_pkg(NULL, 0); curr_pkg = pkgs; frame_instantiating = NULL; } diff --git a/inst.h b/inst.h index b64ed29..d79c930 100644 --- a/inst.h +++ b/inst.h @@ -134,6 +134,7 @@ extern struct inst *selected_inst; extern struct pkg *pkgs; /* list of packages */ extern struct pkg *active_pkg; /* package selected in GUI */ extern struct pkg *curr_pkg; /* package currently being instantiated */ +extern struct pkg *reachable_pkg; /* package reachable with active vars */ extern struct bbox active_frame_bbox; /* @@ -195,7 +196,7 @@ void inst_begin_frame(struct obj *obj, struct frame *frame, struct coord base, int active, int is_active_frame); void inst_end_frame(const struct frame *frame); -void inst_select_pkg(const char *name); +void inst_select_pkg(const char *name, int active); struct bbox inst_get_bbox(void); diff --git a/meas.c b/meas.c index e505c68..234dea2 100644 --- a/meas.c +++ b/meas.c @@ -317,7 +317,7 @@ int instantiate_meas(int n_frames) frame_instantiating = pkgs->insts[ip_frame]; for (pkg = pkgs; pkg; pkg = pkg->next) if (pkg->name) { - inst_select_pkg(pkg->name); + inst_select_pkg(pkg->name, 0); if (!instantiate_meas_pkg(n_frames)) return 0; purge_meas(pkg); diff --git a/obj.c b/obj.c index ee2e73a..c4f8f14 100644 --- a/obj.c +++ b/obj.c @@ -1,8 +1,8 @@ /* * obj.c - Object definition model * - * Written 2009-2011 by Werner Almesberger - * Copyright 2009-2011 by Werner Almesberger + * Written 2009-2012 by Werner Almesberger + * Copyright 2009-2012 by Werner Almesberger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -336,7 +336,7 @@ static int generate_items(struct frame *frame, struct coord base, int active) if (frame == frames) { s = expand(pkg_name, frame); /* s is NULL if expansion failed */ - inst_select_pkg(s ? s : "_"); + inst_select_pkg(s ? s : "_", active); free(s); } inst_begin_active(active && frame == active_frame);