Logic Editor UI: Make the Active object always the first one of the list, and have...
authorDalai Felinto <dfelinto@gmail.com>
Tue, 13 Jul 2010 09:29:02 +0000 (09:29 +0000)
committerDalai Felinto <dfelinto@gmail.com>
Tue, 13 Jul 2010 09:29:02 +0000 (09:29 +0000)
The reason for that is because I can't find a way to change the active object for a particular context (it may be even a bug in the rna/UI base code). So for the time being (a.k.a. for Beta) this will make it.

I actually like this solution, maybe the bug is for the good afterall.

source/blender/editors/space_logic/logic_window.c

index 4ab2511fcd2f3615c1dc0afa999e7c97f8b901b7..1d8100be1b076a50c8f89a15354b8c20066f4e20 100644 (file)
@@ -912,8 +912,15 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf
        
        ob= G.main->object.first;
        nr= 0;
+
+       /* make the active object always the first one of the list */
+       if (obact) {
+               idar[0]= (ID *)obact;
+               nr++;
+       }
+
        while(ob) {
-               if( ob->scavisflag ) {
+               if( (ob->scavisflag) && (ob != obact)) {
                        idar[nr]= (ID *)ob;
                        nr++;
                }
@@ -4377,6 +4384,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
 {
        SpaceLogic *slogic= CTX_wm_space_logic(C);
        Object *ob= CTX_data_active_object(C);
+       Object *act_ob= ob;
        ID **idar;
        
        PointerRNA logic_ptr, settings_ptr;
@@ -4470,7 +4478,8 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
 
                row = uiLayoutRow(split, 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);
+               if (ob == act_ob)
+                       uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0);
 
                if (RNA_boolean_get(&settings_ptr, "show_state_panel")) {
 
@@ -4563,7 +4572,8 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
 
                row = uiLayoutRow(layout, 1);
                uiDefButBitS(block, TOG, OB_SHOWSENS, 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 sensors");
-               uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", 0);
+               if (ob == act_ob)
+                       uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", 0);
                
                if ((ob->scaflag & OB_SHOWSENS) == 0) continue;
                
@@ -4628,7 +4638,8 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
 
                row = uiLayoutRow(layout, 1);
                uiDefButBitS(block, TOG, OB_SHOWACT, 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 actuators");
-               uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", 0);
+               if (ob == act_ob)
+                       uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", 0);
 
                if ((ob->scaflag & OB_SHOWACT) == 0) continue;