[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28586] trunk/blender/source/blender: Logic Editor UI work
Matt Ebb
matt at mke3.net
Wed May 5 02:12:31 CEST 2010
Revision: 28586
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28586
Author: broken
Date: 2010-05-05 02:12:31 +0200 (Wed, 05 May 2010)
Log Message:
-----------
Logic Editor UI work
* Re-structured code (can delete the old function entirely when this is done)
* Fixed links/inlinks
* Fixed some bugs in add and remove controller/actuator
* Cleaned up some ui layouts
* Use key event types in keyboard sensor
* Implemented object controller 'state' in RNA/layout engine (still needs tweaks)
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_logic/logic_ops.c
trunk/blender/source/blender/editors/space_logic/logic_window.c
trunk/blender/source/blender/makesdna/DNA_object_types.h
trunk/blender/source/blender/makesdna/DNA_space_types.h
trunk/blender/source/blender/makesrna/intern/rna_object.c
trunk/blender/source/blender/makesrna/intern/rna_sensor.c
trunk/blender/source/blender/makesrna/intern/rna_space.c
Modified: trunk/blender/source/blender/editors/space_logic/logic_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_logic/logic_ops.c 2010-05-04 22:05:41 UTC (rev 28585)
+++ trunk/blender/source/blender/editors/space_logic/logic_ops.c 2010-05-05 00:12:31 UTC (rev 28586)
@@ -306,6 +306,7 @@
return OPERATOR_CANCELLED;
BLI_remlink(&(ob->controllers), cont);
+ unlink_controller(cont);
free_controller(cont);
WM_event_add_notifier(C, NC_LOGIC, NULL);
@@ -344,12 +345,27 @@
Object *ob = ED_object_active_context(C);
bController *cont;
int type= RNA_enum_get(op->ptr, "type");
-
+ int bit;
+
cont= new_controller(type);
BLI_addtail(&(ob->controllers), cont);
make_unique_prop_names(C, cont->name);
+
+ /* set the controller state mask from the current object state.
+ A controller is always in a single state, so select the lowest bit set
+ from the object state */
+ for (bit=0; bit<OB_MAX_STATES; bit++) {
+ if (ob->state & (1<<bit))
+ break;
+ }
+ cont->state_mask = (1<<bit);
+ if (cont->state_mask == 0) {
+ /* shouldn't happen, object state is never 0 */
+ cont->state_mask = 1;
+ }
+
ob->scaflag |= OB_SHOWCONT;
-
+
WM_event_add_notifier(C, NC_LOGIC, NULL);
return OPERATOR_FINISHED;
@@ -390,6 +406,7 @@
return OPERATOR_CANCELLED;
BLI_remlink(&(ob->actuators), act);
+ unlink_actuator(act);
free_actuator(act);
WM_event_add_notifier(C, NC_LOGIC, NULL);
@@ -432,7 +449,7 @@
act= new_actuator(type);
BLI_addtail(&(ob->actuators), act);
make_unique_prop_names(C, act->name);
- ob->scaflag |= OB_SHOWCONT;
+ ob->scaflag |= OB_SHOWACT;
WM_event_add_notifier(C, NC_LOGIC, NULL);
Modified: trunk/blender/source/blender/editors/space_logic/logic_window.c
===================================================================
--- trunk/blender/source/blender/editors/space_logic/logic_window.c 2010-05-04 22:05:41 UTC (rev 28585)
+++ trunk/blender/source/blender/editors/space_logic/logic_window.c 2010-05-05 00:12:31 UTC (rev 28586)
@@ -3187,21 +3187,22 @@
static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr)
{
- uiLayout *box, *row;
+ uiLayout *box, *split, *row;
box= uiLayoutBox(layout);
- row= uiLayoutRow(box, 0);
-
- if (!RNA_boolean_get(ptr, "expanded"))
- return;
-
- row= uiLayoutRow(box, 0);
+ split = uiLayoutSplit(box, 0.45, 0);
+
+ row= uiLayoutRow(split, 1);
uiItemR(row, ptr, "pulse_true_level", 0, "", ICON_DOTSUP);
uiItemR(row, ptr, "pulse_false_level", 0, "", ICON_DOTSDOWN);
- uiItemR(row, ptr, "frequency", 0, "", 0);
- uiItemR(row, ptr, "level", 0, "", 0);
- uiItemR(row, ptr, "tap", 0, "", 0);
- uiItemR(row, ptr, "invert", 0, "", 0);
+ uiItemR(row, ptr, "frequency", 0, "Freq", 0);
+
+ row= uiLayoutRow(split, 1);
+ uiItemR(row, ptr, "level", UI_ITEM_R_TOGGLE, NULL, 0);
+ uiItemR(row, ptr, "tap", UI_ITEM_R_TOGGLE, NULL, 0);
+
+ row= uiLayoutRow(split, 1);
+ uiItemR(row, ptr, "invert", UI_ITEM_R_TOGGLE, "Invert", 0);
}
/* sensors in alphabetical order */
@@ -3290,10 +3291,21 @@
static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr)
{
- uiItemR(layout, ptr, "key", 0, NULL, 0);
+ uiLayout *row;
+
+ row = uiLayoutRow(layout, 0);
+ uiItemL(row, "Key:", 0);
+ uiItemR(row, ptr, "key", UI_ITEM_R_EVENT, "", 0);
uiItemR(layout, ptr, "all_keys", 0, NULL, 0);
- uiItemR(layout, ptr, "modifier_key", 0, NULL, 0);
- uiItemR(layout, ptr, "second_modifier_key", 0, NULL, 0);
+
+ row = uiLayoutRow(layout, 0);
+ uiItemL(row, "First Modifier:", 0);
+ uiItemR(row, ptr, "modifier_key", UI_ITEM_R_EVENT, "", 0);
+
+ row = uiLayoutRow(layout, 0);
+ uiItemL(row, "Second Modifier:", 0);
+ uiItemR(row, ptr, "second_modifier_key", UI_ITEM_R_EVENT, "", 0);
+
uiItemR(layout, ptr, "target", 0, NULL, 0);
uiItemR(layout, ptr, "log", 0, NULL, 0);
@@ -3387,11 +3399,11 @@
if (!RNA_boolean_get(ptr, "expanded"))
return;
+
+ draw_sensor_internal_header(layout, ptr);
box = uiLayoutBox(layout);
- draw_sensor_internal_header(box, ptr);
-
switch (RNA_enum_get(ptr, "type")) {
case SENS_ACTUATOR:
@@ -3850,42 +3862,38 @@
}
}
-void logic_buttons(bContext *C, ARegion *ar)
+static void logic_buttons_new(bContext *C, ARegion *ar)
{
SpaceLogic *slogic= CTX_wm_space_logic(C);
Object *ob= CTX_data_active_object(C);
ID **idar;
- bSensor *sens;
- bController *cont;
- bActuator *act;
+
+ PointerRNA logic_ptr;
+
+ uiLayout *layout, *row;
uiBlock *block;
uiBut *but;
- uiLayout *layout, *row;
- PointerRNA logic_ptr;
- int a, iact, stbit, offset;
- int xco, yco, width, ycoo;
- short count;
char name[32];
- /* pin is a bool used for actuator and sensor drawing with states
- * pin so changing states dosnt hide the logic brick */
- char pin;
-
+ short a, count;
+ int xco, yco, width;
+
if(ob==NULL) return;
-// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
-
+
+ RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr);
+ idar= get_selected_and_linked_obs(C, &count, slogic->scaflag);
+
sprintf(name, "buttonswin %p", ar);
block= uiBeginBlock(C, ar, name, UI_EMBOSS);
uiBlockSetHandleFunc(block, do_logic_buts, NULL);
-
- RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr);
- idar= get_selected_and_linked_obs(C, &count, slogic->scaflag);
-
/* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that
- we can determine which is actually linked/visible */
+ we can determine which is actually linked/visible */
for(a=0; a<count; a++) {
+ bActuator *act;
+ bSensor *sens;
ob= (Object *)idar[a];
- act= ob->actuators.first;
+
+ act = ob->actuators.first;
while(act) {
act->flag &= ~(ACT_LINKED|ACT_VISIBLE);
act = act->next;
@@ -3897,14 +3905,10 @@
sens = sens->next;
}
}
-
- /* start with the controller because we need to know which one is visible */
- /* ******************************* */
- xco= 400; yco= 170; width= 300;
-
-
- if (G.rt >0) { // new UI code to replace old one
+ /* ****************** Controllers ****************** */
+
+ xco= 420; yco= 170; width= 300;
layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, U.uistyles.first);
row = uiLayoutRow(layout, 1);
@@ -3914,60 +3918,35 @@
uiItemR(row, &logic_ptr, "controllers_show_active_objects", 0, "Act", 0);
uiItemR(row, &logic_ptr, "controllers_show_linked_controller", 0, "Link", 0);
-
-
- /* State part - ugly */
- if(ob->scaflag & OB_SHOWCONT) {
- unsigned int controller_state_mask = 0; /* store a bitmask for states that are used */
-
- /* first show the state */
- uiDefBlockBut(block, object_state_mask_menu, ob, "State", (short)(xco-10), (short)(yco-10), 36, UI_UNIT_Y, "Object state menu: store and retrieve initial state");
-
- if (!ob->state)
- ob->state = 1;
- for (offset=0; offset<15; offset+=5) {
- uiBlockBeginAlign(block);
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset), stbit+offset, "", (short)(xco+31+12*stbit+13*offset), yco, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset)));
- uiButSetFunc(but, check_state_mask, but, &(ob->state));
- }
- for (stbit=0; stbit<5; stbit++) {
- but = uiDefButBitI(block, controller_state_mask&(1<<(stbit+offset+15)) ? BUT_TOGDUAL:TOG, 1<<(stbit+offset+15), stbit+offset+15, "", (short)(xco+31+12*stbit+13*offset), yco-12, 12, 12, (int *)&(ob->state), 0, 0, 0, 0, get_state_name(ob, (short)(stbit+offset+15)));
- uiButSetFunc(but, check_state_mask, but, &(ob->state));
- }
- }
+ {
+ PointerRNA settings_ptr;
+ row = uiLayoutRow(layout, 0);
+ RNA_pointer_create(NULL, &RNA_GameObjectSettings, ob, &settings_ptr);
+ uiItemR(row, &logic_ptr, "controllers_show_initial_state", UI_ITEM_R_NO_BG, "", 0);
+ uiTemplateLayers(row, &settings_ptr, "state", &settings_ptr, "used_state", 0);
+
uiBlockBeginAlign(block);
- uiDefButBitS(block, TOG, OB_SETSTBIT, B_SET_STATE_BIT, "All",(short)(xco+226), yco-10, 22, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Set all state bits");
- uiDefButBitS(block, TOG, OB_INITSTBIT, B_INIT_STATE_BIT, "Ini",(short)(xco+248), yco-10, 22, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Set the initial state");
- uiDefButBitS(block, TOG, OB_DEBUGSTATE, 0, "D",(short)(xco+270), yco-10, 15, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Print state debug info");
+ uiDefButBitS(block, TOG, OB_SETSTBIT, B_SET_STATE_BIT, "All", 0, 0, UI_UNIT_X, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Set all state bits");
+ uiDefButBitS(block, TOG, OB_DEBUGSTATE, 0, "D", 0, 0, UI_UNIT_X, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Print state debug info");
uiBlockEndAlign(block);
-
- yco-=35;
-
- /* display only the controllers that match the current state */
- offset = 0;
- for (stbit=0; stbit<32; stbit++) {
- if (!(ob->state & (1<<stbit)))
- continue;
- /* add a separation between controllers of different states */
- if (offset) {
- offset = 0;
- yco -= 6;
- }
-
- //draw controller
+
+ if (RNA_boolean_get(&logic_ptr, "controllers_show_initial_state")) {
+ row = uiLayoutRow(layout, 0);
+ uiItemL(row, "Initial State:", 0);
+ uiTemplateLayers(row, &settings_ptr, "initial_state", &settings_ptr, "used_state", 0);
}
}
-// cont= ob->controllers.first;
- /* draw individual controllers*/
row = uiLayoutRow(layout, 1);
uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide controllers");
uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0);
for(a=0; a<count; a++) {
+ bController *cont;
PointerRNA ptr;
- uiLayout *split, *col;
+ uiLayout *split, *subsplit, *col;
+ int iact;
+
ob= (Object *)idar[a];
if (!(ob->scavisflag & OB_VIS_CONT) || !(ob->scaflag & OB_SHOWCONT)) continue;
@@ -3976,19 +3955,33 @@
for(cont= ob->controllers.first; cont; cont=cont->next) {
RNA_pointer_create(&ob->id, &RNA_Controller, cont, &ptr);
-
-// if (!(cont->state_mask & (1<<stbit)))
-// continue;
-
+
+ if (!(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++) {
- act = cont->links[iact];
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list