Date: | 2012-05-26 00:20:29 (11 years 10 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | e0351bdf738ee187c68fecc0016d71dc0eb68668 |
Message: | make active package track active variables (for the GUI) If the package whose name is produced by the active variable values is active and the variables change, then make the newly active package the one whose name is produced by the changed variables. This way, iterating through a table or a loop will automatically switch to the right package, with the exception that, if the user choses to explicitly select a different package (by clicking on its name in the packages line), then that selection takes priority. Explicit selection loses its priority when active package and active variables coincide again. I.e., one can simply "catch" the active package by activating the corresponding values. |
Files: |
gui.c (1 diff) inst.c (4 diffs) inst.h (2 diffs) meas.c (1 diff) obj.c (2 diffs) |
Change Details
gui.c | ||
---|---|---|
322 | 322 | void change_world(void) |
323 | 323 | { |
324 | 324 | struct bbox before, after; |
325 | int reachable_is_active; | |
325 | 326 | |
326 | 327 | inst_deselect(); |
327 | 328 | status_begin_reporting(); |
328 | 329 | before = inst_get_bbox(); |
330 | reachable_is_active = reachable_pkg && reachable_pkg == active_pkg; | |
331 | reachable_pkg = NULL; | |
329 | 332 | instantiate(); |
333 | if (reachable_is_active && reachable_pkg && | |
334 | reachable_pkg != active_pkg) { | |
335 | active_pkg = reachable_pkg; | |
336 | instantiate(); | |
337 | } | |
330 | 338 | after = inst_get_bbox(); |
331 | 339 | label_in_box_bg(active_frame->label, COLOR_FRAME_SELECTED); |
332 | 340 | do_build_frames(); |
inst.c | ||
---|---|---|
35 | 35 | struct inst *selected_inst = NULL; |
36 | 36 | struct bbox active_frame_bbox; |
37 | 37 | struct pkg *pkgs, *active_pkg, *curr_pkg; |
38 | struct pkg *reachable_pkg = NULL; | |
38 | 39 | struct inst *frame_instantiating = NULL; |
39 | 40 | |
40 | 41 | static struct pkg *prev_pkgs; |
... | ... | |
1173 | 1174 | /* ----- package ----------------------------------------------------------- */ |
1174 | 1175 | |
1175 | 1176 | |
1176 | void inst_select_pkg(const char *name) | |
1177 | void inst_select_pkg(const char *name, int active) | |
1177 | 1178 | { |
1178 | 1179 | struct pkg **pkg; |
1179 | 1180 | enum inst_prio prio; |
... | ... | |
1192 | 1193 | (*pkg)->n_samples = n_samples; |
1193 | 1194 | } |
1194 | 1195 | curr_pkg = *pkg; |
1196 | if (active && name) | |
1197 | reachable_pkg = curr_pkg; | |
1195 | 1198 | } |
1196 | 1199 | |
1197 | 1200 | |
... | ... | |
1246 | 1249 | active_frame_bbox = bbox_zero; |
1247 | 1250 | prev_pkgs = pkgs; |
1248 | 1251 | pkgs = NULL; |
1249 | inst_select_pkg(NULL); | |
1252 | inst_select_pkg(NULL, 0); | |
1250 | 1253 | curr_pkg = pkgs; |
1251 | 1254 | frame_instantiating = NULL; |
1252 | 1255 | } |
inst.h | ||
---|---|---|
134 | 134 | extern struct pkg *pkgs; /* list of packages */ |
135 | 135 | extern struct pkg *active_pkg; /* package selected in GUI */ |
136 | 136 | extern struct pkg *curr_pkg; /* package currently being instantiated */ |
137 | extern struct pkg *reachable_pkg; /* package reachable with active vars */ | |
137 | 138 | extern struct bbox active_frame_bbox; |
138 | 139 | |
139 | 140 | /* |
... | ... | |
195 | 196 | struct coord base, int active, int is_active_frame); |
196 | 197 | void inst_end_frame(const struct frame *frame); |
197 | 198 | |
198 | void inst_select_pkg(const char *name); | |
199 | void inst_select_pkg(const char *name, int active); | |
199 | 200 | |
200 | 201 | struct bbox inst_get_bbox(void); |
201 | 202 |
meas.c | ||
---|---|---|
317 | 317 | frame_instantiating = pkgs->insts[ip_frame]; |
318 | 318 | for (pkg = pkgs; pkg; pkg = pkg->next) |
319 | 319 | if (pkg->name) { |
320 | inst_select_pkg(pkg->name); | |
320 | inst_select_pkg(pkg->name, 0); | |
321 | 321 | if (!instantiate_meas_pkg(n_frames)) |
322 | 322 | return 0; |
323 | 323 | purge_meas(pkg); |
obj.c | ||
---|---|---|
1 | 1 | /* |
2 | 2 | * obj.c - Object definition model |
3 | 3 | * |
4 | * Written 2009-2011 by Werner Almesberger | |
5 | * Copyright 2009-2011 by Werner Almesberger | |
4 | * Written 2009-2012 by Werner Almesberger | |
5 | * Copyright 2009-2012 by Werner Almesberger | |
6 | 6 | * |
7 | 7 | * This program is free software; you can redistribute it and/or modify |
8 | 8 | * it under the terms of the GNU General Public License as published by |
... | ... | |
336 | 336 | if (frame == frames) { |
337 | 337 | s = expand(pkg_name, frame); |
338 | 338 | /* s is NULL if expansion failed */ |
339 | inst_select_pkg(s ? s : "_"); | |
339 | inst_select_pkg(s ? s : "_", active); | |
340 | 340 | free(s); |
341 | 341 | } |
342 | 342 | inst_begin_active(active && frame == active_frame); |
Branches:
master