Hello to everyone who reads this.

I am a novice/intermediate programmer and I am trying to figure out how to add 
a side panel/properties panel to the outliner. I have looked through the 
functions in the other editor code(e.g. bf_editor_space_graph), and also I have 
searched through the blame history to see if I can piece together how the other 
programmers have created properties panels. I just can't seem to find anything 
other than what I have below.


If anyone would be cool enough to show me what I am missing, what other 
functions should I be investigating, that would be...... cool! 


Below is a .diff file showing the code that I have pieced together so far. I 
just really really want to know the missing pieces!!! THANKS!!!


====================================================

diff --git a/source/blender/editors/space_outliner/CMakeLists.txt 
b/source/blender/editors/space_outliner/CMakeLists.txt
index b716f06..3622bb0 100644
--- a/source/blender/editors/space_outliner/CMakeLists.txt
+++ b/source/blender/editors/space_outliner/CMakeLists.txt
@@ -36,8 +36,9 @@ set(INC_SYS
        ${GLEW_INCLUDE_PATH}
 )
 
 set(SRC
+       outliner_buttons.c
        outliner_draw.c
        outliner_edit.c
        outliner_ops.c
        outliner_select.c
diff --git a/source/blender/editors/space_outliner/outliner_buttons.c 
b/source/blender/editors/space_outliner/outliner_buttons.c
new file mode 100644
index 0000000..027e3eb
--- /dev/null
+++ b/source/blender/editors/space_outliner/outliner_buttons.c
@@ -0,0 +1,177 @@
+/*
+* ***** BEGIN GPL LICENSE BLOCK *****
+*
+* 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 the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* The Original Code is Copyright (C) 2004 Blender Foundation.
+* All rights reserved.
+*
+* The Original Code is: all of this file.
+*
+* Contributor(s): Joshua Leung
+*
+* ***** END GPL LICENSE BLOCK *****
+*/
+
+/** \file blender/editors/space_outliner/outliner_buttons.c
+*  \ingroup spoutliner
+*/
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+#include <float.h>
+#include "MEM_guardedalloc.h"
+
+#include "DNA_anim_types.h"
+#include "DNA_armature_types.h"
+#include "DNA_group_types.h"
+#include "DNA_lamp_types.h"
+#include "DNA_material_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meta_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_sequence_types.h"
+#include "DNA_world_types.h"
+#include "DNA_object_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+#include "BLI_ghash.h"
+
+#include "BLF_translation.h"
+
+#include "BKE_animsys.h"
+#include "BKE_context.h"
+#include "BKE_depsgraph.h"
+#include "BKE_fcurve.h"
+#include "BKE_group.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_report.h"
+#include "BKE_scene.h"
+#include "BKE_sequencer.h"
+
+#include "BKE_screen.h"
+
+
+#include "ED_armature.h"
+#include "ED_object.h"
+#include "ED_screen.h"
+#include "ED_sequencer.h"
+#include "ED_util.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "UI_interface.h"
+#include "UI_view2d.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_enum_types.h"
+
+#include "UI_resources.h"
+
+#include "outliner_intern.h"
+
+enum etest {
+       GRAPHKE_SNAP_CFRA = 1,
+       GRAPHKE_SNAP_NEAREST_FRAME,
+       GRAPHKE_SNAP_NEAREST_SECOND,
+       GRAPHKE_SNAP_NEAREST_MARKER,
+       GRAPHKE_SNAP_HORIZONTAL,
+       GRAPHKE_SNAP_VALUE,
+};
+
+
+/* Graph Editor View Settings */
+static void outliner_panel_view(const bContext *C, Panel *pa)
+{
+       bScreen *sc = CTX_wm_screen(C);
+       SpaceOops *sout = CTX_wm_space_outliner(C);
+       Scene *scene = CTX_data_scene(C);
+       PointerRNA spaceptr, sceneptr;
+       uiLayout *col, *sub, *row;
+
+       /* get RNA pointers for use when creating the UI elements */
+       RNA_id_pointer_create(&scene->id, &sceneptr);
+       RNA_pointer_create(&sc->id, &RNA_SpaceOutliner, sout, &spaceptr);
+
+       /* 2D-Cursor */
+       col = uiLayoutColumn(pa->layout, false);
+       uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE);
+
+       sub = uiLayoutColumn(col, true);
+       uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
+       uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, 
"GRAPH_OT_frame_jump");
+
+       sub = uiLayoutColumn(col, true);
+       uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
+       row = uiLayoutSplit(sub, 0.7f, true);
+       uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), 
ICON_NONE);
+       uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", 
GRAPHKE_SNAP_CFRA);
+
+       row = uiLayoutSplit(sub, 0.7f, true);
+       uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), 
ICON_NONE);
+       uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", 
GRAPHKE_SNAP_VALUE);
+}
+
+
+
+
+
+
+
+
+
+/* ******************* general ******************************** */
+void outliner_buttons_register(ARegionType *art)
+{
+       PanelType *pt;
+
+       pt = MEM_callocN(sizeof(PanelType), "spacetype outliner panel view");
+       strcpy(pt->idname, "OUTLINER_PT_view");
+       strcpy(pt->label, N_("View Properties"));
+       strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
+       pt->draw = outliner_panel_view;
+       pt->flag |= PNL_DEFAULT_CLOSED;
+       BLI_addtail(&art->paneltypes, pt);
+
+
+}
+
+static int outliner_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       ScrArea *sa = CTX_wm_area(C);
+       ARegion *ar = outliner_has_buttons_region(sa);
+
+       if (ar)
+               ED_region_toggle_hidden(C, ar);
+
+       return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_properties(wmOperatorType *ot)
+{
+       ot->name = "Properties";
+       ot->idname = "OUTLINER_OT_properties";
+       ot->description = "Toggle display properties panel";
+
+       ot->exec = outliner_properties_toggle_exec;
+       ot->poll = ED_operator_outliner_active;
+
+       /* flags */
+       ot->flag = 0;
+}
\ No newline at end of file
diff --git a/source/blender/editors/space_outliner/outliner_intern.h 
b/source/blender/editors/space_outliner/outliner_intern.h
index 24842d2..12377b3 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -163,8 +163,13 @@ typedef enum {
 
 /* is the currrent element open? if so we also show children */
 #define TSELEM_OPEN(telm, sv)    ( (telm->flag & TSE_CLOSED) == 0 || 
(SEARCHING_OUTLINER(sv) && (telm->flag & TSE_CHILDSEARCH)) )
 
