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
diff options
context:
space:
mode:
-rw-r--r--release/scripts/startup/bl_ui/__init__.py1
-rw-r--r--release/scripts/startup/bl_ui/space_properties.py46
-rw-r--r--source/blender/editors/space_buttons/CMakeLists.txt1
-rw-r--r--source/blender/editors/space_buttons/buttons_header.c140
-rw-r--r--source/blender/editors/space_buttons/buttons_intern.h3
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c19
-rw-r--r--source/blender/makesrna/intern/rna_space.c109
7 files changed, 144 insertions, 175 deletions
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index 868fa2a311c..594f724c6e3 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -68,6 +68,7 @@ _modules = [
"space_nla",
"space_node",
"space_outliner",
+ "space_properties",
"space_sequencer",
"space_text",
"space_time",
diff --git a/release/scripts/startup/bl_ui/space_properties.py b/release/scripts/startup/bl_ui/space_properties.py
new file mode 100644
index 00000000000..758713b5cc4
--- /dev/null
+++ b/release/scripts/startup/bl_ui/space_properties.py
@@ -0,0 +1,46 @@
+# ##### 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.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+import bpy
+from bpy.types import Header
+
+
+class PROPERTIES_HT_header(Header):
+ bl_space_type = 'PROPERTIES'
+
+ def draw(self, context):
+ layout = self.layout
+
+ view = context.space_data
+
+ row = layout.row()
+ row.template_header(menus=False)
+ row.prop(view, "context", expand=True, icon_only=True)
+
+
+def register():
+ bpy.utils.register_module(__name__)
+
+
+def unregister():
+ bpy.utils.unregister_module(__name__)
+
+
+if __name__ == "__main__":
+ register()
diff --git a/source/blender/editors/space_buttons/CMakeLists.txt b/source/blender/editors/space_buttons/CMakeLists.txt
index b20301cfc3b..9e045a39a0c 100644
--- a/source/blender/editors/space_buttons/CMakeLists.txt
+++ b/source/blender/editors/space_buttons/CMakeLists.txt
@@ -35,7 +35,6 @@ set(INC_SYS
set(SRC
buttons_context.c
- buttons_header.c
buttons_ops.c
buttons_texture.c
space_buttons.c
diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c
deleted file mode 100644
index 44c76d7a9a2..00000000000
--- a/source/blender/editors/space_buttons/buttons_header.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * ***** 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) 2008 Blender Foundation.
- * All rights reserved.
- *
- *
- * Contributor(s): Blender Foundation
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/editors/space_buttons/buttons_header.c
- * \ingroup spbuttons
- */
-
-
-#include <string.h>
-#include <stdio.h>
-
-#include "BLI_blenlib.h"
-#include "BLI_utildefines.h"
-
-#include "BLF_translation.h"
-
-#include "BKE_context.h"
-#include "BKE_modifier.h"
-#include "BKE_paint.h"
-#include "BKE_scene.h"
-
-#include "ED_buttons.h"
-#include "ED_screen.h"
-#include "ED_types.h"
-
-#include "DNA_brush_types.h"
-#include "DNA_object_force.h"
-#include "DNA_object_types.h"
-
-#include "UI_interface.h"
-#include "UI_resources.h"
-#include "UI_view2d.h"
-
-#include "buttons_intern.h"
-
-
-#define B_CONTEXT_SWITCH 101
-
-static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event)
-{
- SpaceButs *sbuts = CTX_wm_space_buts(C);
-
- if (!sbuts) /* editor type switch */
- return;
-
- switch (event) {
- case B_CONTEXT_SWITCH:
- ED_area_tag_redraw(CTX_wm_area(C));
-
- sbuts->preview = 1;
- break;
- }
-
- sbuts->mainbuser = sbuts->mainb;
-}
-
-#define BUT_UNIT_X (UI_UNIT_X + 2 * U.pixelsize)
-
-void buttons_header_buttons(const bContext *C, ARegion *ar)
-{
- SpaceButs *sbuts = CTX_wm_space_buts(C);
- uiBlock *block;
- uiBut *but;
- int headery = ED_area_headersize();
- int xco, yco = 0.5f * (headery - UI_UNIT_Y);
-
- buttons_context_compute(C, sbuts);
-
- block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
- uiBlockSetHandleFunc(block, do_buttons_buttons, NULL);
-
- xco = ED_area_header_switchbutton(C, block, yco);
-
- uiBlockSetEmboss(block, UI_EMBOSS);
-
- xco -= UI_UNIT_X;
-
- /* Default panels */
-
- uiBlockBeginAlign(block);
-
-#define BUTTON_HEADER_CTX(_ctx, _icon, _tip) \
- if (sbuts->pathflag & (1 << _ctx)) { \
- but = uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, _icon, xco += BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, \
- &(sbuts->mainb), 0.0, (float)_ctx, 0, 0, TIP_(_tip)); \
- uiButClearFlag(but, UI_BUT_UNDO); \
- } (void)0
-
- BUTTON_HEADER_CTX(BCONTEXT_RENDER, ICON_SCENE, N_("Render"));
- BUTTON_HEADER_CTX(BCONTEXT_RENDER_LAYER, ICON_RENDERLAYERS, N_("Render Layers"));
- BUTTON_HEADER_CTX(BCONTEXT_SCENE, ICON_SCENE_DATA, N_("Scene"));
- BUTTON_HEADER_CTX(BCONTEXT_WORLD, ICON_WORLD, N_("World"));
- BUTTON_HEADER_CTX(BCONTEXT_OBJECT, ICON_OBJECT_DATA, N_("Object"));
- BUTTON_HEADER_CTX(BCONTEXT_CONSTRAINT, ICON_CONSTRAINT, N_("Object Constraints"));
- BUTTON_HEADER_CTX(BCONTEXT_MODIFIER, ICON_MODIFIER, N_("Object Modifiers"));
- BUTTON_HEADER_CTX(BCONTEXT_DATA, sbuts->dataicon, N_("Object Data"));
- BUTTON_HEADER_CTX(BCONTEXT_BONE, ICON_BONE_DATA, N_("Bone"));
- BUTTON_HEADER_CTX(BCONTEXT_BONE_CONSTRAINT, ICON_CONSTRAINT_BONE, N_("Bone Constraints"));
- BUTTON_HEADER_CTX(BCONTEXT_MATERIAL, ICON_MATERIAL, N_("Material"));
- BUTTON_HEADER_CTX(BCONTEXT_TEXTURE, ICON_TEXTURE, N_("Textures"));
- BUTTON_HEADER_CTX(BCONTEXT_PARTICLE, ICON_PARTICLES, N_("Particles"));
- BUTTON_HEADER_CTX(BCONTEXT_PHYSICS, ICON_PHYSICS, N_("Physics"));
-
-#undef BUTTON_HEADER_CTX
-
- xco += BUT_UNIT_X;
-
- uiBlockEndAlign(block);
-
- /* always as last */
- UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), BLI_rctf_size_y(&ar->v2d.tot));
-
- uiEndBlock(C, block);
- uiDrawBlock(C, block);
-}
-
-
diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h
index 5700d361e15..f294729ae97 100644
--- a/source/blender/editors/space_buttons/buttons_intern.h
+++ b/source/blender/editors/space_buttons/buttons_intern.h
@@ -97,9 +97,6 @@ typedef struct ButsContextTexture {
/* internal exports only */
-/* buttons_header.c */
-void buttons_header_buttons(const struct bContext *C, struct ARegion *ar);
-
/* buttons_context.c */
void buttons_context_compute(const struct bContext *C, struct SpaceButs *sbuts);
int buttons_context(const struct bContext *C, const char *member, struct bContextDataResult *result);
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 02b06e08eed..e6c6df416bf 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -87,7 +87,7 @@ static SpaceLink *buttons_new(const bContext *UNUSED(C))
BLI_addtail(&sbuts->regionbase, ar);
ar->regiontype = RGN_TYPE_WINDOW;
-
+
return (SpaceLink *)sbuts;
}
@@ -200,22 +200,17 @@ static void buttons_keymap(struct wmKeyConfig *keyconf)
/* add handlers, stuff you only do once or on area/region changes */
static void buttons_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar)
{
- UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
+ ED_region_header_init(ar);
}
static void buttons_header_area_draw(const bContext *C, ARegion *ar)
{
- /* clear */
- UI_ThemeClearColor(ED_screen_area_active(C) ? TH_HEADER : TH_HEADERDESEL);
- glClear(GL_COLOR_BUFFER_BIT);
-
- /* set view2d view matrix for scrolling (without scrollers) */
- UI_view2d_view_ortho(&ar->v2d);
-
- buttons_header_buttons(C, ar);
+ SpaceButs *sbuts = CTX_wm_space_buts(C);
+
+ /* Needed for RNA to get the good values! */
+ buttons_context_compute(C, sbuts);
- /* restore view matrix? */
- UI_view2d_view_restore(C);
+ ED_region_header(C, ar);
}
/* draw a certain button set only if properties area is currently
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 36da4e3508c..4513694e59d 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -138,6 +138,25 @@ EnumPropertyItem clip_editor_mode_items[] = {
};
/* Actually populated dynamically trough a function, but helps for context-less access (e.g. doc, i18n...). */
+static EnumPropertyItem buttons_context_items[] = {
+ {BCONTEXT_SCENE, "SCENE", ICON_SCENE_DATA, "Scene", "Scene"},
+ {BCONTEXT_RENDER, "RENDER", ICON_SCENE, "Render", "Render"},
+ {BCONTEXT_RENDER_LAYER, "RENDER_LAYER", ICON_RENDERLAYERS, "Render Layers", "Render layers"},
+ {BCONTEXT_WORLD, "WORLD", ICON_WORLD, "World", "World"},
+ {BCONTEXT_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Object"},
+ {BCONTEXT_CONSTRAINT, "CONSTRAINT", ICON_CONSTRAINT, "Constraints", "Object constraints"},
+ {BCONTEXT_MODIFIER, "MODIFIER", ICON_MODIFIER, "Modifiers", "Object modifiers"},
+ {BCONTEXT_DATA, "DATA", ICON_NONE, "Data", "Object data"},
+ {BCONTEXT_BONE, "BONE", ICON_BONE_DATA, "Bone", "Bone"},
+ {BCONTEXT_BONE_CONSTRAINT, "BONE_CONSTRAINT", ICON_CONSTRAINT, "Bone Constraints", "Bone constraints"},
+ {BCONTEXT_MATERIAL, "MATERIAL", ICON_MATERIAL, "Material", "Material"},
+ {BCONTEXT_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture"},
+ {BCONTEXT_PARTICLE, "PARTICLES", ICON_PARTICLES, "Particles", "Particle"},
+ {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"},
+ {0, NULL, 0, NULL, NULL}
+};
+
+/* Actually populated dynamically trough a function, but helps for context-less access (e.g. doc, i18n...). */
static EnumPropertyItem buttons_texture_context_items[] = {
{SB_TEXC_MATERIAL, "MATERIAL", ICON_MATERIAL, "", "Show material textures"},
{SB_TEXC_WORLD, "WORLD", ICON_WORLD, "", "Show world textures"},
@@ -831,6 +850,76 @@ static void rna_SpaceProperties_context_set(PointerRNA *ptr, int value)
sbuts->mainbuser = value;
}
+static EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext *C, PointerRNA *ptr,
+ PropertyRNA *UNUSED(prop), int *free)
+{
+ SpaceButs *sbuts = (SpaceButs *)(ptr->data);
+ EnumPropertyItem *item = NULL;
+ int totitem = 0;
+
+ if (sbuts->pathflag & (1 << BCONTEXT_RENDER)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_RENDER);
+ }
+
+ if (sbuts->pathflag & (1 << BCONTEXT_RENDER_LAYER)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_RENDER_LAYER);
+ }
+
+ if (sbuts->pathflag & (1 << BCONTEXT_SCENE)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_SCENE);
+ }
+
+ if (sbuts->pathflag & (1 << BCONTEXT_WORLD)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_WORLD);
+ }
+
+ if (sbuts->pathflag & (1 << BCONTEXT_OBJECT)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_OBJECT);
+ }
+
+ if (sbuts->pathflag & (1 << BCONTEXT_CONSTRAINT)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_CONSTRAINT);
+ }
+
+ if (sbuts->pathflag & (1 << BCONTEXT_MODIFIER)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_MODIFIER);
+ }
+
+ if (sbuts->pathflag & (1 << BCONTEXT_DATA)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_DATA);
+ (item + totitem - 1)->icon = sbuts->dataicon;
+ }
+
+ if (sbuts->pathflag & (1 << BCONTEXT_BONE)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_BONE);
+ }
+
+ if (sbuts->pathflag & (1 << BCONTEXT_BONE_CONSTRAINT)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_BONE_CONSTRAINT);
+ }
+
+ if (sbuts->pathflag & (1 << BCONTEXT_MATERIAL)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_MATERIAL);
+ }
+
+ if (sbuts->pathflag & (1 << BCONTEXT_TEXTURE)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_TEXTURE);
+ }
+
+ if (sbuts->pathflag & (1 << BCONTEXT_PARTICLE)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_PARTICLE);
+ }
+
+ if (sbuts->pathflag & (1 << BCONTEXT_PHYSICS)) {
+ RNA_enum_items_add_value(&item, &totitem, buttons_context_items, BCONTEXT_PHYSICS);
+ }
+
+ RNA_enum_item_end(&item, &totitem);
+ *free = 1;
+
+ return item;
+}
+
static void rna_SpaceProperties_align_set(PointerRNA *ptr, int value)
{
SpaceButs *sbuts = (SpaceButs *)(ptr->data);
@@ -2068,24 +2157,6 @@ static void rna_def_space_buttons(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
- static EnumPropertyItem buttons_context_items[] = {
- {BCONTEXT_SCENE, "SCENE", ICON_SCENE, "Scene", "Scene"},
- {BCONTEXT_RENDER, "RENDER", ICON_SCENE_DATA, "Render", "Render"},
- {BCONTEXT_RENDER_LAYER, "RENDER_LAYER", ICON_RENDERLAYERS, "Render Layers", "Render Layers"},
- {BCONTEXT_WORLD, "WORLD", ICON_WORLD, "World", "World"},
- {BCONTEXT_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Object"},
- {BCONTEXT_CONSTRAINT, "CONSTRAINT", ICON_CONSTRAINT, "Constraints", "Constraints"},
- {BCONTEXT_MODIFIER, "MODIFIER", ICON_MODIFIER, "Modifiers", "Modifiers"},
- {BCONTEXT_DATA, "DATA", 0, "Data", "Data"},
- {BCONTEXT_BONE, "BONE", ICON_BONE_DATA, "Bone", "Bone"},
- {BCONTEXT_BONE_CONSTRAINT, "BONE_CONSTRAINT", ICON_CONSTRAINT, "Bone Constraints", "Bone Constraints"},
- {BCONTEXT_MATERIAL, "MATERIAL", ICON_MATERIAL, "Material", "Material"},
- {BCONTEXT_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture"},
- {BCONTEXT_PARTICLE, "PARTICLES", ICON_PARTICLES, "Particles", "Particle"},
- {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"},
- {0, NULL, 0, NULL, NULL}
- };
-
static EnumPropertyItem align_items[] = {
{BUT_HORIZONTAL, "HORIZONTAL", 0, "Horizontal", ""},
{BUT_VERTICAL, "VERTICAL", 0, "Vertical", ""},
@@ -2099,7 +2170,7 @@ static void rna_def_space_buttons(BlenderRNA *brna)
prop = RNA_def_property(srna, "context", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mainb");
RNA_def_property_enum_items(prop, buttons_context_items);
- RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceProperties_context_set", NULL);
+ RNA_def_property_enum_funcs(prop, NULL, "rna_SpaceProperties_context_set", "rna_SpaceProperties_context_itemf");
RNA_def_property_ui_text(prop, "Context", "Type of active data to display and edit");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_PROPERTIES, NULL);