Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2010-06-21 11:51:40 +0400
committerDalai Felinto <dfelinto@gmail.com>2010-06-21 11:51:40 +0400
commit3f4121cea5d10b76fac30f4fc60390f0d5e8ad20 (patch)
tree31dd05d6e2cfcddfeafc21880a0df33be04db9f2 /source
parent78d3793d31b380fcddbdcb3cc1ee932d68f60937 (diff)
Logic UI: Pin option for sensor and actuators (from 2.49)
- implemented the old functionality of pin a sensor or actuator when "show state" is on. - fixed code for setting/resetting VISIBLE and LINKED flags for sensors and actuators (so states buttons is working for actuators and sensors) - move the flag setting code (^^^) to a pre-processing part of the logic ui code.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_logic/logic_window.c57
-rw-r--r--source/blender/makesrna/intern/rna_actuator.c6
-rw-r--r--source/blender/makesrna/intern/rna_sensor.c6
-rw-r--r--source/blender/makesrna/intern/rna_space.c4
4 files changed, 53 insertions, 20 deletions
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index 104bcc6286d..b34a5d4ef3e 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -3172,7 +3172,7 @@ static int is_sensor_linked(uiBlock *block, bSensor *sens)
/* Sensors code */
-static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr)
+static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *logic_ptr)
{
uiLayout *box, *row;
@@ -3182,6 +3182,11 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr)
uiItemR(row, ptr, "expanded", UI_ITEM_R_NO_BG, "", 0);
uiItemR(row, ptr, "type", 0, "", 0);
uiItemR(row, ptr, "name", 0, "", 0);
+
+ // XXX in 2.49 we make the pin to dis/appear. In 2.50 may be better to simply enable/disable it
+ if (RNA_boolean_get(logic_ptr, "sensors_show_active_states") && (RNA_boolean_get(ptr, "expanded") || RNA_boolean_get(ptr, "pinned")))
+ uiItemR(row, ptr, "pinned", UI_ITEM_R_NO_BG, "", 0);
+
uiItemO(row, "", ICON_X, "LOGIC_OT_sensor_remove");
}
@@ -3584,7 +3589,7 @@ void draw_brick_controller(uiLayout *layout, PointerRNA *ptr)
}
/* Actuator code */
-static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr)
+static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *logic_ptr)
{
uiLayout *box, *row;
@@ -3594,6 +3599,11 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr)
uiItemR(row, ptr, "expanded", UI_ITEM_R_NO_BG, "", 0);
uiItemR(row, ptr, "type", 0, "", 0);
uiItemR(row, ptr, "name", 0, "", 0);
+
+ // XXX in 2.49 we make the pin to dis/appear. In 2.50 may be better to simply enable/disable it
+ if (RNA_boolean_get(logic_ptr, "actuators_show_active_states") && (RNA_boolean_get(ptr, "expanded") || RNA_boolean_get(ptr, "pinned")))
+ uiItemR(row, ptr, "pinned", UI_ITEM_R_NO_BG, "", 0);
+
uiItemO(row, "", ICON_X, "LOGIC_OT_actuator_remove");
}
@@ -4367,13 +4377,17 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
block= uiBeginBlock(C, ar, name, UI_EMBOSS);
uiBlockSetHandleFunc(block, do_logic_buts, NULL);
- /* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that
- we can determine which is actually linked/visible */
+ /* loop over all objects and set visible/linked flags for the logic bricks */
for(a=0; a<count; a++) {
bActuator *act;
bSensor *sens;
+ bController *cont;
+ int iact;
+ short flag;
+
ob= (Object *)idar[a];
+ /* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that we can determine which is actually linked/visible */
act = ob->actuators.first;
while(act) {
act->flag &= ~(ACT_LINKED|ACT_VISIBLE);
@@ -4385,6 +4399,23 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
sens->flag &= ~(SENS_VISIBLE);
sens = sens->next;
}
+
+ /* mark the linked and visible actuators */
+ cont= ob->controllers.first;
+ while(cont) {
+ flag = ACT_LINKED;
+
+ /* this controller is visible, mark all its actuator */
+ if ((ob->scaflag & OB_ALLSTATE) || (ob->state & cont->state_mask))
+ flag |= ACT_VISIBLE;
+
+ for (iact=0; iact<cont->totlinks; iact++) {
+ act = cont->links[iact];
+ if (act)
+ act->flag |= flag;
+ }
+ cont = cont->next;
+ }
}
/* ****************** Controllers ****************** */
@@ -4452,16 +4483,6 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
if (!(ob->scaflag & OB_ALLSTATE) && !(ob->state & cont->state_mask))
continue;
- //if (!(cont->state_mask & (1<<stbit)))
- // continue;
-
- /* this controller is visible, mark all its actuator */
- /* XXX: perhaps move this to a preprocessing stage if possible? */
- for (iact=0; iact<cont->totlinks; iact++) {
- bActuator *act = cont->links[iact];
- if (act)
- act->flag |= ACT_VISIBLE;
- }
/* use two nested splits to align inlinks/links properly */
split = uiLayoutSplit(layout, 0.05, 0);
@@ -4526,7 +4547,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
RNA_pointer_create((ID *)ob, &RNA_Sensor, sens, &ptr);
if ((ob->scaflag & OB_ALLSTATE) ||
- (slogic->scaflag & BUTS_SENS_STATE) ||
+ !(slogic->scaflag & BUTS_SENS_STATE) ||
(sens->totlinks == 0) || /* always display sensor without links so that is can be edited */
(sens->flag & SENS_PIN && slogic->scaflag & BUTS_SENS_STATE) || /* states can hide some sensors, pinned sensors ignore the visible state */
(is_sensor_linked(block, sens))
@@ -4539,7 +4560,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
uiLayoutSetContextPointer(col, "sensor", &ptr);
/* should make UI template for sensor header.. function will do for now */
- draw_sensor_header(col, &ptr);
+ draw_sensor_header(col, &ptr, &logic_ptr);
/* draw the brick contents */
draw_brick_sensor(col, &ptr, C);
@@ -4586,7 +4607,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
RNA_pointer_create((ID *)ob, &RNA_Actuator, act, &ptr);
if ((ob->scaflag & OB_ALLSTATE) ||
- (slogic->scaflag & BUTS_ACT_STATE) ||
+ !(slogic->scaflag & BUTS_ACT_STATE) ||
!(act->flag & ACT_LINKED) || /* always display actuators without links so that is can be edited */
(act->flag & ACT_VISIBLE) || /* this actuator has visible connection, display it */
(act->flag & ACT_PIN && slogic->scaflag & BUTS_ACT_STATE) /* states can hide some sensors, pinned sensors ignore the visible state */
@@ -4604,7 +4625,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
uiLayoutSetContextPointer(col, "actuator", &ptr);
/* should make UI template for actuator header.. function will do for now */
- draw_actuator_header(col, &ptr);
+ draw_actuator_header(col, &ptr, &logic_ptr);
/* draw the brick contents */
draw_brick_actuator(col, &ptr, C);
diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c
index 2ca327f8907..2a29f3332b5 100644
--- a/source/blender/makesrna/intern/rna_actuator.c
+++ b/source/blender/makesrna/intern/rna_actuator.c
@@ -476,6 +476,12 @@ void rna_def_actuator(BlenderRNA *brna)
RNA_def_property_enum_funcs(prop, NULL, "rna_Actuator_type_set", "rna_Actuator_type_itemf");
RNA_def_property_ui_text(prop, "Type", "");
+ prop= RNA_def_property(srna, "pinned", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_PIN);
+ RNA_def_property_ui_text(prop, "Pinned", "Display when not linked to a visible states controller");
+ RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ACT_SHOW);
RNA_def_property_ui_text(prop, "Expanded", "Set actuator expanded in the user interface");
diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c
index 31fa8f018dc..17137d0d259 100644
--- a/source/blender/makesrna/intern/rna_sensor.c
+++ b/source/blender/makesrna/intern/rna_sensor.c
@@ -260,6 +260,12 @@ static void rna_def_sensor(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Type", "");
RNA_def_property_update(prop, NC_LOGIC, NULL);
+ prop= RNA_def_property(srna, "pinned", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_PIN);
+ RNA_def_property_ui_text(prop, "Pinned", "Display when not linked to a visible states controller");
+ RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1);
+ RNA_def_property_update(prop, NC_LOGIC, NULL);
+
prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SENS_SHOW);
RNA_def_property_ui_text(prop, "Expanded", "Set sensor expanded in the user interface");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 3058fe62e0f..774ae94d5f3 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2202,7 +2202,7 @@ static void rna_def_space_logic(BlenderRNA *brna)
RNA_def_property_update(prop, NC_LOGIC, NULL);
prop= RNA_def_property(srna, "sensors_show_active_states", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "scaflag", BUTS_SENS_STATE);
+ RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_SENS_STATE);
RNA_def_property_ui_text(prop, "Show Active States", "Show only sensors connected to active states");
RNA_def_property_update(prop, NC_LOGIC, NULL);
@@ -2239,7 +2239,7 @@ static void rna_def_space_logic(BlenderRNA *brna)
RNA_def_property_update(prop, NC_LOGIC, NULL);
prop= RNA_def_property(srna, "actuators_show_active_states", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_negative_sdna(prop, NULL, "scaflag", BUTS_ACT_STATE);
+ RNA_def_property_boolean_sdna(prop, NULL, "scaflag", BUTS_ACT_STATE);
RNA_def_property_ui_text(prop, "Show Active States", "Show only actuators connected to active states");
RNA_def_property_update(prop, NC_LOGIC, NULL);