+/* space_outliner.c -----------------------------------------------*/
+
+struct ARegion *outliner_has_buttons_region(struct ScrArea *sa);
+
+
 /* outliner_tree.c ----------------------------------------------- */
 
 void outliner_free_tree(ListBase *lb);
 void outliner_cleanup_tree(struct SpaceOops *soops);
@@ -258,8 +263,13 @@ void OUTLINER_OT_action_set(struct wmOperatorType *ot);
 void OUTLINER_OT_constraint_operation(struct wmOperatorType *ot);
 void OUTLINER_OT_modifier_operation(struct wmOperatorType *ot);
 /* ---------------------------------------------------------------- */
 
+/* outliner_buttons.c -------------------------------------------- */
+
+void OUTLINER_OT_properties(struct wmOperatorType *ot);
+void outliner_buttons_register(struct ARegionType *art);
+
 /* outliner_ops.c */
 void outliner_operatortypes(void);
 void outliner_keymap(struct wmKeyConfig *keyconf);
 
diff --git a/source/blender/editors/space_outliner/outliner_ops.c 
b/source/blender/editors/space_outliner/outliner_ops.c
index f586957..1b78152 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -42,8 +42,9 @@
 /* ************************** registration **********************************/
 
 void outliner_operatortypes(void)
 {
+       WM_operatortype_append(OUTLINER_OT_properties);
        WM_operatortype_append(OUTLINER_OT_item_activate);
        WM_operatortype_append(OUTLINER_OT_select_border);
        WM_operatortype_append(OUTLINER_OT_item_openclose);
        WM_operatortype_append(OUTLINER_OT_item_rename);
@@ -88,8 +89,10 @@ void outliner_keymap(wmKeyConfig *keyconf)
 {
        wmKeyMap *keymap = WM_keymap_find(keyconf, "Outliner", SPACE_OUTLINER, 
0);
        wmKeyMapItem *kmi;
        
+       WM_keymap_add_item(keymap, "OUTLINER_OT_properties", NKEY, KM_PRESS, 0, 
0);
+       
        WM_keymap_add_item(keymap, "OUTLINER_OT_item_rename", LEFTMOUSE, 
KM_DBL_CLICK, 0, 0);
 
        kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", 
LEFTMOUSE, KM_CLICK, 0, 0);
        RNA_boolean_set(kmi->ptr, "recursive", false);
diff --git a/source/blender/editors/space_outliner/space_outliner.c 
b/source/blender/editors/space_outliner/space_outliner.c
index 7b1ec17..46ff57a 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -61,8 +61,34 @@
 
 
 #include "outliner_intern.h"
 
+/* ******************** manage regions ********************* */
+
+ARegion *outliner_has_buttons_region(ScrArea *sa)
+{
+       ARegion *ar, *arnew;
+
+       ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
+       if (ar) return ar;
+
+       /* add subdiv level; after main */
+       ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
+
+       /* is error! */
+       if (ar == NULL) return NULL;
+
+       arnew = MEM_callocN(sizeof(ARegion), "buttons for outliner");
+
+       BLI_insertlinkafter(&sa->regionbase, ar, arnew);
+       arnew->regiontype = RGN_TYPE_UI;
+       arnew->alignment = RGN_ALIGN_RIGHT;
+
+       arnew->flag = RGN_FLAG_HIDDEN;
+
+       return arnew;
+}
+
 static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
        ListBase *lb;
        wmKeyMap *keymap;
@@ -444,8 +470,17 @@ static SpaceLink *outliner_new(const bContext *UNUSED(C))
        BLI_addtail(&soutliner->regionbase, ar);
        ar->regiontype = RGN_TYPE_HEADER;
        ar->alignment = RGN_ALIGN_BOTTOM;
        
+       /* ui buttons */
+       ar = MEM_callocN(sizeof(ARegion), "buttons area for outlineredit");
+
+       BLI_addtail(&soutliner->regionbase, ar);
+       ar->regiontype = RGN_TYPE_UI;
+       ar->alignment = RGN_ALIGN_RIGHT;
+       ar->flag = RGN_FLAG_HIDDEN;
+
+
        /* main area */
        ar = MEM_callocN(sizeof(ARegion), "main area for outliner");
        
        BLI_addtail(&soutliner->regionbase, ar);
@@ -485,8 +520,86 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl)
        
        return (SpaceLink *)soutlinern;
 }
 
