2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-06-03 00:01:22 +00:00
|
|
|
* ***** 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-06-03 00:01:22 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_buttons/buttons_context.c
|
|
|
|
|
* \ingroup spbuttons
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2009-06-03 00:01:22 +00:00
|
|
|
#include <stdlib.h>
|
2009-06-03 23:33:56 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
2009-06-03 00:01:22 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_listbase.h"
|
|
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2013-02-19 15:45:56 +00:00
|
|
|
|
2009-06-03 00:01:22 +00:00
|
|
|
#include "DNA_armature_types.h"
|
2009-06-03 23:33:56 +00:00
|
|
|
#include "DNA_lamp_types.h"
|
2009-06-03 00:01:22 +00:00
|
|
|
#include "DNA_material_types.h"
|
2010-01-29 16:32:06 +00:00
|
|
|
#include "DNA_node_types.h"
|
2009-06-03 00:01:22 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
#include "DNA_world_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_brush_types.h"
|
2014-05-03 18:51:53 +09:00
|
|
|
#include "DNA_linestyle_types.h"
|
2009-06-03 00:01:22 +00:00
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
2010-01-30 23:48:49 +00:00
|
|
|
#include "BKE_action.h"
|
2009-06-03 00:01:22 +00:00
|
|
|
#include "BKE_material.h"
|
|
|
|
|
#include "BKE_modifier.h"
|
2009-08-16 19:50:00 +00:00
|
|
|
#include "BKE_paint.h"
|
2009-06-03 00:01:22 +00:00
|
|
|
#include "BKE_particle.h"
|
2009-06-03 23:33:56 +00:00
|
|
|
#include "BKE_screen.h"
|
2009-10-09 09:50:49 +00:00
|
|
|
#include "BKE_texture.h"
|
2014-07-16 13:36:39 +09:00
|
|
|
#include "BKE_linestyle.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2009-06-03 00:01:22 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
2015-05-04 15:07:24 +10:00
|
|
|
#include "ED_buttons.h"
|
2009-06-19 14:56:49 +00:00
|
|
|
#include "ED_armature.h"
|
2009-06-07 13:36:12 +00:00
|
|
|
#include "ED_screen.h"
|
2009-10-27 02:54:25 +00:00
|
|
|
#include "ED_physics.h"
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2009-06-03 23:33:56 +00:00
|
|
|
#include "UI_interface.h"
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
#include "buttons_intern.h" // own include
|
2009-06-03 00:01:22 +00:00
|
|
|
|
2009-06-07 13:36:12 +00:00
|
|
|
static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA *ptr;
|
|
|
|
|
int a;
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
for (a = 0; a < path->len; a++) {
|
|
|
|
|
ptr = &path->ptr[a];
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_is_a(ptr->type, type)) {
|
2009-06-07 13:36:12 +00:00
|
|
|
CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA *ptr;
|
|
|
|
|
int a;
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
for (a = 0; a < path->len; a++) {
|
|
|
|
|
ptr = &path->ptr[a];
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_is_a(ptr->type, type))
|
2009-06-07 13:36:12 +00:00
|
|
|
return ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-03 23:33:56 +00:00
|
|
|
/************************* Creating the Path ************************/
|
|
|
|
|
|
|
|
|
|
static int buttons_context_path_scene(ButsContextPath *path)
|
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = &path->ptr[path->len - 1];
|
2009-06-03 23:33:56 +00:00
|
|
|
|
|
|
|
|
/* this one just verifies */
|
|
|
|
|
return RNA_struct_is_a(ptr->type, &RNA_Scene);
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-19 19:17:05 +00:00
|
|
|
/* note: this function can return 1 without adding a world to the path
|
|
|
|
|
* so the buttons stay visible, but be sure to check the ID type if a ID_WO */
|
2009-06-03 23:33:56 +00:00
|
|
|
static int buttons_context_path_world(ButsContextPath *path)
|
2009-06-03 00:01:22 +00:00
|
|
|
{
|
2009-06-03 23:33:56 +00:00
|
|
|
Scene *scene;
|
2009-10-13 06:15:41 +00:00
|
|
|
World *world;
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = &path->ptr[path->len - 1];
|
2009-06-03 00:01:22 +00:00
|
|
|
|
2009-06-03 23:33:56 +00:00
|
|
|
/* if we already have a (pinned) world, we're done */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_World)) {
|
2009-06-03 00:01:22 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
2009-06-03 23:33:56 +00:00
|
|
|
/* if we have a scene, use the scene's world */
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (buttons_context_path_scene(path)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
scene = path->ptr[path->len - 1].data;
|
|
|
|
|
world = scene->world;
|
2009-10-13 06:15:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (world) {
|
2009-10-13 06:15:41 +00:00
|
|
|
RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
2009-10-16 19:46:53 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2009-10-13 06:15:41 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
2009-06-03 00:01:22 +00:00
|
|
|
}
|
2009-06-03 23:33:56 +00:00
|
|
|
|
|
|
|
|
/* no path to a world possible */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-03 18:51:53 +09:00
|
|
|
static int buttons_context_path_linestyle(ButsContextPath *path)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene;
|
|
|
|
|
FreestyleLineStyle *linestyle;
|
|
|
|
|
PointerRNA *ptr = &path->ptr[path->len - 1];
|
|
|
|
|
|
|
|
|
|
/* if we already have a (pinned) linestyle, we're done */
|
|
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_FreestyleLineStyle)) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
/* if we have a scene, use the lineset's linestyle */
|
|
|
|
|
else if (buttons_context_path_scene(path)) {
|
|
|
|
|
scene = path->ptr[path->len - 1].data;
|
2014-07-16 15:13:40 +10:00
|
|
|
linestyle = BKE_linestyle_active_from_scene(scene);
|
2014-05-03 18:51:53 +09:00
|
|
|
if (linestyle) {
|
|
|
|
|
RNA_id_pointer_create(&linestyle->id, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no path to a linestyle possible */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2009-06-06 11:34:18 +00:00
|
|
|
|
2009-06-03 23:33:56 +00:00
|
|
|
static int buttons_context_path_object(ButsContextPath *path)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene;
|
|
|
|
|
Object *ob;
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = &path->ptr[path->len - 1];
|
2009-06-03 23:33:56 +00:00
|
|
|
|
|
|
|
|
/* if we already have a (pinned) object, we're done */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_Object)) {
|
2009-06-03 00:01:22 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
2009-06-03 23:33:56 +00:00
|
|
|
/* if we have a scene, use the scene's active object */
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (buttons_context_path_scene(path)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
scene = path->ptr[path->len - 1].data;
|
|
|
|
|
ob = (scene->basact) ? scene->basact->object : NULL;
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob) {
|
2009-06-03 23:33:56 +00:00
|
|
|
RNA_id_pointer_create(&ob->id, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
|
|
|
|
|
2009-06-03 00:01:22 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-03 23:33:56 +00:00
|
|
|
|
|
|
|
|
/* no path to a object possible */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int buttons_context_path_data(ButsContextPath *path, int type)
|
|
|
|
|
{
|
|
|
|
|
Object *ob;
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = &path->ptr[path->len - 1];
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2009-06-07 13:36:12 +00:00
|
|
|
/* if we already have a data, we're done */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) return 1;
|
2014-07-20 01:30:29 +10:00
|
|
|
else if (RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM(type, OB_CURVE, OB_SURF, OB_FONT))) return 1;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) return 1;
|
|
|
|
|
else if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) return 1;
|
|
|
|
|
else if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) return 1;
|
|
|
|
|
else if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) return 1;
|
|
|
|
|
else if (RNA_struct_is_a(ptr->type, &RNA_Lamp) && (type == -1 || type == OB_LAMP)) return 1;
|
|
|
|
|
else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) return 1;
|
2009-06-03 23:33:56 +00:00
|
|
|
/* try to get an object in the path, no pinning supported here */
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (buttons_context_path_object(path)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ob = path->ptr[path->len - 1].data;
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob && (type == -1 || type == ob->type)) {
|
2009-06-03 23:33:56 +00:00
|
|
|
RNA_id_pointer_create(ob->data, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
|
|
|
|
|
2009-06-03 00:01:22 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-03 23:33:56 +00:00
|
|
|
|
|
|
|
|
/* no path to data possible */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-07 13:36:12 +00:00
|
|
|
static int buttons_context_path_modifier(ButsContextPath *path)
|
|
|
|
|
{
|
|
|
|
|
Object *ob;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (buttons_context_path_object(path)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ob = path->ptr[path->len - 1].data;
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ob && ELEM(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE))
|
2009-06-07 13:36:12 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-24 16:02:10 +02:00
|
|
|
static int buttons_context_path_material(ButsContextPath *path, bool for_texture, bool new_shading)
|
2009-06-03 23:33:56 +00:00
|
|
|
{
|
|
|
|
|
Object *ob;
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = &path->ptr[path->len - 1];
|
2009-06-07 13:36:12 +00:00
|
|
|
Material *ma;
|
2009-06-03 23:33:56 +00:00
|
|
|
|
|
|
|
|
/* if we already have a (pinned) material, we're done */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_Material)) {
|
2009-06-03 23:33:56 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
/* if we have an object, use the object material slot */
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (buttons_context_path_object(path)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ob = path->ptr[path->len - 1].data;
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ma = give_current_material(ob, ob->actcol);
|
2009-06-07 13:36:12 +00:00
|
|
|
RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
|
2009-06-03 23:33:56 +00:00
|
|
|
path->len++;
|
2011-07-13 17:52:23 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (for_texture && give_current_material_texture_node(ma))
|
2011-07-13 17:52:23 +00:00
|
|
|
return 1;
|
2014-05-24 16:02:10 +02:00
|
|
|
|
|
|
|
|
if (!new_shading) {
|
|
|
|
|
/* Only try to get mat from node in case of old shading system (see T40331). */
|
|
|
|
|
ma = give_node_material(ma);
|
|
|
|
|
if (ma) {
|
|
|
|
|
RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
|
|
|
|
}
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2009-06-03 00:01:22 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-03 23:33:56 +00:00
|
|
|
|
|
|
|
|
/* no path to a material possible */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int buttons_context_path_bone(ButsContextPath *path)
|
|
|
|
|
{
|
|
|
|
|
bArmature *arm;
|
2009-06-19 14:56:49 +00:00
|
|
|
EditBone *edbo;
|
2009-06-03 23:33:56 +00:00
|
|
|
|
|
|
|
|
/* if we have an armature, get the active bone */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (buttons_context_path_data(path, OB_ARMATURE)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
arm = path->ptr[path->len - 1].data;
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (arm->edbo) {
|
|
|
|
|
if (arm->act_edbone) {
|
2012-05-08 15:30:00 +00:00
|
|
|
edbo = arm->act_edbone;
|
2009-11-09 21:03:54 +00:00
|
|
|
RNA_pointer_create(&arm->id, &RNA_EditBone, edbo, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
|
|
|
|
return 1;
|
2009-06-19 14:56:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (arm->act_bone) {
|
2009-11-09 21:03:54 +00:00
|
|
|
RNA_pointer_create(&arm->id, &RNA_Bone, arm->act_bone, &path->ptr[path->len]);
|
2009-06-19 14:56:49 +00:00
|
|
|
path->len++;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2009-06-03 00:01:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-06-03 23:33:56 +00:00
|
|
|
|
|
|
|
|
/* no path to a bone possible */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-30 23:48:49 +00:00
|
|
|
static int buttons_context_path_pose_bone(ButsContextPath *path)
|
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = &path->ptr[path->len - 1];
|
2010-01-30 23:48:49 +00:00
|
|
|
|
|
|
|
|
/* if we already have a (pinned) PoseBone, we're done */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) {
|
2010-01-30 23:48:49 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* if we have an armature, get the active bone */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (buttons_context_path_object(path)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
Object *ob = path->ptr[path->len - 1].data;
|
|
|
|
|
bArmature *arm = ob->data; /* path->ptr[path->len-1].data - works too */
|
2010-01-30 23:48:49 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob->type != OB_ARMATURE || arm->edbo) {
|
2010-01-30 23:48:49 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (arm->act_bone) {
|
2012-05-08 15:30:00 +00:00
|
|
|
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, arm->act_bone->name);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (pchan) {
|
2010-01-30 23:48:49 +00:00
|
|
|
RNA_pointer_create(&ob->id, &RNA_PoseBone, pchan, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no path to a bone possible */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-06-03 23:33:56 +00:00
|
|
|
static int buttons_context_path_particle(ButsContextPath *path)
|
|
|
|
|
{
|
|
|
|
|
Object *ob;
|
|
|
|
|
ParticleSystem *psys;
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = &path->ptr[path->len - 1];
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2011-02-16 10:57:58 +00:00
|
|
|
/* if we already have (pinned) particle settings, we're done */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_ParticleSettings)) {
|
2011-02-16 10:57:58 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
2009-06-03 23:33:56 +00:00
|
|
|
/* if we have an object, get the active particle system */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (buttons_context_path_object(path)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ob = path->ptr[path->len - 1].data;
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob && ob->type == OB_MESH) {
|
2012-05-08 15:30:00 +00:00
|
|
|
psys = psys_get_current(ob);
|
2009-06-07 13:36:12 +00:00
|
|
|
|
|
|
|
|
RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2009-06-03 23:33:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no path to a particle system possible */
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-16 08:03:28 +00:00
|
|
|
static int buttons_context_path_brush(ButsContextPath *path)
|
2009-07-25 22:31:02 +00:00
|
|
|
{
|
|
|
|
|
Scene *scene;
|
2012-05-08 15:30:00 +00:00
|
|
|
Brush *br = NULL;
|
|
|
|
|
PointerRNA *ptr = &path->ptr[path->len - 1];
|
2009-07-25 22:31:02 +00:00
|
|
|
|
|
|
|
|
/* if we already have a (pinned) brush, we're done */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_Brush)) {
|
2009-07-25 22:31:02 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
/* if we have a scene, use the toolsettings brushes */
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (buttons_context_path_scene(path)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
scene = path->ptr[path->len - 1].data;
|
2009-07-25 22:31:02 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (scene)
|
Paint refactoring commit, non-disruptive (in theory :p)
* Fix precision overflow issue with overlay previews,
* Expose alpha mask mapping to UI (still not functional but coming soon).
* More overlay refactoring:
Overlay now does minimal checking for texture refresh.
Instead, we now have invalidation flags to set an aspect of the brush
overlay as invalid. This is necessary because this way we will be able to
separate and preview different brush attributes on the overlays, using
different textures:
These attributes/aspects are:
Primary texture (main texture for sculpt, vertex, imapaint)
Secondary texture (mask/alpha texture for imapaint)
Cursor texture (cursor texture. It involves brush strength and curves)
Modified the relevant RNA property update functions and C update callback
functions to call the relevant cursor invalidation functions instead
of checking every frame for multiple properties.
Properties that affect this are:
Image changes, if image is used by current brush,
Texture slot changes, similarly
Curve changes,
Object mode change invalidates the cursor
Paint tool change invalidates the cursor.
These changes give slightly more invalidation cases than simply
comparing the relevant properties each frame, but these do not occur in
performance critical moments and it's a much more elegant system than
adding more variables to check per frame each time we add something on
the system.
2013-04-12 17:21:31 +00:00
|
|
|
br = BKE_paint_brush(BKE_paint_get_active(scene));
|
2009-07-25 22:31:02 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (br) {
|
2010-08-04 04:01:27 +00:00
|
|
|
RNA_id_pointer_create((ID *)br, &path->ptr[path->len]);
|
2009-07-25 22:31:02 +00:00
|
|
|
path->len++;
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-18 12:58:51 +00:00
|
|
|
/* no path to a brush possible */
|
2009-07-25 22:31:02 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-08 13:07:16 +00:00
|
|
|
static int buttons_context_path_texture(ButsContextPath *path, ButsContextTexture *ct)
|
2009-06-03 23:33:56 +00:00
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ct) {
|
2011-11-08 13:07:16 +00:00
|
|
|
/* new shading system */
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = &path->ptr[path->len - 1];
|
2011-11-08 13:07:16 +00:00
|
|
|
ID *id;
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2011-11-08 13:07:16 +00:00
|
|
|
/* if we already have a (pinned) texture, we're done */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_Texture))
|
2011-11-08 13:07:16 +00:00
|
|
|
return 1;
|
2009-07-25 22:31:02 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ct->user)
|
2011-11-08 13:07:16 +00:00
|
|
|
return 0;
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
id = ct->user->id;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (id) {
|
|
|
|
|
if (GS(id->name) == ID_BR)
|
2011-11-08 13:07:16 +00:00
|
|
|
buttons_context_path_brush(path);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (GS(id->name) == ID_MA)
|
2014-05-24 16:02:10 +02:00
|
|
|
buttons_context_path_material(path, false, true);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (GS(id->name) == ID_WO)
|
2011-11-08 13:07:16 +00:00
|
|
|
buttons_context_path_world(path);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (GS(id->name) == ID_LA)
|
2011-11-08 13:07:16 +00:00
|
|
|
buttons_context_path_data(path, OB_LAMP);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (GS(id->name) == ID_PA)
|
2011-11-08 13:07:16 +00:00
|
|
|
buttons_context_path_particle(path);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (GS(id->name) == ID_OB)
|
2011-11-08 13:07:16 +00:00
|
|
|
buttons_context_path_object(path);
|
2014-05-03 18:51:53 +09:00
|
|
|
else if (GS(id->name) == ID_LS)
|
|
|
|
|
buttons_context_path_linestyle(path);
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
This commit addresses the somewhat weak handling of stackless textures in Blender with default (BI) renderer. To do so, it's defining an "other" texture context, and when in this one, it switches to using the "new shading" texture handling already known with Cycles engine.
So now, in the new "other" tex context, you can (depending on active data) have direct access to modifiers', force's or brushes' textures...
I also refactored a bit how texture contexts are handled (once again, we had some quite similar code in both space_buttons and RNA sources). This should also solve some harmless glitches like "no texture context selected in UI" sometimes when you remove data related to current texture (see e.g. after removing the material from default cube, in startup scene).
This usage of two different systems for textures, and the handling of switches between them, has been a bit tricky to get working right, but it is OK now I think. I also had to add a bool flag to buttons space, SB_TEX_USER_LIMITED (use_limited_texture_context in RNA), which indicates "new shading" texture code whether it has to ignore materials, lamps etc. (BI) or not (Cycles).
Btw, pinned textures from modifiers/force/etc. were also broken (showing nothing), now it should work too.
Thanks to Brecht for reviewing.
2013-05-17 07:10:10 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ct->texture) {
|
2011-11-08 13:07:16 +00:00
|
|
|
RNA_id_pointer_create(&ct->texture->id, &path->ptr[path->len]);
|
2009-07-25 22:31:02 +00:00
|
|
|
path->len++;
|
|
|
|
|
}
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2011-11-08 13:07:16 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* old shading system */
|
|
|
|
|
Material *ma;
|
|
|
|
|
Lamp *la;
|
|
|
|
|
World *wo;
|
|
|
|
|
ParticleSystem *psys;
|
2014-05-03 18:51:53 +09:00
|
|
|
FreestyleLineStyle *ls;
|
2011-11-08 13:07:16 +00:00
|
|
|
Tex *tex;
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = &path->ptr[path->len - 1];
|
2011-11-08 13:07:16 +00:00
|
|
|
|
|
|
|
|
/* if we already have a (pinned) texture, we're done */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_struct_is_a(ptr->type, &RNA_Texture)) {
|
2009-06-07 13:36:12 +00:00
|
|
|
return 1;
|
2009-06-03 23:33:56 +00:00
|
|
|
}
|
2011-11-08 13:07:16 +00:00
|
|
|
/* try world */
|
This commit addresses the somewhat weak handling of stackless textures in Blender with default (BI) renderer. To do so, it's defining an "other" texture context, and when in this one, it switches to using the "new shading" texture handling already known with Cycles engine.
So now, in the new "other" tex context, you can (depending on active data) have direct access to modifiers', force's or brushes' textures...
I also refactored a bit how texture contexts are handled (once again, we had some quite similar code in both space_buttons and RNA sources). This should also solve some harmless glitches like "no texture context selected in UI" sometimes when you remove data related to current texture (see e.g. after removing the material from default cube, in startup scene).
This usage of two different systems for textures, and the handling of switches between them, has been a bit tricky to get working right, but it is OK now I think. I also had to add a bool flag to buttons space, SB_TEX_USER_LIMITED (use_limited_texture_context in RNA), which indicates "new shading" texture code whether it has to ignore materials, lamps etc. (BI) or not (Cycles).
Btw, pinned textures from modifiers/force/etc. were also broken (showing nothing), now it should work too.
Thanks to Brecht for reviewing.
2013-05-17 07:10:10 +00:00
|
|
|
else if ((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
wo = path->ptr[path->len - 1].data;
|
2011-02-16 10:57:58 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
if (wo && GS(wo->id.name) == ID_WO) {
|
|
|
|
|
tex = give_current_world_texture(wo);
|
2011-02-16 10:57:58 +00:00
|
|
|
|
|
|
|
|
RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-11-08 13:07:16 +00:00
|
|
|
/* try particles */
|
This commit addresses the somewhat weak handling of stackless textures in Blender with default (BI) renderer. To do so, it's defining an "other" texture context, and when in this one, it switches to using the "new shading" texture handling already known with Cycles engine.
So now, in the new "other" tex context, you can (depending on active data) have direct access to modifiers', force's or brushes' textures...
I also refactored a bit how texture contexts are handled (once again, we had some quite similar code in both space_buttons and RNA sources). This should also solve some harmless glitches like "no texture context selected in UI" sometimes when you remove data related to current texture (see e.g. after removing the material from default cube, in startup scene).
This usage of two different systems for textures, and the handling of switches between them, has been a bit tricky to get working right, but it is OK now I think. I also had to add a bool flag to buttons space, SB_TEX_USER_LIMITED (use_limited_texture_context in RNA), which indicates "new shading" texture code whether it has to ignore materials, lamps etc. (BI) or not (Cycles).
Btw, pinned textures from modifiers/force/etc. were also broken (showing nothing), now it should work too.
Thanks to Brecht for reviewing.
2013-05-17 07:10:10 +00:00
|
|
|
else if ((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
if (path->ptr[path->len - 1].type == &RNA_ParticleSettings) {
|
|
|
|
|
ParticleSettings *part = path->ptr[path->len - 1].data;
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
tex = give_current_particle_texture(part);
|
2011-11-08 13:07:16 +00:00
|
|
|
RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2012-05-08 15:30:00 +00:00
|
|
|
psys = path->ptr[path->len - 1].data;
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
if (psys && psys->part && GS(psys->part->id.name) == ID_PA) {
|
|
|
|
|
tex = give_current_particle_texture(psys->part);
|
2011-11-08 13:07:16 +00:00
|
|
|
|
|
|
|
|
RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-03 00:01:22 +00:00
|
|
|
}
|
2011-11-08 13:07:16 +00:00
|
|
|
/* try material */
|
2014-05-24 16:02:10 +02:00
|
|
|
else if ((path->tex_ctx == SB_TEXC_MATERIAL) && buttons_context_path_material(path, true, false)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ma = path->ptr[path->len - 1].data;
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma) {
|
2012-05-08 15:30:00 +00:00
|
|
|
tex = give_current_material_texture(ma);
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2011-11-08 13:07:16 +00:00
|
|
|
RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2009-06-03 00:01:22 +00:00
|
|
|
}
|
2011-11-08 13:07:16 +00:00
|
|
|
/* try lamp */
|
This commit addresses the somewhat weak handling of stackless textures in Blender with default (BI) renderer. To do so, it's defining an "other" texture context, and when in this one, it switches to using the "new shading" texture handling already known with Cycles engine.
So now, in the new "other" tex context, you can (depending on active data) have direct access to modifiers', force's or brushes' textures...
I also refactored a bit how texture contexts are handled (once again, we had some quite similar code in both space_buttons and RNA sources). This should also solve some harmless glitches like "no texture context selected in UI" sometimes when you remove data related to current texture (see e.g. after removing the material from default cube, in startup scene).
This usage of two different systems for textures, and the handling of switches between them, has been a bit tricky to get working right, but it is OK now I think. I also had to add a bool flag to buttons space, SB_TEX_USER_LIMITED (use_limited_texture_context in RNA), which indicates "new shading" texture code whether it has to ignore materials, lamps etc. (BI) or not (Cycles).
Btw, pinned textures from modifiers/force/etc. were also broken (showing nothing), now it should work too.
Thanks to Brecht for reviewing.
2013-05-17 07:10:10 +00:00
|
|
|
else if ((path->tex_ctx == SB_TEXC_LAMP) && buttons_context_path_data(path, OB_LAMP)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
la = path->ptr[path->len - 1].data;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (la) {
|
2012-05-08 15:30:00 +00:00
|
|
|
tex = give_current_lamp_texture(la);
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2014-05-03 18:51:53 +09:00
|
|
|
RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* try linestyle */
|
|
|
|
|
else if ((path->tex_ctx == SB_TEXC_LINESTYLE) && buttons_context_path_linestyle(path)) {
|
|
|
|
|
ls = path->ptr[path->len - 1].data;
|
|
|
|
|
|
|
|
|
|
if (ls) {
|
|
|
|
|
tex = give_current_linestyle_texture(ls);
|
|
|
|
|
|
2011-11-08 13:07:16 +00:00
|
|
|
RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
|
|
|
|
|
path->len++;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2010-01-13 23:12:48 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2009-07-25 22:31:02 +00:00
|
|
|
/* no path to a texture possible */
|
2009-06-03 23:33:56 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-04 00:04:12 +10:00
|
|
|
#ifdef WITH_FREESTYLE
|
2014-05-03 18:51:53 +09:00
|
|
|
static bool buttons_context_linestyle_pinnable(const bContext *C)
|
|
|
|
|
{
|
|
|
|
|
Scene *scene = CTX_data_scene(C);
|
2014-05-05 19:53:13 +09:00
|
|
|
SceneRenderLayer *actsrl;
|
|
|
|
|
FreestyleConfig *config;
|
2014-05-03 18:51:53 +09:00
|
|
|
SpaceButs *sbuts;
|
|
|
|
|
|
|
|
|
|
/* if Freestyle is disabled in the scene */
|
|
|
|
|
if ((scene->r.mode & R_EDGE_FRS) == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-05-05 19:53:13 +09:00
|
|
|
/* if Freestyle is not in the Parameter Editor mode */
|
|
|
|
|
actsrl = BLI_findlink(&scene->r.layers, scene->r.actlay);
|
|
|
|
|
config = &actsrl->freestyleConfig;
|
|
|
|
|
if (config->mode != FREESTYLE_CONTROL_EDITOR_MODE) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-05-03 18:51:53 +09:00
|
|
|
/* if the scene has already been pinned */
|
|
|
|
|
sbuts = CTX_wm_space_buts(C);
|
|
|
|
|
if (sbuts->pinid && sbuts->pinid == &scene->id) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2014-05-04 00:04:12 +10:00
|
|
|
#endif
|
2009-07-20 20:28:29 +00:00
|
|
|
|
2009-07-25 22:31:02 +00:00
|
|
|
static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag)
|
2009-06-03 23:33:56 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
SpaceButs *sbuts = CTX_wm_space_buts(C);
|
2009-06-03 23:33:56 +00:00
|
|
|
ID *id;
|
|
|
|
|
int found;
|
|
|
|
|
|
|
|
|
|
memset(path, 0, sizeof(*path));
|
2012-05-08 15:30:00 +00:00
|
|
|
path->flag = flag;
|
2011-02-08 14:29:48 +00:00
|
|
|
path->tex_ctx = sbuts->texture_context;
|
2009-06-03 23:33:56 +00:00
|
|
|
|
|
|
|
|
/* if some ID datablock is pinned, set the root pointer */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sbuts->pinid) {
|
2012-05-08 15:30:00 +00:00
|
|
|
id = sbuts->pinid;
|
2009-06-03 23:33:56 +00:00
|
|
|
|
|
|
|
|
RNA_id_pointer_create(id, &path->ptr[0]);
|
|
|
|
|
path->len++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* no pinned root, use scene as root */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (path->len == 0) {
|
2012-05-08 15:30:00 +00:00
|
|
|
id = (ID *)CTX_data_scene(C);
|
2009-06-03 23:33:56 +00:00
|
|
|
RNA_id_pointer_create(id, &path->ptr[0]);
|
|
|
|
|
path->len++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* now for each buttons context type, we try to construct a path,
|
|
|
|
|
* tracing back recursively */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (mainb) {
|
2009-06-03 23:33:56 +00:00
|
|
|
case BCONTEXT_SCENE:
|
2009-10-14 14:07:32 +00:00
|
|
|
case BCONTEXT_RENDER:
|
2014-05-03 18:51:53 +09:00
|
|
|
found = buttons_context_path_scene(path);
|
|
|
|
|
break;
|
2012-10-28 16:09:51 +00:00
|
|
|
case BCONTEXT_RENDER_LAYER:
|
2014-05-03 18:51:53 +09:00
|
|
|
#ifdef WITH_FREESTYLE
|
|
|
|
|
if (buttons_context_linestyle_pinnable(C)) {
|
|
|
|
|
found = buttons_context_path_linestyle(path);
|
|
|
|
|
if (found) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2012-05-08 15:30:00 +00:00
|
|
|
found = buttons_context_path_scene(path);
|
2009-06-03 23:33:56 +00:00
|
|
|
break;
|
|
|
|
|
case BCONTEXT_WORLD:
|
2012-05-08 15:30:00 +00:00
|
|
|
found = buttons_context_path_world(path);
|
2009-06-03 23:33:56 +00:00
|
|
|
break;
|
|
|
|
|
case BCONTEXT_OBJECT:
|
|
|
|
|
case BCONTEXT_PHYSICS:
|
2009-06-06 16:18:19 +00:00
|
|
|
case BCONTEXT_CONSTRAINT:
|
2012-05-08 15:30:00 +00:00
|
|
|
found = buttons_context_path_object(path);
|
2009-06-03 23:33:56 +00:00
|
|
|
break;
|
2009-06-07 13:36:12 +00:00
|
|
|
case BCONTEXT_MODIFIER:
|
2012-05-08 15:30:00 +00:00
|
|
|
found = buttons_context_path_modifier(path);
|
2009-06-07 13:36:12 +00:00
|
|
|
break;
|
2009-06-03 23:33:56 +00:00
|
|
|
case BCONTEXT_DATA:
|
2012-05-08 15:30:00 +00:00
|
|
|
found = buttons_context_path_data(path, -1);
|
2009-06-03 23:33:56 +00:00
|
|
|
break;
|
|
|
|
|
case BCONTEXT_PARTICLE:
|
2012-05-08 15:30:00 +00:00
|
|
|
found = buttons_context_path_particle(path);
|
2009-06-03 23:33:56 +00:00
|
|
|
break;
|
|
|
|
|
case BCONTEXT_MATERIAL:
|
2014-05-24 16:02:10 +02:00
|
|
|
found = buttons_context_path_material(path, false, (sbuts->texuser != NULL));
|
2009-06-03 23:33:56 +00:00
|
|
|
break;
|
|
|
|
|
case BCONTEXT_TEXTURE:
|
2012-05-08 15:30:00 +00:00
|
|
|
found = buttons_context_path_texture(path, sbuts->texuser);
|
2009-06-03 23:33:56 +00:00
|
|
|
break;
|
|
|
|
|
case BCONTEXT_BONE:
|
2012-05-08 15:30:00 +00:00
|
|
|
found = buttons_context_path_bone(path);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!found)
|
2012-05-08 15:30:00 +00:00
|
|
|
found = buttons_context_path_data(path, OB_ARMATURE);
|
2009-06-03 23:33:56 +00:00
|
|
|
break;
|
2010-01-30 23:48:49 +00:00
|
|
|
case BCONTEXT_BONE_CONSTRAINT:
|
2012-05-08 15:30:00 +00:00
|
|
|
found = buttons_context_path_pose_bone(path);
|
2010-01-30 23:48:49 +00:00
|
|
|
break;
|
2009-06-03 23:33:56 +00:00
|
|
|
default:
|
2012-05-08 15:30:00 +00:00
|
|
|
found = 0;
|
2009-06-03 23:33:56 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-28 10:57:31 +00:00
|
|
|
static int buttons_shading_context(const bContext *C, int mainb)
|
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
Object *ob = CTX_data_active_object(C);
|
2010-01-28 10:57:31 +00:00
|
|
|
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE))
|
2010-01-28 10:57:31 +00:00
|
|
|
return 1;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA))
|
2010-01-28 10:57:31 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-16 08:03:28 +00:00
|
|
|
static int buttons_shading_new_context(const bContext *C, int flag)
|
2010-01-28 10:57:31 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
Object *ob = CTX_data_active_object(C);
|
2010-01-28 10:57:31 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (flag & (1 << BCONTEXT_MATERIAL))
|
2010-01-28 10:57:31 +00:00
|
|
|
return BCONTEXT_MATERIAL;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ob && ELEM(ob->type, OB_LAMP, OB_CAMERA) && (flag & (1 << BCONTEXT_DATA)))
|
2010-01-28 10:57:31 +00:00
|
|
|
return BCONTEXT_DATA;
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (flag & (1 << BCONTEXT_WORLD))
|
2010-01-28 10:57:31 +00:00
|
|
|
return BCONTEXT_WORLD;
|
|
|
|
|
|
|
|
|
|
return BCONTEXT_RENDER;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-03 23:33:56 +00:00
|
|
|
void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
|
|
|
|
|
{
|
2009-06-07 13:36:12 +00:00
|
|
|
ButsContextPath *path;
|
|
|
|
|
PointerRNA *ptr;
|
2012-05-08 15:30:00 +00:00
|
|
|
int a, pflag = 0, flag = 0;
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!sbuts->path)
|
2012-05-08 15:30:00 +00:00
|
|
|
sbuts->path = MEM_callocN(sizeof(ButsContextPath), "ButsContextPath");
|
2014-04-07 17:13:06 +02:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
path = sbuts->path;
|
2014-04-07 17:13:06 +02:00
|
|
|
|
|
|
|
|
/* We need to set Scene path now! Else, buttons_texture_context_compute() might not get a valid scene. */
|
|
|
|
|
buttons_context_path(C, path, BCONTEXT_SCENE, pflag);
|
|
|
|
|
|
|
|
|
|
buttons_texture_context_compute(C, sbuts);
|
|
|
|
|
|
2009-06-07 13:36:12 +00:00
|
|
|
/* for each context, see if we can compute a valid path to it, if
|
|
|
|
|
* this is the case, we know we have to display the button */
|
2012-05-08 15:30:00 +00:00
|
|
|
for (a = 0; a < BCONTEXT_TOT; a++) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (buttons_context_path(C, path, a, pflag)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
flag |= (1 << a);
|
2009-06-07 13:36:12 +00:00
|
|
|
|
|
|
|
|
/* setting icon for data context */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (a == BCONTEXT_DATA) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ptr = &path->ptr[path->len - 1];
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ptr->type)
|
2012-05-08 15:30:00 +00:00
|
|
|
sbuts->dataicon = RNA_struct_ui_icon(ptr->type);
|
2009-06-07 13:36:12 +00:00
|
|
|
else
|
2012-05-08 15:30:00 +00:00
|
|
|
sbuts->dataicon = ICON_EMPTY_DATA;
|
2009-06-07 13:36:12 +00:00
|
|
|
}
|
2009-06-03 00:01:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2009-07-24 16:41:12 +00:00
|
|
|
/* always try to use the tab that was explicitly
|
|
|
|
|
* set to the user, so that once that context comes
|
|
|
|
|
* back, the tab is activated again */
|
2012-05-08 15:30:00 +00:00
|
|
|
sbuts->mainb = sbuts->mainbuser;
|
2009-07-24 16:41:12 +00:00
|
|
|
|
2009-06-07 13:36:12 +00:00
|
|
|
/* in case something becomes invalid, change */
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((flag & (1 << sbuts->mainb)) == 0) {
|
|
|
|
|
if (sbuts->flag & SB_SHADING_CONTEXT) {
|
2010-01-28 10:57:31 +00:00
|
|
|
/* try to keep showing shading related buttons */
|
2012-05-08 15:30:00 +00:00
|
|
|
sbuts->mainb = buttons_shading_new_context(C, flag);
|
2010-01-28 10:57:31 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (flag & BCONTEXT_OBJECT) {
|
2012-05-08 15:30:00 +00:00
|
|
|
sbuts->mainb = BCONTEXT_OBJECT;
|
2009-06-07 13:36:12 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-05-08 15:30:00 +00:00
|
|
|
for (a = 0; a < BCONTEXT_TOT; a++) {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (flag & (1 << a)) {
|
2012-05-08 15:30:00 +00:00
|
|
|
sbuts->mainb = a;
|
2009-06-07 13:36:12 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2009-07-25 22:31:02 +00:00
|
|
|
buttons_context_path(C, path, sbuts->mainb, pflag);
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!(flag & (1 << sbuts->mainb))) {
|
|
|
|
|
if (flag & (1 << BCONTEXT_OBJECT))
|
2012-05-08 15:30:00 +00:00
|
|
|
sbuts->mainb = BCONTEXT_OBJECT;
|
2009-06-07 13:36:12 +00:00
|
|
|
else
|
2012-05-08 15:30:00 +00:00
|
|
|
sbuts->mainb = BCONTEXT_SCENE;
|
2009-06-03 23:33:56 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (buttons_shading_context(C, sbuts->mainb))
|
2010-01-28 10:57:31 +00:00
|
|
|
sbuts->flag |= SB_SHADING_CONTEXT;
|
|
|
|
|
else
|
|
|
|
|
sbuts->flag &= ~SB_SHADING_CONTEXT;
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
sbuts->pathflag = flag;
|
2009-06-03 23:33:56 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-07 13:36:12 +00:00
|
|
|
/************************* Context Callback ************************/
|
|
|
|
|
|
2011-02-15 14:38:43 +00:00
|
|
|
const char *buttons_context_dir[] = {
|
2014-04-07 12:23:24 +02:00
|
|
|
"texture_slot", "scene", "world", "object", "mesh", "armature", "lattice", "curve",
|
2011-08-01 11:44:20 +00:00
|
|
|
"meta_ball", "lamp", "speaker", "camera", "material", "material_slot",
|
2013-04-28 15:20:52 +00:00
|
|
|
"texture", "texture_user", "texture_user_property", "bone", "edit_bone",
|
2012-07-25 12:07:19 +00:00
|
|
|
"pose_bone", "particle_system", "particle_system_editable", "particle_settings",
|
2014-05-03 18:51:53 +09:00
|
|
|
"cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint",
|
|
|
|
|
"line_style", NULL
|
2012-05-08 15:30:00 +00:00
|
|
|
};
|
2011-02-15 14:38:43 +00:00
|
|
|
|
2009-06-03 23:33:56 +00:00
|
|
|
int buttons_context(const bContext *C, const char *member, bContextDataResult *result)
|
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
SpaceButs *sbuts = CTX_wm_space_buts(C);
|
|
|
|
|
ButsContextPath *path = sbuts ? sbuts->path : NULL;
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!path)
|
2009-06-03 23:33:56 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* here we handle context, getting data from precomputed path */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (CTX_data_dir(member)) {
|
2012-11-09 17:12:39 +00:00
|
|
|
/* in case of new shading system we skip texture_slot, complex python
|
|
|
|
|
* UI script logic depends on checking if this is available */
|
|
|
|
|
if (sbuts->texuser)
|
|
|
|
|
CTX_data_dir_set(result, buttons_context_dir + 1);
|
|
|
|
|
else
|
|
|
|
|
CTX_data_dir_set(result, buttons_context_dir);
|
2009-06-20 14:55:28 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
2014-04-07 12:23:24 +02:00
|
|
|
else if (CTX_data_equals(member, "scene")) {
|
2014-04-07 17:13:06 +02:00
|
|
|
/* Do not return one here if scene not found in path, in this case we want to get default context scene! */
|
|
|
|
|
return set_pointer_type(path, result, &RNA_Scene);
|
2014-04-07 12:23:24 +02:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "world")) {
|
2009-06-03 23:33:56 +00:00
|
|
|
set_pointer_type(path, result, &RNA_World);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "object")) {
|
2009-06-03 23:33:56 +00:00
|
|
|
set_pointer_type(path, result, &RNA_Object);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "mesh")) {
|
2009-06-03 23:33:56 +00:00
|
|
|
set_pointer_type(path, result, &RNA_Mesh);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "armature")) {
|
2009-06-03 23:33:56 +00:00
|
|
|
set_pointer_type(path, result, &RNA_Armature);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "lattice")) {
|
2009-06-03 23:33:56 +00:00
|
|
|
set_pointer_type(path, result, &RNA_Lattice);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "curve")) {
|
2009-06-03 23:33:56 +00:00
|
|
|
set_pointer_type(path, result, &RNA_Curve);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "meta_ball")) {
|
2009-06-03 23:33:56 +00:00
|
|
|
set_pointer_type(path, result, &RNA_MetaBall);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "lamp")) {
|
2009-06-03 23:33:56 +00:00
|
|
|
set_pointer_type(path, result, &RNA_Lamp);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "camera")) {
|
2009-06-03 23:33:56 +00:00
|
|
|
set_pointer_type(path, result, &RNA_Camera);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "speaker")) {
|
2011-08-01 11:44:20 +00:00
|
|
|
set_pointer_type(path, result, &RNA_Speaker);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "material")) {
|
2009-06-07 13:36:12 +00:00
|
|
|
set_pointer_type(path, result, &RNA_Material);
|
2009-06-03 23:33:56 +00:00
|
|
|
return 1;
|
2009-06-03 00:01:22 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "texture")) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ButsContextTexture *ct = sbuts->texuser;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ct) {
|
2011-11-08 13:07:16 +00:00
|
|
|
/* new shading system */
|
|
|
|
|
CTX_data_pointer_set(result, &ct->texture->id, &RNA_Texture, ct->texture);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* old shading system */
|
|
|
|
|
set_pointer_type(path, result, &RNA_Texture);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-03 23:33:56 +00:00
|
|
|
return 1;
|
2009-06-03 00:01:22 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "material_slot")) {
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ptr) {
|
2012-05-08 15:30:00 +00:00
|
|
|
Object *ob = ptr->data;
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type) && ob->totcol) {
|
2011-10-03 16:55:00 +00:00
|
|
|
/* a valid actcol isn't ensured [#27526] */
|
2012-05-08 15:30:00 +00:00
|
|
|
int matnr = ob->actcol - 1;
|
|
|
|
|
if (matnr < 0) matnr = 0;
|
2011-10-03 16:55:00 +00:00
|
|
|
CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, &ob->mat[matnr]);
|
|
|
|
|
}
|
2009-06-07 13:36:12 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-03 23:33:56 +00:00
|
|
|
return 1;
|
2009-06-03 00:01:22 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "texture_user")) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ButsContextTexture *ct = sbuts->texuser;
|
2010-01-29 16:32:06 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ct)
|
2012-05-08 15:30:00 +00:00
|
|
|
return -1; /* old shading system (found but not available) */
|
2010-01-29 16:32:06 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ct->user && ct->user->ptr.data) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ButsTextureUser *user = ct->user;
|
2011-11-08 13:07:16 +00:00
|
|
|
CTX_data_pointer_set(result, user->ptr.id.data, user->ptr.type, user->ptr.data);
|
2010-01-29 16:32:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2013-04-28 15:20:52 +00:00
|
|
|
else if (CTX_data_equals(member, "texture_user_property")) {
|
|
|
|
|
ButsContextTexture *ct = sbuts->texuser;
|
|
|
|
|
|
|
|
|
|
if (!ct)
|
|
|
|
|
return -1; /* old shading system (found but not available) */
|
|
|
|
|
|
|
|
|
|
if (ct->user && ct->user->ptr.data) {
|
|
|
|
|
ButsTextureUser *user = ct->user;
|
|
|
|
|
CTX_data_pointer_set(result, NULL, &RNA_Property, user->prop);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "texture_node")) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ButsContextTexture *ct = sbuts->texuser;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ct) {
|
2011-11-08 13:07:16 +00:00
|
|
|
/* new shading system */
|
This commit addresses the somewhat weak handling of stackless textures in Blender with default (BI) renderer. To do so, it's defining an "other" texture context, and when in this one, it switches to using the "new shading" texture handling already known with Cycles engine.
So now, in the new "other" tex context, you can (depending on active data) have direct access to modifiers', force's or brushes' textures...
I also refactored a bit how texture contexts are handled (once again, we had some quite similar code in both space_buttons and RNA sources). This should also solve some harmless glitches like "no texture context selected in UI" sometimes when you remove data related to current texture (see e.g. after removing the material from default cube, in startup scene).
This usage of two different systems for textures, and the handling of switches between them, has been a bit tricky to get working right, but it is OK now I think. I also had to add a bool flag to buttons space, SB_TEX_USER_LIMITED (use_limited_texture_context in RNA), which indicates "new shading" texture code whether it has to ignore materials, lamps etc. (BI) or not (Cycles).
Btw, pinned textures from modifiers/force/etc. were also broken (showing nothing), now it should work too.
Thanks to Brecht for reviewing.
2013-05-17 07:10:10 +00:00
|
|
|
if (ct->user && ct->user->node) {
|
2011-11-08 13:07:16 +00:00
|
|
|
CTX_data_pointer_set(result, &ct->user->ntree->id, &RNA_Node, ct->user->node);
|
This commit addresses the somewhat weak handling of stackless textures in Blender with default (BI) renderer. To do so, it's defining an "other" texture context, and when in this one, it switches to using the "new shading" texture handling already known with Cycles engine.
So now, in the new "other" tex context, you can (depending on active data) have direct access to modifiers', force's or brushes' textures...
I also refactored a bit how texture contexts are handled (once again, we had some quite similar code in both space_buttons and RNA sources). This should also solve some harmless glitches like "no texture context selected in UI" sometimes when you remove data related to current texture (see e.g. after removing the material from default cube, in startup scene).
This usage of two different systems for textures, and the handling of switches between them, has been a bit tricky to get working right, but it is OK now I think. I also had to add a bool flag to buttons space, SB_TEX_USER_LIMITED (use_limited_texture_context in RNA), which indicates "new shading" texture code whether it has to ignore materials, lamps etc. (BI) or not (Cycles).
Btw, pinned textures from modifiers/force/etc. were also broken (showing nothing), now it should work too.
Thanks to Brecht for reviewing.
2013-05-17 07:10:10 +00:00
|
|
|
}
|
2011-11-08 13:07:16 +00:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* old shading system */
|
|
|
|
|
PointerRNA *ptr;
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
if ((ptr = get_pointer_type(path, &RNA_Material))) {
|
|
|
|
|
Material *ma = ptr->data;
|
2011-11-08 13:07:16 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma) {
|
2012-05-08 15:30:00 +00:00
|
|
|
bNode *node = give_current_material_texture_node(ma);
|
2011-11-16 13:49:51 +00:00
|
|
|
CTX_data_pointer_set(result, &ma->nodetree->id, &RNA_Node, node);
|
2011-11-08 13:07:16 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "texture_slot")) {
|
2012-05-08 15:30:00 +00:00
|
|
|
ButsContextTexture *ct = sbuts->texuser;
|
2009-06-07 13:36:12 +00:00
|
|
|
PointerRNA *ptr;
|
|
|
|
|
|
This commit addresses the somewhat weak handling of stackless textures in Blender with default (BI) renderer. To do so, it's defining an "other" texture context, and when in this one, it switches to using the "new shading" texture handling already known with Cycles engine.
So now, in the new "other" tex context, you can (depending on active data) have direct access to modifiers', force's or brushes' textures...
I also refactored a bit how texture contexts are handled (once again, we had some quite similar code in both space_buttons and RNA sources). This should also solve some harmless glitches like "no texture context selected in UI" sometimes when you remove data related to current texture (see e.g. after removing the material from default cube, in startup scene).
This usage of two different systems for textures, and the handling of switches between them, has been a bit tricky to get working right, but it is OK now I think. I also had to add a bool flag to buttons space, SB_TEX_USER_LIMITED (use_limited_texture_context in RNA), which indicates "new shading" texture code whether it has to ignore materials, lamps etc. (BI) or not (Cycles).
Btw, pinned textures from modifiers/force/etc. were also broken (showing nothing), now it should work too.
Thanks to Brecht for reviewing.
2013-05-17 07:10:10 +00:00
|
|
|
/* Particles slots are used in both old and new textures handling. */
|
|
|
|
|
if ((ptr = get_pointer_type(path, &RNA_ParticleSystem))) {
|
|
|
|
|
ParticleSettings *part = ((ParticleSystem *)ptr->data)->part;
|
2010-01-29 16:32:06 +00:00
|
|
|
|
This commit addresses the somewhat weak handling of stackless textures in Blender with default (BI) renderer. To do so, it's defining an "other" texture context, and when in this one, it switches to using the "new shading" texture handling already known with Cycles engine.
So now, in the new "other" tex context, you can (depending on active data) have direct access to modifiers', force's or brushes' textures...
I also refactored a bit how texture contexts are handled (once again, we had some quite similar code in both space_buttons and RNA sources). This should also solve some harmless glitches like "no texture context selected in UI" sometimes when you remove data related to current texture (see e.g. after removing the material from default cube, in startup scene).
This usage of two different systems for textures, and the handling of switches between them, has been a bit tricky to get working right, but it is OK now I think. I also had to add a bool flag to buttons space, SB_TEX_USER_LIMITED (use_limited_texture_context in RNA), which indicates "new shading" texture code whether it has to ignore materials, lamps etc. (BI) or not (Cycles).
Btw, pinned textures from modifiers/force/etc. were also broken (showing nothing), now it should work too.
Thanks to Brecht for reviewing.
2013-05-17 07:10:10 +00:00
|
|
|
if (part)
|
|
|
|
|
CTX_data_pointer_set(result, &part->id, &RNA_ParticleSettingsTextureSlot, part->mtex[(int)part->texact]);
|
|
|
|
|
}
|
|
|
|
|
else if (ct) {
|
|
|
|
|
return 0; /* new shading system */
|
|
|
|
|
}
|
|
|
|
|
else if ((ptr = get_pointer_type(path, &RNA_Material))) {
|
|
|
|
|
Material *ma = ptr->data;
|
2012-12-07 11:30:40 +00:00
|
|
|
|
2010-01-29 16:32:06 +00:00
|
|
|
/* if we have a node material, get slot from material in material node */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ma && ma->use_nodes && ma->nodetree) {
|
2010-04-22 06:59:41 +00:00
|
|
|
/* if there's an active texture node in the node tree,
|
|
|
|
|
* then that texture is in context directly, without a texture slot */
|
|
|
|
|
if (give_current_material_texture_node(ma))
|
|
|
|
|
return 0;
|
This commit addresses the somewhat weak handling of stackless textures in Blender with default (BI) renderer. To do so, it's defining an "other" texture context, and when in this one, it switches to using the "new shading" texture handling already known with Cycles engine.
So now, in the new "other" tex context, you can (depending on active data) have direct access to modifiers', force's or brushes' textures...
I also refactored a bit how texture contexts are handled (once again, we had some quite similar code in both space_buttons and RNA sources). This should also solve some harmless glitches like "no texture context selected in UI" sometimes when you remove data related to current texture (see e.g. after removing the material from default cube, in startup scene).
This usage of two different systems for textures, and the handling of switches between them, has been a bit tricky to get working right, but it is OK now I think. I also had to add a bool flag to buttons space, SB_TEX_USER_LIMITED (use_limited_texture_context in RNA), which indicates "new shading" texture code whether it has to ignore materials, lamps etc. (BI) or not (Cycles).
Btw, pinned textures from modifiers/force/etc. were also broken (showing nothing), now it should work too.
Thanks to Brecht for reviewing.
2013-05-17 07:10:10 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
ma = give_node_material(ma);
|
2010-04-22 06:59:41 +00:00
|
|
|
if (ma)
|
|
|
|
|
CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]);
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
|
else if (ma) {
|
2009-06-08 16:55:43 +00:00
|
|
|
CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]);
|
2010-04-22 06:59:41 +00:00
|
|
|
}
|
2009-06-07 13:36:12 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
else if ((ptr = get_pointer_type(path, &RNA_Lamp))) {
|
|
|
|
|
Lamp *la = ptr->data;
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (la)
|
2009-06-08 16:55:43 +00:00
|
|
|
CTX_data_pointer_set(result, &la->id, &RNA_LampTextureSlot, la->mtex[(int)la->texact]);
|
2009-06-07 13:36:12 +00:00
|
|
|
}
|
2012-05-08 15:30:00 +00:00
|
|
|
else if ((ptr = get_pointer_type(path, &RNA_World))) {
|
|
|
|
|
World *wo = ptr->data;
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (wo)
|
2009-06-08 16:55:43 +00:00
|
|
|
CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]);
|
2009-06-07 13:36:12 +00:00
|
|
|
}
|
2014-05-03 18:51:53 +09:00
|
|
|
else if ((ptr = get_pointer_type(path, &RNA_FreestyleLineStyle))) {
|
|
|
|
|
FreestyleLineStyle *ls = ptr->data;
|
|
|
|
|
|
|
|
|
|
if (ls)
|
|
|
|
|
CTX_data_pointer_set(result, &ls->id, &RNA_LineStyleTextureSlot, ls->mtex[(int)ls->texact]);
|
|
|
|
|
}
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2009-06-03 23:33:56 +00:00
|
|
|
return 1;
|
2009-06-03 00:01:22 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "bone")) {
|
2009-06-03 23:33:56 +00:00
|
|
|
set_pointer_type(path, result, &RNA_Bone);
|
|
|
|
|
return 1;
|
2009-06-03 00:01:22 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "edit_bone")) {
|
2009-06-19 14:56:49 +00:00
|
|
|
set_pointer_type(path, result, &RNA_EditBone);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "pose_bone")) {
|
2010-01-30 23:48:49 +00:00
|
|
|
set_pointer_type(path, result, &RNA_PoseBone);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "particle_system")) {
|
2009-06-03 23:33:56 +00:00
|
|
|
set_pointer_type(path, result, &RNA_ParticleSystem);
|
|
|
|
|
return 1;
|
2009-06-03 00:01:22 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "particle_system_editable")) {
|
2012-05-08 15:30:00 +00:00
|
|
|
if (PE_poll((bContext *)C))
|
2009-10-15 18:27:41 +00:00
|
|
|
set_pointer_type(path, result, &RNA_ParticleSystem);
|
|
|
|
|
else
|
|
|
|
|
CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL);
|
|
|
|
|
return 1;
|
2012-10-21 05:46:41 +00:00
|
|
|
}
|
2012-07-25 12:07:19 +00:00
|
|
|
else if (CTX_data_equals(member, "particle_settings")) {
|
|
|
|
|
/* only available when pinned */
|
|
|
|
|
PointerRNA *ptr = get_pointer_type(path, &RNA_ParticleSettings);
|
|
|
|
|
|
|
|
|
|
if (ptr && ptr->data) {
|
|
|
|
|
CTX_data_pointer_set(result, ptr->id.data, &RNA_ParticleSettings, ptr->data);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* get settings from active particle system instead */
|
2012-10-12 14:35:10 +00:00
|
|
|
ptr = get_pointer_type(path, &RNA_ParticleSystem);
|
2012-07-25 12:07:19 +00:00
|
|
|
|
|
|
|
|
if (ptr && ptr->data) {
|
|
|
|
|
ParticleSettings *part = ((ParticleSystem *)ptr->data)->part;
|
|
|
|
|
CTX_data_pointer_set(result, ptr->id.data, &RNA_ParticleSettings, part);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
set_pointer_type(path, result, &RNA_ParticleSettings);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "cloth")) {
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
|
2009-06-18 14:20:25 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ptr && ptr->data) {
|
2012-05-08 15:30:00 +00:00
|
|
|
Object *ob = ptr->data;
|
|
|
|
|
ModifierData *md = modifiers_findByType(ob, eModifierType_Cloth);
|
2009-06-18 14:20:25 +00:00
|
|
|
CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2009-06-03 00:01:22 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "soft_body")) {
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ptr && ptr->data) {
|
2012-05-08 15:30:00 +00:00
|
|
|
Object *ob = ptr->data;
|
|
|
|
|
ModifierData *md = modifiers_findByType(ob, eModifierType_Softbody);
|
2009-07-02 19:41:31 +00:00
|
|
|
CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodyModifier, md);
|
2009-06-03 00:01:22 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "fluid")) {
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ptr && ptr->data) {
|
2012-05-08 15:30:00 +00:00
|
|
|
Object *ob = ptr->data;
|
|
|
|
|
ModifierData *md = modifiers_findByType(ob, eModifierType_Fluidsim);
|
2009-06-03 00:01:22 +00:00
|
|
|
CTX_data_pointer_set(result, &ob->id, &RNA_FluidSimulationModifier, md);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-08-06 14:23:48 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "smoke")) {
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
|
2009-08-06 14:23:48 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ptr && ptr->data) {
|
2012-05-08 15:30:00 +00:00
|
|
|
Object *ob = ptr->data;
|
|
|
|
|
ModifierData *md = modifiers_findByType(ob, eModifierType_Smoke);
|
2009-08-06 14:23:48 +00:00
|
|
|
CTX_data_pointer_set(result, &ob->id, &RNA_SmokeModifier, md);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "collision")) {
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
|
2009-07-02 19:41:31 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ptr && ptr->data) {
|
2012-05-08 15:30:00 +00:00
|
|
|
Object *ob = ptr->data;
|
|
|
|
|
ModifierData *md = modifiers_findByType(ob, eModifierType_Collision);
|
2009-07-02 19:41:31 +00:00
|
|
|
CTX_data_pointer_set(result, &ob->id, &RNA_CollisionModifier, md);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "brush")) {
|
2009-07-25 22:31:02 +00:00
|
|
|
set_pointer_type(path, result, &RNA_Brush);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (CTX_data_equals(member, "dynamic_paint")) {
|
2012-05-08 15:30:00 +00:00
|
|
|
PointerRNA *ptr = get_pointer_type(path, &RNA_Object);
|
2011-05-24 07:08:58 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ptr && ptr->data) {
|
2012-05-08 15:30:00 +00:00
|
|
|
Object *ob = ptr->data;
|
|
|
|
|
ModifierData *md = modifiers_findByType(ob, eModifierType_DynamicPaint);
|
2011-05-24 07:08:58 +00:00
|
|
|
CTX_data_pointer_set(result, &ob->id, &RNA_DynamicPaintModifier, md);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-05-03 18:51:53 +09:00
|
|
|
else if (CTX_data_equals(member, "line_style")) {
|
|
|
|
|
set_pointer_type(path, result, &RNA_FreestyleLineStyle);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2009-11-10 15:09:53 +00:00
|
|
|
else {
|
|
|
|
|
return 0; /* not found */
|
|
|
|
|
}
|
2009-06-03 00:01:22 +00:00
|
|
|
|
2009-11-10 15:09:53 +00:00
|
|
|
return -1; /* found but not available */
|
2009-06-03 00:01:22 +00:00
|
|
|
}
|
|
|
|
|
|
2009-06-03 23:33:56 +00:00
|
|
|
/************************* Drawing the Path ************************/
|
|
|
|
|
|
2010-10-16 08:03:28 +00:00
|
|
|
static void pin_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
|
2009-06-07 13:36:12 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
SpaceButs *sbuts = CTX_wm_space_buts(C);
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sbuts->flag & SB_PIN_CONTEXT) {
|
2012-05-08 15:30:00 +00:00
|
|
|
sbuts->pinid = buttons_context_id_path(C);
|
2009-06-07 13:36:12 +00:00
|
|
|
}
|
|
|
|
|
else
|
2012-05-08 15:30:00 +00:00
|
|
|
sbuts->pinid = NULL;
|
2009-06-07 13:36:12 +00:00
|
|
|
|
|
|
|
|
ED_area_tag_redraw(CTX_wm_area(C));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void buttons_context_draw(const bContext *C, uiLayout *layout)
|
2009-06-03 23:33:56 +00:00
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
SpaceButs *sbuts = CTX_wm_space_buts(C);
|
|
|
|
|
ButsContextPath *path = sbuts->path;
|
2009-06-03 23:33:56 +00:00
|
|
|
uiLayout *row;
|
2009-06-07 13:36:12 +00:00
|
|
|
uiBlock *block;
|
|
|
|
|
uiBut *but;
|
2009-06-03 23:33:56 +00:00
|
|
|
PointerRNA *ptr;
|
|
|
|
|
char namebuf[128], *name;
|
|
|
|
|
int a, icon;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!path)
|
2009-06-03 23:33:56 +00:00
|
|
|
return;
|
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
row = uiLayoutRow(layout, true);
|
2009-06-03 23:33:56 +00:00
|
|
|
uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT);
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
block = uiLayoutGetBlock(row);
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_block_emboss_set(block, UI_EMBOSS_NONE);
|
|
|
|
|
but = uiDefIconButBitC(block, UI_BTYPE_ICON_TOGGLE, SB_PIN_CONTEXT, 0, ICON_UNPINNED, 0, 0, UI_UNIT_X, UI_UNIT_Y, &sbuts->flag,
|
2016-09-19 16:46:20 +02:00
|
|
|
0, 0, 0, 0, TIP_("Follow context or keep fixed data-block displayed"));
|
2014-11-09 21:20:40 +01:00
|
|
|
UI_but_flag_disable(but, UI_BUT_UNDO); /* skip undo on screen buttons */
|
|
|
|
|
UI_but_func_set(but, pin_cb, NULL, NULL);
|
2009-06-07 13:36:12 +00:00
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
for (a = 0; a < path->len; a++) {
|
|
|
|
|
ptr = &path->ptr[a];
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (a != 0)
|
2009-12-10 10:23:53 +00:00
|
|
|
uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC);
|
2009-07-08 15:34:41 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ptr->data) {
|
2012-05-08 15:30:00 +00:00
|
|
|
icon = RNA_struct_ui_icon(ptr->type);
|
|
|
|
|
name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL);
|
2009-06-03 23:33:56 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (name) {
|
2014-07-20 01:30:29 +10:00
|
|
|
if (!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE, BCONTEXT_RENDER_LAYER) && ptr->type == &RNA_Scene)
|
2012-05-08 15:30:00 +00:00
|
|
|
uiItemLDrag(row, ptr, "", icon); /* save some space */
|
2009-07-08 15:34:41 +00:00
|
|
|
else
|
Drag and drop 2.5 integration! Finally, slashdot regulars can use
Blender too now! :)
** Drag works as follows:
- drag-able items are defined by the standard interface ui toolkit
- each button can get this feature, via uiButSetDragXXX(but, ...).
There are calls to define drag-able images, ID blocks, RNA paths,
file paths, and so on. By default you drag an icon, exceptionally
an ImBuf
- Drag items are registered centrally in the WM, it allows more drag
items simultaneous too, but not implemented
** Drop works as follows:
- On mouse release, and if drag items exist in the WM, it converts
the mouse event to an EVT_DROP type. This event then gets the full
drag info as customdata
- drop regions are defined with WM_dropbox_add(), similar to keymaps
you can make a "drop map" this way, which become 'drop map handlers'
in the queues.
- next to that the UI kit handles some common button types (like
accepting ID or names) to be catching a drop event too.
- Every "drop box" has two callbacks:
- poll() = check if the event drag data is relevant for this box
- copy() = fill in custom properties in the dropbox to initialize
an operator
- The dropbox handler then calls its standard Operator with its
dropbox properties.
** Currently implemented
Drag items:
- ID icons in browse buttons
- ID icons in context menu of properties region
- ID icons in outliner and rna viewer
- FileBrowser icons
- FileBrowser preview images
Drag-able icons are subtly visualized by making them brighter a bit
on mouse-over. In case the icon is a button or UI element too (most
cases), the drag-able feature will make the item react to
mouse-release instead of mouse-press.
Drop options:
- UI buttons: ID and text buttons (paste name)
- View3d: Object ID drop copies object
- View3d: Material ID drop assigns to object under cursor
- View3d: Image ID drop assigns to object UV texture under cursor
- Sequencer: Path drop will add either Image or Movie strip
- Image window: Path drop will open image
** Drag and drop Notes:
- Dropping into another Blender window (from same application) works
too. I've added code that passes on mousemoves and clicks to other
windows, without activating them though. This does make using multi-window
Blender a bit friendler.
- Dropping a file path to an image, is not the same as dropping an
Image ID... keep this in mind. Sequencer for example wants paths to
be dropped, textures in 3d window wants an Image ID.
- Although drop boxes could be defined via Python, I suggest they're
part of the UI and editor design (= how we want an editor to work), and
not default offered configurable like keymaps.
- At the moment only one item can be dragged at a time. This is for
several reasons.... For one, Blender doesn't have a well defined
uniform way to define "what is selected" (files, outliner items, etc).
Secondly there's potential conflicts on what todo when you drop mixed
drag sets on spots. All undefined stuff... nice for later.
- Example to bypass the above: a collection of images that form a strip,
should be represented in filewindow as a single sequence anyway.
This then will fit well and gets handled neatly by design.
- Another option to check is to allow multiple options per drop... it
could show the operator as a sort of menu, allowing arrow or scrollwheel
to choose. For time being I'd prefer to try to design a singular drop
though, just offer only one drop action per data type on given spots.
- What does work already, but a tad slow, is to use a function that
detects an object (type) under cursor, so a drag item's option can be
further refined (like drop object on object = parent). (disabled)
** More notes
- Added saving for Region layouts (like split points for toolbar)
- Label buttons now handle mouse over
- File list: added full path entry for drop feature.
- Filesel bugfix: wm_operator_exec() got called there and fully handled,
while WM event code tried same. Added new OPERATOR_HANDLED flag for this.
Maybe python needs it too?
- Cocoa: added window move event, so multi-win setups work OK (didnt save).
- Interface_handlers.c: removed win->active
- Severe area copy bug: area handlers were not set to NULL
- Filesel bugfix: next/prev folder list was not copied on area copies
** Leftover todos
- Cocoa windows seem to hang on cases still... needs check
- Cocoa 'draw overlap' swap doesn't work
- Cocoa window loses focus permanently on using Spotlight
(for these reasons, makefile building has Carbon as default atm)
- ListView templates in UI cannot become dragged yet, needs review...
it consists of two overlapping UI elements, preventing handling icon clicks.
- There's already Ghost library code to handle dropping from OS
into Blender window. I've noticed this code is unfinished for Macs, but
seems to be complete for Windows. Needs test... currently, an external
drop event will print in console when succesfully delivered to Blender's WM.
2010-01-26 18:18:21 +00:00
|
|
|
uiItemLDrag(row, ptr, name, icon);
|
2014-01-03 15:47:59 +01:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (name != namebuf)
|
2009-06-03 23:33:56 +00:00
|
|
|
MEM_freeN(name);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
uiItemL(row, "", icon);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-07 13:36:12 +00:00
|
|
|
static void buttons_panel_context(const bContext *C, Panel *pa)
|
|
|
|
|
{
|
|
|
|
|
buttons_context_draw(C, pa->layout);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-03 23:33:56 +00:00
|
|
|
void buttons_context_register(ARegionType *art)
|
|
|
|
|
{
|
|
|
|
|
PanelType *pt;
|
|
|
|
|
|
2012-05-08 15:30:00 +00:00
|
|
|
pt = MEM_callocN(sizeof(PanelType), "spacetype buttons panel context");
|
2009-06-03 23:33:56 +00:00
|
|
|
strcpy(pt->idname, "BUTTONS_PT_context");
|
2013-02-19 15:45:56 +00:00
|
|
|
strcpy(pt->label, N_("Context")); /* XXX C panels are not available through RNA (bpy.types)! */
|
2015-08-16 17:32:01 +10:00
|
|
|
strcpy(pt->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA);
|
2012-05-08 15:30:00 +00:00
|
|
|
pt->draw = buttons_panel_context;
|
|
|
|
|
pt->flag = PNL_NO_HEADER;
|
2009-06-03 23:33:56 +00:00
|
|
|
BLI_addtail(&art->paneltypes, pt);
|
|
|
|
|
}
|
* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
/usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
2010-03-30 12:15:16 +00:00
|
|
|
|
|
|
|
|
ID *buttons_context_id_path(const bContext *C)
|
|
|
|
|
{
|
2012-05-08 15:30:00 +00:00
|
|
|
SpaceButs *sbuts = CTX_wm_space_buts(C);
|
|
|
|
|
ButsContextPath *path = sbuts->path;
|
* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
/usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
2010-03-30 12:15:16 +00:00
|
|
|
PointerRNA *ptr;
|
|
|
|
|
int a;
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (path->len) {
|
2012-05-08 15:30:00 +00:00
|
|
|
for (a = path->len - 1; a >= 0; a--) {
|
|
|
|
|
ptr = &path->ptr[a];
|
* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
/usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
2010-03-30 12:15:16 +00:00
|
|
|
|
2011-02-16 10:57:58 +00:00
|
|
|
/* pin particle settings instead of system, since only settings are an idblock*/
|
2012-03-24 06:38:07 +00:00
|
|
|
if (sbuts->mainb == BCONTEXT_PARTICLE && sbuts->flag & SB_PIN_CONTEXT) {
|
|
|
|
|
if (ptr->type == &RNA_ParticleSystem && ptr->data) {
|
2011-02-16 10:57:58 +00:00
|
|
|
ParticleSystem *psys = (ParticleSystem *)ptr->data;
|
|
|
|
|
return &psys->part->id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ptr->id.data) {
|
* Multiply for panorama cameras
* Some cases of struct name being set where it shouldnt have been.
* Spelling: wich --> which
* Copy and initialize uv modifier scale, remove unneeded enum.
* Ability to pin any object into the context.
* Update uv window while transforming (useful when used with UVProject modifier)
* Patch by Wahooney, so new template's are internal text and dont get saved over
by mistake.
* Fix for https://bugzilla.redhat.com/show_bug.cgi?id=572186
Bug 572186 - [abrt] crash in blender-2.49b-5.fc12: Process
/usr/bin/blender.bin was killed by signal 6 (SIGABRT). Original fix submitted
by Jochen Schmitt.
* [#21816] bpy.data.add_image has stopped working on Windows. moved to
bpy.data.images.load(), missed this call.
(commits 27726,27825,27828,27831,27832,27833,27834,27836,27837,27838,27839,27858 by Campbell from render25 branch)
2010-03-30 12:15:16 +00:00
|
|
|
return ptr->id.data;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|