mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-22 08:51:53 +02:00
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.
This commit is contained in:
parent
b06ed92557
commit
e0351bdf73
8
gui.c
8
gui.c
@ -322,11 +322,19 @@ static void do_build_frames(void)
|
|||||||
void change_world(void)
|
void change_world(void)
|
||||||
{
|
{
|
||||||
struct bbox before, after;
|
struct bbox before, after;
|
||||||
|
int reachable_is_active;
|
||||||
|
|
||||||
inst_deselect();
|
inst_deselect();
|
||||||
status_begin_reporting();
|
status_begin_reporting();
|
||||||
before = inst_get_bbox();
|
before = inst_get_bbox();
|
||||||
|
reachable_is_active = reachable_pkg && reachable_pkg == active_pkg;
|
||||||
|
reachable_pkg = NULL;
|
||||||
instantiate();
|
instantiate();
|
||||||
|
if (reachable_is_active && reachable_pkg &&
|
||||||
|
reachable_pkg != active_pkg) {
|
||||||
|
active_pkg = reachable_pkg;
|
||||||
|
instantiate();
|
||||||
|
}
|
||||||
after = inst_get_bbox();
|
after = inst_get_bbox();
|
||||||
label_in_box_bg(active_frame->label, COLOR_FRAME_SELECTED);
|
label_in_box_bg(active_frame->label, COLOR_FRAME_SELECTED);
|
||||||
do_build_frames();
|
do_build_frames();
|
||||||
|
7
inst.c
7
inst.c
@ -35,6 +35,7 @@
|
|||||||
struct inst *selected_inst = NULL;
|
struct inst *selected_inst = NULL;
|
||||||
struct bbox active_frame_bbox;
|
struct bbox active_frame_bbox;
|
||||||
struct pkg *pkgs, *active_pkg, *curr_pkg;
|
struct pkg *pkgs, *active_pkg, *curr_pkg;
|
||||||
|
struct pkg *reachable_pkg = NULL;
|
||||||
struct inst *frame_instantiating = NULL;
|
struct inst *frame_instantiating = NULL;
|
||||||
|
|
||||||
static struct pkg *prev_pkgs;
|
static struct pkg *prev_pkgs;
|
||||||
@ -1173,7 +1174,7 @@ void inst_end_frame(const struct frame *frame)
|
|||||||
/* ----- package ----------------------------------------------------------- */
|
/* ----- package ----------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
void inst_select_pkg(const char *name)
|
void inst_select_pkg(const char *name, int active)
|
||||||
{
|
{
|
||||||
struct pkg **pkg;
|
struct pkg **pkg;
|
||||||
enum inst_prio prio;
|
enum inst_prio prio;
|
||||||
@ -1192,6 +1193,8 @@ void inst_select_pkg(const char *name)
|
|||||||
(*pkg)->n_samples = n_samples;
|
(*pkg)->n_samples = n_samples;
|
||||||
}
|
}
|
||||||
curr_pkg = *pkg;
|
curr_pkg = *pkg;
|
||||||
|
if (active && name)
|
||||||
|
reachable_pkg = curr_pkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1246,7 +1249,7 @@ void inst_start(void)
|
|||||||
active_frame_bbox = bbox_zero;
|
active_frame_bbox = bbox_zero;
|
||||||
prev_pkgs = pkgs;
|
prev_pkgs = pkgs;
|
||||||
pkgs = NULL;
|
pkgs = NULL;
|
||||||
inst_select_pkg(NULL);
|
inst_select_pkg(NULL, 0);
|
||||||
curr_pkg = pkgs;
|
curr_pkg = pkgs;
|
||||||
frame_instantiating = NULL;
|
frame_instantiating = NULL;
|
||||||
}
|
}
|
||||||
|
3
inst.h
3
inst.h
@ -134,6 +134,7 @@ extern struct inst *selected_inst;
|
|||||||
extern struct pkg *pkgs; /* list of packages */
|
extern struct pkg *pkgs; /* list of packages */
|
||||||
extern struct pkg *active_pkg; /* package selected in GUI */
|
extern struct pkg *active_pkg; /* package selected in GUI */
|
||||||
extern struct pkg *curr_pkg; /* package currently being instantiated */
|
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;
|
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);
|
struct coord base, int active, int is_active_frame);
|
||||||
void inst_end_frame(const struct frame *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);
|
struct bbox inst_get_bbox(void);
|
||||||
|
|
||||||
|
2
meas.c
2
meas.c
@ -317,7 +317,7 @@ int instantiate_meas(int n_frames)
|
|||||||
frame_instantiating = pkgs->insts[ip_frame];
|
frame_instantiating = pkgs->insts[ip_frame];
|
||||||
for (pkg = pkgs; pkg; pkg = pkg->next)
|
for (pkg = pkgs; pkg; pkg = pkg->next)
|
||||||
if (pkg->name) {
|
if (pkg->name) {
|
||||||
inst_select_pkg(pkg->name);
|
inst_select_pkg(pkg->name, 0);
|
||||||
if (!instantiate_meas_pkg(n_frames))
|
if (!instantiate_meas_pkg(n_frames))
|
||||||
return 0;
|
return 0;
|
||||||
purge_meas(pkg);
|
purge_meas(pkg);
|
||||||
|
6
obj.c
6
obj.c
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* obj.c - Object definition model
|
* obj.c - Object definition model
|
||||||
*
|
*
|
||||||
* Written 2009-2011 by Werner Almesberger
|
* Written 2009-2012 by Werner Almesberger
|
||||||
* Copyright 2009-2011 by Werner Almesberger
|
* Copyright 2009-2012 by Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* 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) {
|
if (frame == frames) {
|
||||||
s = expand(pkg_name, frame);
|
s = expand(pkg_name, frame);
|
||||||
/* s is NULL if expansion failed */
|
/* s is NULL if expansion failed */
|
||||||
inst_select_pkg(s ? s : "_");
|
inst_select_pkg(s ? s : "_", active);
|
||||||
free(s);
|
free(s);
|
||||||
}
|
}
|
||||||
inst_begin_active(active && frame == active_frame);
|
inst_begin_active(active && frame == active_frame);
|
||||||
|
Loading…
Reference in New Issue
Block a user