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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-06-07 17:36:12 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-06-07 17:36:12 +0400
commiteecf7722b635545f0f5c51b74a15418e3cc9f47e (patch)
tree9d74c4603411f4aa6d527d229d2ea05220f81aec /source/blender/editors/space_buttons/buttons_ops.c
parent0a9dea9d7d2db373b47395d4b5d564e559da5229 (diff)
UI Buttons:
* Context now allows pinning a datablock, independent of selection. * Initial ID browse buttons for most buttons tabs. * Browsing from world to texture now displays world textures again, but is a bit of a hack, not sure there is a right way to do this. * There's a button to switch between active materials and textures now, only temporary though. * There's some code to put context part in own region, disabled still because it doesn't work that well yet.
Diffstat (limited to 'source/blender/editors/space_buttons/buttons_ops.c')
-rw-r--r--source/blender/editors/space_buttons/buttons_ops.c194
1 files changed, 194 insertions, 0 deletions
diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c
new file mode 100644
index 00000000000..63469a8294d
--- /dev/null
+++ b/source/blender/editors/space_buttons/buttons_ops.c
@@ -0,0 +1,194 @@
+/**
+ * $Id:
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2009 Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_object_types.h"
+#include "DNA_material_types.h"
+#include "DNA_texture_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_world_types.h"
+
+#include "BKE_context.h"
+#include "BKE_library.h"
+#include "BKE_material.h"
+#include "BKE_texture.h"
+#include "BKE_world.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "buttons_intern.h" // own include
+
+/********************** new material operator *********************/
+
+static int new_material_exec(bContext *C, wmOperator *op)
+{
+ PointerRNA ptr;
+ Material *ma;
+ Object *ob;
+ int index;
+
+ /* add or copy material */
+ ptr= CTX_data_pointer_get(C, "material");
+ ma= (RNA_struct_is_a(ptr.type, &RNA_Material))? ptr.data: NULL;
+
+ if(ma)
+ ma= copy_material(ma);
+ else
+ ma= add_material("Material");
+
+ ma->id.us--; /* compensating for us++ in assign_material */
+
+ /* attempt to assign to material slot */
+ ptr= CTX_data_pointer_get(C, "material_slot");
+
+ if(RNA_struct_is_a(ptr.type, &RNA_MaterialSlot)) {
+ ob= ptr.id.data;
+ index= (Material**)ptr.data - ob->mat;
+
+ assign_material(ob, ma, index+1);
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+void MATERIAL_OT_new(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "New Material";
+ ot->idname= "MATERIAL_OT_new";
+
+ /* api callbacks */
+ ot->exec= new_material_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/********************** new texture operator *********************/
+
+static int new_texture_exec(bContext *C, wmOperator *op)
+{
+ PointerRNA ptr;
+ ID *id;
+ Tex *tex;
+ MTex *mtex;
+
+ /* add or copy texture */
+ ptr= CTX_data_pointer_get(C, "texture");
+ tex= (RNA_struct_is_a(ptr.type, &RNA_Texture))? ptr.data: NULL;
+
+ if(tex)
+ tex= copy_texture(tex);
+ else
+ tex= add_texture("Texture");
+
+ id_us_min(&tex->id);
+
+ /* attempt to assign to texture slot */
+ ptr= CTX_data_pointer_get(C, "texture_slot");
+
+ if(RNA_struct_is_a(ptr.type, &RNA_TextureSlot)) {
+ id= ptr.id.data;
+ mtex= ptr.data;
+
+ if(mtex) {
+ if(mtex->tex)
+ id_us_min(&mtex->tex->id);
+ mtex->tex= tex;
+ id_us_plus(&tex->id);
+ }
+
+ /* XXX nodes, notifier .. */
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+void TEXTURE_OT_new(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "New Texture";
+ ot->idname= "TEXTURE_OT_new";
+
+ /* api callbacks */
+ ot->exec= new_texture_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+/********************** new world operator *********************/
+
+static int new_world_exec(bContext *C, wmOperator *op)
+{
+ PointerRNA ptr;
+ Scene *scene;
+ World *wo;
+
+ /* add or copy world */
+ ptr= CTX_data_pointer_get(C, "world");
+ wo= (RNA_struct_is_a(ptr.type, &RNA_World))? ptr.data: NULL;
+
+ if(wo)
+ wo= copy_world(wo);
+ else
+ wo= add_world("World");
+
+ /* assign to scene */
+ scene= CTX_data_scene(C);
+
+ if(scene->world)
+ id_us_min(&scene->world->id);
+ scene->world= wo;
+
+ // XXX notifier
+
+ return OPERATOR_FINISHED;
+}
+
+void WORLD_OT_new(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "New World";
+ ot->idname= "WORLD_OT_new";
+
+ /* api callbacks */
+ ot->exec= new_world_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+