+
+static void outliner_buttons_area_init(wmWindowManager *wm, ARegion *ar)
+{
+       wmKeyMap *keymap;
+       
+               ED_region_panels_init(wm, ar);
+       
+               keymap = WM_keymap_find(wm->defaultconf, "Outliner Editor 
Generic", SPACE_OUTLINER, 0);
+       WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, 
&ar->winrct);
+}
+
+
+static void outliner_buttons_area_draw(const bContext *C, ARegion *ar)
+{
+       ED_region_panels(C, ar, 1, NULL, -1);
+}
+
+//These case statements are cut-and-paste and they need to be looked over
+static void outliner_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), 
ARegion *ar, wmNotifier *wmn)
+{
+       //ED_region_tag_redraw(ar);//None of the other ED_region_tag_redraw() 
are called for now...
+               /* context changes */
+               switch (wmn->category) {
+               case NC_ANIMATION:
+                       ED_region_tag_redraw(ar);
+                       break;
+                       case NC_SCENE:
+                               switch (wmn->data) {
+                                       case ND_RENDER_OPTIONS:
+                                               case ND_OB_ACTIVE:
+                                                       case ND_FRAME:
+                                                               case ND_MARKERS:
+                                                                       
ED_region_tag_redraw(ar);
+                                                                       break;
+                                                                       case 
ND_SEQUENCER:
+                                                                               
if (wmn->action == NA_SELECTED)
+                                                                               
                ED_region_tag_redraw(ar);
+                                                                               
break;
+                                                                               
+                               }
+                               break;
+                               case NC_OBJECT:
+                                       switch (wmn->data) {
+                                               case ND_BONE_ACTIVE:
+                                                       case ND_BONE_SELECT:
+                                                               case ND_KEYS:
+                                                                       
ED_region_tag_redraw(ar);
+                                                                       break;
+                                                                       case 
ND_MODIFIER:
+                                                                               
if (wmn->action == NA_RENAME)
+                                                                               
                ED_region_tag_redraw(ar);
+                                                                               
break;
+                                                                               
+                                       }
+                                       break;
+                                       case NC_NODE:
+                                               switch (wmn->action) {
+                                                       case NA_EDITED:
+                                                               case 
NA_SELECTED:
+                                                                       
ED_region_tag_redraw(ar);
+                                                                       break;
+                                                                       
+                                               }
+                                               break;
+                                               case NC_ID:
+                                                       if (wmn->action == 
NA_RENAME)
+                                                                       
ED_region_tag_redraw(ar);
+                                                       break;
+                                                       default:
+                                                               if (wmn->data 
== ND_KEYS)
+                                                                               
ED_region_tag_redraw(ar);
+                                                               break;
+                                                               
+                                                                       
+       }
+}
+
+
 /* only called once, from space_api/spacetypes.c */
 void ED_spacetype_outliner(void)
 {
        SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time");
@@ -525,7 +638,21 @@ void ED_spacetype_outliner(void)
        art->free = outliner_header_area_free;
        art->listener = outliner_header_area_listener;
        BLI_addhead(&st->regiontypes, art);
        
+       /* regions: UI buttons */
+       art = MEM_callocN(sizeof(ARegionType), "spacetype outliner region");
+       art->regionid = RGN_TYPE_UI;
+       art->prefsizex = 200;
+       art->keymapflag = ED_KEYMAP_UI;
+       art->init = outliner_buttons_area_init;
+       art->draw = outliner_buttons_area_draw;
+       art->listener = outliner_region_listener;
+
+       BLI_addhead(&st->regiontypes, art);
+       
+       outliner_buttons_register(art);
+
+
        BKE_spacetype_register(st);
 }
 









---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
Bf-committers mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-committers

Reply via email to