diff options
Diffstat (limited to 'source/blender/editors/space_buttons')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_context.c | 41 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_header.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_intern.h | 27 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_ops.c | 990 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/space_buttons.c | 106 |
5 files changed, 44 insertions, 1130 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 635abd429f6..eb88ea8519e 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -52,6 +52,7 @@ #include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_screen.h" +#include "BKE_texture.h" #include "BKE_utildefines.h" #include "BKE_world.h" @@ -116,6 +117,7 @@ static int buttons_context_path_scene(ButsContextPath *path) static int buttons_context_path_world(ButsContextPath *path) { Scene *scene; + World *world; PointerRNA *ptr= &path->ptr[path->len-1]; /* if we already have a (pinned) world, we're done */ @@ -125,11 +127,14 @@ static int buttons_context_path_world(ButsContextPath *path) /* if we have a scene, use the scene's world */ else if(buttons_context_path_scene(path)) { scene= path->ptr[path->len-1].data; + world= scene->world; + + if(world) { + RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]); + path->len++; - RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]); - path->len++; - - return 1; + return 1; + } } /* no path to a world possible */ @@ -342,7 +347,6 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path Lamp *la; Brush *br; World *wo; - MTex *mtex; Tex *tex; PointerRNA *ptr= &path->ptr[path->len-1]; @@ -355,8 +359,7 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path br= path->ptr[path->len-1].data; if(br) { - mtex= br->mtex[(int)br->texact]; - tex= (mtex)? mtex->tex: NULL; + tex= give_current_brush_texture(br); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -368,8 +371,7 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path wo= path->ptr[path->len-1].data; if(wo) { - mtex= wo->mtex[(int)wo->texact]; - tex= (mtex)? mtex->tex: NULL; + tex= give_current_world_texture(wo); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -381,8 +383,7 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path ma= path->ptr[path->len-1].data; if(ma) { - mtex= ma->mtex[(int)ma->texact]; - tex= (mtex)? mtex->tex: NULL; + tex= give_current_material_texture(ma); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -394,8 +395,7 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path la= path->ptr[path->len-1].data; if(la) { - mtex= la->mtex[(int)la->texact]; - tex= (mtex)? mtex->tex: NULL; + tex= give_current_lamp_texture(la); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -437,6 +437,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma * tracing back recursively */ switch(mainb) { case BCONTEXT_SCENE: + case BCONTEXT_RENDER: found= buttons_context_path_scene(path); break; case BCONTEXT_WORLD: @@ -463,6 +464,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma found= buttons_context_path_texture(C, path); break; case BCONTEXT_BONE: + case BCONTEXT_BONE_CONSTRAINT: found= buttons_context_path_bone(path); if(!found) found= buttons_context_path_data(path, OB_ARMATURE); @@ -552,8 +554,8 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r static const char *dir[] = { "world", "object", "mesh", "armature", "lattice", "curve", "meta_ball", "lamp", "camera", "material", "material_slot", - "texture", "texture_slot", "bone", "edit_bone", "particle_system", - "cloth", "soft_body", "fluid", "smoke", "smoke_hr", "collision", "brush", NULL}; + "texture", "texture_slot", "bone", "edit_bone", "particle_system", "particle_system_editable", + "cloth", "soft_body", "fluid", "smoke", "collision", "brush", NULL}; CTX_data_dir_set(result, dir); return 1; @@ -656,6 +658,13 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r set_pointer_type(path, result, &RNA_ParticleSystem); return 1; } + else if(CTX_data_equals(member, "particle_system_editable")) { + if(PE_poll(C)) + set_pointer_type(path, result, &RNA_ParticleSystem); + else + CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL); + return 1; + } else if(CTX_data_equals(member, "cloth")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); @@ -775,7 +784,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf)); if(name) { - if(sbuts->mainb != BCONTEXT_SCENE && ptr->type == &RNA_Scene) + if(!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene) uiItemL(row, "", icon); /* save some space */ else uiItemL(row, name, icon); diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index a1041bc5106..1bf2a058b5a 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -107,20 +107,24 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) // Default panels uiBlockBeginAlign(block); + if(sbuts->pathflag & (1<<BCONTEXT_RENDER)) + uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_SCENE, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_RENDER, 0, 0, "Render"); if(sbuts->pathflag & (1<<BCONTEXT_SCENE)) - uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_SCENE, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_SCENE, 0, 0, "Scene"); + uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_SCENE_DATA, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_SCENE, 0, 0, "Scene"); if(sbuts->pathflag & (1<<BCONTEXT_WORLD)) uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_WORLD, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_WORLD, 0, 0, "World"); if(sbuts->pathflag & (1<<BCONTEXT_OBJECT)) uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_OBJECT_DATA, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_OBJECT, 0, 0, "Object"); if(sbuts->pathflag & (1<<BCONTEXT_CONSTRAINT)) - uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_CONSTRAINT, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_CONSTRAINT, 0, 0, "Constraint"); + uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_CONSTRAINT, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_CONSTRAINT, 0, 0, "Object Constraints"); if(sbuts->pathflag & (1<<BCONTEXT_DATA)) uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, sbuts->dataicon, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_DATA, 0, 0, "Object Data"); if(sbuts->pathflag & (1<<BCONTEXT_MODIFIER)) - uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MODIFIER, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_MODIFIER, 0, 0, "Modifier"); + uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MODIFIER, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_MODIFIER, 0, 0, "Modifiers"); if(sbuts->pathflag & (1<<BCONTEXT_BONE)) uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_BONE_DATA, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE, 0, 0, "Bone"); + if(sbuts->pathflag & (1<<BCONTEXT_BONE_CONSTRAINT)) + uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_CONSTRAINT, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_BONE_CONSTRAINT, 0, 0, "Bone Constraints"); if(sbuts->pathflag & (1<<BCONTEXT_MATERIAL)) uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, ICON_MATERIAL, xco+=BUTS_UI_UNIT, yco, BUTS_UI_UNIT, BUTS_UI_UNIT, &(sbuts->mainb), 0.0, (float)BCONTEXT_MATERIAL, 0, 0, "Material"); if(sbuts->pathflag & (1<<BCONTEXT_TEXTURE)) diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index 0a5a5714a06..2e95fde8f99 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -64,33 +64,6 @@ void buttons_context_draw(const struct bContext *C, struct uiLayout *layout); void buttons_context_register(struct ARegionType *art); /* buttons_ops.c */ -void OBJECT_OT_group_add(struct wmOperatorType *ot); -void OBJECT_OT_group_remove(struct wmOperatorType *ot); - -void OBJECT_OT_material_slot_add(struct wmOperatorType *ot); -void OBJECT_OT_material_slot_remove(struct wmOperatorType *ot); -void OBJECT_OT_material_slot_assign(struct wmOperatorType *ot); -void OBJECT_OT_material_slot_select(struct wmOperatorType *ot); -void OBJECT_OT_material_slot_deselect(struct wmOperatorType *ot); - -void MATERIAL_OT_new(struct wmOperatorType *ot); -void TEXTURE_OT_new(struct wmOperatorType *ot); -void WORLD_OT_new(struct wmOperatorType *ot); - -void OBJECT_OT_particle_system_add(struct wmOperatorType *ot); -void OBJECT_OT_particle_system_remove(struct wmOperatorType *ot); - -void PARTICLE_OT_new(struct wmOperatorType *ot); -void PARTICLE_OT_new_target(struct wmOperatorType *ot); -void PARTICLE_OT_remove_target(struct wmOperatorType *ot); -void PARTICLE_OT_target_move_up(struct wmOperatorType *ot); -void PARTICLE_OT_target_move_down(struct wmOperatorType *ot); -void PARTICLE_OT_connect_hair(struct wmOperatorType *ot); -void PARTICLE_OT_disconnect_hair(struct wmOperatorType *ot); - -void SCENE_OT_render_layer_add(struct wmOperatorType *ot); -void SCENE_OT_render_layer_remove(struct wmOperatorType *ot); - void BUTTONS_OT_file_browse(struct wmOperatorType *ot); void BUTTONS_OT_toolbox(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index b68ea35d118..634b3e36ea7 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -30,54 +30,14 @@ #include "MEM_guardedalloc.h" -#include "DNA_boid_types.h" -#include "DNA_curve_types.h" -#include "DNA_group_types.h" -#include "DNA_object_types.h" -#include "DNA_material_types.h" -#include "DNA_meshdata_types.h" -#include "DNA_modifier_types.h" -#include "DNA_node_types.h" -#include "DNA_texture_types.h" -#include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" -#include "DNA_world_types.h" -#include "BKE_bvhutils.h" -#include "BKE_cdderivedmesh.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" -#include "BKE_DerivedMesh.h" -#include "BKE_group.h" -#include "BKE_font.h" -#include "BKE_library.h" -#include "BKE_main.h" -#include "BKE_material.h" -#include "BKE_modifier.h" -#include "BKE_node.h" -#include "BKE_particle.h" -#include "BKE_pointcache.h" -#include "BKE_scene.h" -#include "BKE_texture.h" -#include "BKE_utildefines.h" -#include "BKE_world.h" -#include "BKE_tessmesh.h" - -#include "BLI_arithb.h" -#include "BLI_editVert.h" -#include "BLI_listbase.h" - -#include "RNA_access.h" -#include "RNA_enum_types.h" #include "WM_api.h" #include "WM_types.h" -#include "ED_curve.h" -#include "ED_mesh.h" -#include "ED_particle.h" - #include "RNA_access.h" #include "RNA_define.h" @@ -86,950 +46,6 @@ #include "buttons_intern.h" // own include - -/********************** material slot operators *********************/ - -static int material_slot_add_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; - - if(!ob) - return OPERATOR_CANCELLED; - - object_add_material_slot(ob); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - - return OPERATOR_FINISHED; -} - -void OBJECT_OT_material_slot_add(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Add Material Slot"; - ot->idname= "OBJECT_OT_material_slot_add"; - ot->description="Add a new material slot or duplicate the selected one."; - - /* api callbacks */ - ot->exec= material_slot_add_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -static int material_slot_remove_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; - - if(!ob) - return OPERATOR_CANCELLED; - - object_remove_material_slot(ob); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - - return OPERATOR_FINISHED; -} - -void OBJECT_OT_material_slot_remove(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Remove Material Slot"; - ot->idname= "OBJECT_OT_material_slot_remove"; - ot->description="Remove the selected material slot."; - - /* api callbacks */ - ot->exec= material_slot_remove_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -static int material_slot_assign_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; - - if(!ob) - return OPERATOR_CANCELLED; - - if(ob && ob->actcol>0) { - if(ob->type == OB_MESH) { - BMEditMesh *em= ((Mesh*)ob->data)->edit_btmesh; - BMFace *efa; - BMIter iter; - - if(em) { - BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) - if(BM_TestHFlag(efa, BM_SELECT)) - efa->mat_nr= ob->actcol-1; - } - } - else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { - ListBase *editnurb= ((Curve*)ob->data)->editnurb; - Nurb *nu; - - if(editnurb) { - for(nu= editnurb->first; nu; nu= nu->next) - if(isNurbsel(nu)) - nu->mat_nr= nu->charidx= ob->actcol-1; - } - } - else if(ob->type == OB_FONT) { - EditFont *ef= ((Curve*)ob->data)->editfont; - int i, selstart, selend; - - if(ef && BKE_font_getselection(ob, &selstart, &selend)) { - for(i=selstart; i<=selend; i++) - ef->textbufinfo[i].mat_nr = ob->actcol-1; - } - } - } - - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data); - - return OPERATOR_FINISHED; -} - -void OBJECT_OT_material_slot_assign(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Assign Material Slot"; - ot->idname= "OBJECT_OT_material_slot_assign"; - ot->description="Assign the material in the selected material slot to the selected vertices."; - - /* api callbacks */ - ot->exec= material_slot_assign_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -static int material_slot_de_select(bContext *C, int select) -{ - Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; - - if(!ob) - return OPERATOR_CANCELLED; - - if(ob->type == OB_MESH) { - EditMesh *em= BKE_mesh_get_editmesh(((Mesh*)ob->data)); - - if(em) { - if(select) - EM_select_by_material(em, ob->actcol-1); - else - EM_deselect_by_material(em, ob->actcol-1); - } - - BKE_mesh_end_editmesh(ob->data, em); - } - else if ELEM(ob->type, OB_CURVE, OB_SURF) { - ListBase *editnurb= ((Curve*)ob->data)->editnurb; - Nurb *nu; - BPoint *bp; - BezTriple *bezt; - int a; - - for(nu= editnurb->first; nu; nu=nu->next) { - if(nu->mat_nr==ob->actcol-1) { - if(nu->bezt) { - a= nu->pntsu; - bezt= nu->bezt; - while(a--) { - if(bezt->hide==0) { - if(select) { - bezt->f1 |= SELECT; - bezt->f2 |= SELECT; - bezt->f3 |= SELECT; - } - else { - bezt->f1 &= ~SELECT; - bezt->f2 &= ~SELECT; - bezt->f3 &= ~SELECT; - } - } - bezt++; - } - } - else if(nu->bp) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - while(a--) { - if(bp->hide==0) { - if(select) bp->f1 |= SELECT; - else bp->f1 &= ~SELECT; - } - bp++; - } - } - } - } - } - - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data); - - return OPERATOR_FINISHED; -} - -static int material_slot_select_exec(bContext *C, wmOperator *op) -{ - return material_slot_de_select(C, 1); -} - -void OBJECT_OT_material_slot_select(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Select Material Slot"; - ot->idname= "OBJECT_OT_material_slot_select"; - ot->description="Select vertices assigned to the selected material slot."; - - /* api callbacks */ - ot->exec= material_slot_select_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -static int material_slot_deselect_exec(bContext *C, wmOperator *op) -{ - return material_slot_de_select(C, 0); -} - -void OBJECT_OT_material_slot_deselect(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Deselect Material Slot"; - ot->idname= "OBJECT_OT_material_slot_deselect"; - ot->description="Deselect vertices assigned to the selected material slot."; - - /* api callbacks */ - ot->exec= material_slot_deselect_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -/********************** new material operator *********************/ - -static int new_material_exec(bContext *C, wmOperator *op) -{ - Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data; - Object *ob; - PointerRNA ptr; - int index; - - /* add or copy material */ - 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_type(C, "material_slot", &RNA_MaterialSlot); - - if(ptr.data) { - 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); - } - - WM_event_add_notifier(C, NC_MATERIAL|NA_ADDED, ma); - - return OPERATOR_FINISHED; -} - -void MATERIAL_OT_new(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "New Material"; - ot->idname= "MATERIAL_OT_new"; - ot->description="Add a new material."; - - /* 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) -{ - Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; - ID *id; - MTex *mtex; - PointerRNA ptr; - - /* add or copy texture */ - 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_type(C, "texture_slot", &RNA_TextureSlot); - - if(ptr.data) { - 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 .. */ - } - - WM_event_add_notifier(C, NC_TEXTURE|NA_ADDED, tex); - - return OPERATOR_FINISHED; -} - -void TEXTURE_OT_new(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "New Texture"; - ot->idname= "TEXTURE_OT_new"; - ot->description="Add a new texture."; - - /* 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) -{ - Scene *scene= CTX_data_scene(C); - World *wo= CTX_data_pointer_get_type(C, "world", &RNA_World).data; - - /* add or copy world */ - if(wo) - wo= copy_world(wo); - else - wo= add_world("World"); - - /* assign to scene */ - if(scene->world) - id_us_min(&scene->world->id); - scene->world= wo; - - WM_event_add_notifier(C, NC_WORLD|NA_ADDED, wo); - - return OPERATOR_FINISHED; -} - -void WORLD_OT_new(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "New World"; - ot->idname= "WORLD_OT_new"; - ot->description= "Add a new world."; - - /* api callbacks */ - ot->exec= new_world_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - - - -/********************** particle system slot operators *********************/ - -static int particle_system_add_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; - Scene *scene = CTX_data_scene(C); - - if(!scene || !ob) - return OPERATOR_CANCELLED; - - object_add_particle_system(scene, ob); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - - return OPERATOR_FINISHED; -} - -void OBJECT_OT_particle_system_add(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Add Particle System Slot"; - ot->idname= "OBJECT_OT_particle_system_add"; - ot->description="Add a particle system."; - - /* api callbacks */ - ot->exec= particle_system_add_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -static int particle_system_remove_exec(bContext *C, wmOperator *op) -{ - Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; - Scene *scene = CTX_data_scene(C); - - if(!scene || !ob) - return OPERATOR_CANCELLED; - - object_remove_particle_system(scene, ob); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - - return OPERATOR_FINISHED; -} - -void OBJECT_OT_particle_system_remove(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Remove Particle System Slot"; - ot->idname= "OBJECT_OT_particle_system_remove"; - ot->description="Remove the selected particle system."; - - /* api callbacks */ - ot->exec= particle_system_remove_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -/********************** new particle settings operator *********************/ - -static int psys_poll(bContext *C) -{ - PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); - return (ptr.data != NULL); -} - -static int new_particle_settings_exec(bContext *C, wmOperator *op) -{ - Scene *scene = CTX_data_scene(C); - Main *bmain= CTX_data_main(C); - ParticleSystem *psys; - ParticleSettings *part = NULL; - Object *ob; - PointerRNA ptr; - - ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); - - psys = ptr.data; - - /* add or copy particle setting */ - if(psys->part) - part= psys_copy_settings(psys->part); - else - part= psys_new_settings("ParticleSettings", bmain); - - ob= ptr.id.data; - - if(psys->part) - psys->part->id.us--; - - psys->part = part; - - psys_check_boid_data(psys); - - DAG_scene_sort(scene); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - - return OPERATOR_FINISHED; -} - -void PARTICLE_OT_new(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "New Particle Settings"; - ot->idname= "PARTICLE_OT_new"; - ot->description="Add new particle settings."; - - /* api callbacks */ - ot->exec= new_particle_settings_exec; - ot->poll= psys_poll; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -/********************** keyed particle target operators *********************/ - -static int new_particle_target_exec(bContext *C, wmOperator *op) -{ - Scene *scene = CTX_data_scene(C); - PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); - ParticleSystem *psys= ptr.data; - Object *ob = ptr.id.data; - - ParticleTarget *pt; - - if(!psys) - return OPERATOR_CANCELLED; - - pt = psys->targets.first; - for(; pt; pt=pt->next) - pt->flag &= ~PTARGET_CURRENT; - - pt = MEM_callocN(sizeof(ParticleTarget), "keyed particle target"); - - pt->flag |= PTARGET_CURRENT; - pt->psys = 1; - - BLI_addtail(&psys->targets, pt); - - DAG_scene_sort(scene); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - - return OPERATOR_FINISHED; -} - -void PARTICLE_OT_new_target(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "New Particle Target"; - ot->idname= "PARTICLE_OT_new_target"; - ot->description="Add a new particle target."; - - /* api callbacks */ - ot->exec= new_particle_target_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -static int remove_particle_target_exec(bContext *C, wmOperator *op) -{ - Scene *scene = CTX_data_scene(C); - PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); - ParticleSystem *psys= ptr.data; - Object *ob = ptr.id.data; - - ParticleTarget *pt; - - if(!psys) - return OPERATOR_CANCELLED; - - pt = psys->targets.first; - for(; pt; pt=pt->next) { - if(pt->flag & PTARGET_CURRENT) { - BLI_remlink(&psys->targets, pt); - MEM_freeN(pt); - break; - } - - } - pt = psys->targets.last; - - if(pt) - pt->flag |= PTARGET_CURRENT; - - DAG_scene_sort(scene); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - - return OPERATOR_FINISHED; -} - -void PARTICLE_OT_remove_target(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Remove Particle Target"; - ot->idname= "PARTICLE_OT_remove_target"; - ot->description="Remove the selected particle target."; - - /* api callbacks */ - ot->exec= remove_particle_target_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -/************************ move up particle target operator *********************/ - -static int target_move_up_exec(bContext *C, wmOperator *op) -{ - PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); - ParticleSystem *psys= ptr.data; - Object *ob = ptr.id.data; - ParticleTarget *pt; - - if(!psys) - return OPERATOR_CANCELLED; - - pt = psys->targets.first; - for(; pt; pt=pt->next) { - if(pt->flag & PTARGET_CURRENT && pt->prev) { - BLI_remlink(&psys->targets, pt); - BLI_insertlink(&psys->targets, pt->prev->prev, pt); - - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - break; - } - } - - return OPERATOR_FINISHED; -} - -void PARTICLE_OT_target_move_up(wmOperatorType *ot) -{ - ot->name= "Move Up Target"; - ot->idname= "PARTICLE_OT_target_move_up"; - ot->description= "Move particle target up in the list."; - - ot->exec= target_move_up_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -/************************ move down particle target operator *********************/ - -static int target_move_down_exec(bContext *C, wmOperator *op) -{ - PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); - ParticleSystem *psys= ptr.data; - Object *ob = ptr.id.data; - ParticleTarget *pt; - - if(!psys) - return OPERATOR_CANCELLED; - pt = psys->targets.first; - for(; pt; pt=pt->next) { - if(pt->flag & PTARGET_CURRENT && pt->next) { - BLI_remlink(&psys->targets, pt); - BLI_insertlink(&psys->targets, pt->next, pt); - - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - break; - } - } - - return OPERATOR_FINISHED; -} - -void PARTICLE_OT_target_move_down(wmOperatorType *ot) -{ - ot->name= "Move Down Target"; - ot->idname= "PARTICLE_OT_target_move_down"; - ot->description= "Move particle target down in the list."; - - ot->exec= target_move_down_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -/************************ connect/disconnect hair operators *********************/ - -static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys) -{ - ParticleSystemModifierData *psmd = psys_get_modifier(ob,psys); - ParticleData *pa = psys->particles; - PTCacheEdit *edit = psys->edit; - PTCacheEditPoint *point = edit ? edit->points : NULL; - PTCacheEditKey *ekey = NULL; - HairKey *key; - int i, k; - float hairmat[4][4]; - - if(!ob || !psys || psys->flag & PSYS_GLOBAL_HAIR) - return; - - if(!psys->part || psys->part->type != PART_HAIR) - return; - - for(i=0; i<psys->totpart; i++,pa++) { - if(point) { - ekey = point->keys; - point++; - } - - psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); - - for(k=0,key=pa->hair; k<pa->totkey; k++,key++) { - Mat4MulVecfl(hairmat,key->co); - - if(ekey) { - ekey->flag &= ~PEK_USE_WCO; - ekey++; - } - } - } - - psys_free_path_cache(psys, psys->edit); - - psys->flag |= PSYS_GLOBAL_HAIR; - - PE_update_object(scene, ob, 0); -} - -static int disconnect_hair_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; - PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); - ParticleSystem *psys= NULL; - int all = RNA_boolean_get(op->ptr, "all"); - - if(!ob) - return OPERATOR_CANCELLED; - - if(all) { - for(psys=ob->particlesystem.first; psys; psys=psys->next) { - disconnect_hair(scene, ob, psys); - } - } - else { - psys = ptr.data; - disconnect_hair(scene, ob, psys); - } - - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - - return OPERATOR_FINISHED; -} - -void PARTICLE_OT_disconnect_hair(wmOperatorType *ot) -{ - ot->name= "Disconnect Hair"; - ot->description= "Disconnect hair from the emitter mesh."; - ot->idname= "PARTICLE_OT_disconnect_hair"; - - ot->exec= disconnect_hair_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_boolean(ot->srna, "all", 0, "All hair", "Disconnect all hair systems from the emitter mesh"); -} - -static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) -{ - ParticleSystemModifierData *psmd = psys_get_modifier(ob,psys); - ParticleData *pa = psys->particles; - PTCacheEdit *edit = psys->edit; - PTCacheEditPoint *point = edit ? edit->points : NULL; - PTCacheEditKey *ekey; - HairKey *key; - BVHTreeFromMesh bvhtree; - BVHTreeNearest nearest; - MFace *mface; - DerivedMesh *dm = NULL; - int numverts; - int i, k; - float hairmat[4][4], imat[4][4]; - float v[4][3], vec[3]; - - if(!psys || !psys->part || psys->part->type != PART_HAIR) - return; - - if(psmd->dm->deformedOnly) - dm= psmd->dm; - else - dm= mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); - - numverts = dm->getNumVerts (dm); - - memset( &bvhtree, 0, sizeof(bvhtree) ); - - /* convert to global coordinates */ - for (i=0; i<numverts; i++) - Mat4MulVecfl (ob->obmat, CDDM_get_vert(dm, i)->co); - - bvhtree_from_mesh_faces(&bvhtree, dm, 0.0, 2, 6); - - for(i=0; i<psys->totpart; i++,pa++) { - key = pa->hair; - - nearest.index = -1; - nearest.dist = FLT_MAX; - - BLI_bvhtree_find_nearest(bvhtree.tree, key->co, &nearest, bvhtree.nearest_callback, &bvhtree); - - if(nearest.index == -1) { - printf("No nearest point found for hair root!"); - continue; - } - - mface = CDDM_get_tessface(dm,nearest.index); - - VecCopyf(v[0], CDDM_get_vert(dm,mface->v1)->co); - VecCopyf(v[1], CDDM_get_vert(dm,mface->v2)->co); - VecCopyf(v[2], CDDM_get_vert(dm,mface->v3)->co); - if(mface->v4) { - VecCopyf(v[3], CDDM_get_vert(dm,mface->v4)->co); - MeanValueWeights(v, 4, nearest.co, pa->fuv); - } - else - MeanValueWeights(v, 3, nearest.co, pa->fuv); - - pa->num = nearest.index; - pa->num_dmcache = psys_particle_dm_face_lookup(ob,psmd->dm,pa->num,pa->fuv,NULL); - - psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); - Mat4Invert(imat,hairmat); - - VECSUB(vec, nearest.co, key->co); - - if(point) { - ekey = point->keys; - point++; - } - - for(k=0,key=pa->hair; k<pa->totkey; k++,key++) { - VECADD(key->co, key->co, vec); - Mat4MulVecfl(imat,key->co); - - if(ekey) { - ekey->flag |= PEK_USE_WCO; - ekey++; - } - } - } - - free_bvhtree_from_mesh(&bvhtree); - if(!psmd->dm->deformedOnly) - dm->release(dm); - - psys_free_path_cache(psys, psys->edit); - - psys->flag &= ~PSYS_GLOBAL_HAIR; - - PE_update_object(scene, ob, 0); -} - -static int connect_hair_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; - PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); - ParticleSystem *psys= NULL; - int all = RNA_boolean_get(op->ptr, "all"); - - if(!ob) - return OPERATOR_CANCELLED; - - if(all) { - for(psys=ob->particlesystem.first; psys; psys=psys->next) { - connect_hair(scene, ob, psys); - } - } - else { - psys = ptr.data; - connect_hair(scene, ob, psys); - } - - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); - - return OPERATOR_FINISHED; -} - -void PARTICLE_OT_connect_hair(wmOperatorType *ot) -{ - ot->name= "Connect Hair"; - ot->description= "Connect hair to the emitter mesh."; - ot->idname= "PARTICLE_OT_connect_hair"; - - ot->exec= connect_hair_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_boolean(ot->srna, "all", 0, "All hair", "Connect all hair systems to the emitter mesh"); -} - -/********************** render layer operators *********************/ - -static int render_layer_add_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - - scene_add_render_layer(scene); - scene->r.actlay= BLI_countlist(&scene->r.layers) - 1; - - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); - - return OPERATOR_FINISHED; -} - -void SCENE_OT_render_layer_add(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Add Render Layer"; - ot->idname= "SCENE_OT_render_layer_add"; - ot->description="Add a render layer."; - - /* api callbacks */ - ot->exec= render_layer_add_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - -static int render_layer_remove_exec(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - SceneRenderLayer *rl; - int act= scene->r.actlay; - - if(BLI_countlist(&scene->r.layers) <= 1) - return OPERATOR_CANCELLED; - - rl= BLI_findlink(&scene->r.layers, scene->r.actlay); - BLI_remlink(&scene->r.layers, rl); - MEM_freeN(rl); - - scene->r.actlay= 0; - - if(scene->nodetree) { - bNode *node; - for(node= scene->nodetree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_R_LAYERS && node->id==NULL) { - if(node->custom1==act) - node->custom1= 0; - else if(node->custom1>act) - node->custom1--; - } - } - } - - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); - - return OPERATOR_FINISHED; -} - -void SCENE_OT_render_layer_remove(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Remove Render Layer"; - ot->idname= "SCENE_OT_render_layer_remove"; - ot->description="Remove the selected render layer."; - - /* api callbacks */ - ot->exec= render_layer_remove_exec; - - /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; -} - /********************** toolbox operator *********************/ static int toolbox_invoke(bContext *C, wmOperator *op, wmEvent *event) @@ -1054,8 +70,8 @@ void BUTTONS_OT_toolbox(wmOperatorType *ot) { /* identifiers */ ot->name= "Toolbox"; + ot->description="Display button panel toolbox"; ot->idname= "BUTTONS_OT_toolbox"; - ot->description="Toolbar panel? DOC_BROKEN"; /* api callbacks */ ot->invoke= toolbox_invoke; @@ -1111,7 +127,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) op->customdata= fbo; str= RNA_property_string_get_alloc(&ptr, prop, 0, 0); - RNA_string_set(op->ptr, "filename", str); + RNA_string_set(op->ptr, "path", str); MEM_freeN(str); WM_event_add_fileselect(C, op); @@ -1123,8 +139,8 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot) { /* identifiers */ ot->name= "File Browse"; - ot->idname= "BUTTONS_OT_file_browse"; ot->description="Open a file browser."; + ot->idname= "BUTTONS_OT_file_browse"; /* api callbacks */ ot->invoke= file_browse_invoke; diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index d4ad77daca7..c1f06d99985 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -57,7 +57,7 @@ #include "UI_resources.h" #include "UI_view2d.h" -#include "ED_previewrender.h" +#include "ED_render.h" #include "buttons_intern.h" // own include @@ -138,11 +138,11 @@ static SpaceLink *buttons_duplicate(SpaceLink *sl) /* add handlers, stuff you only do once or on area/region changes */ static void buttons_main_area_init(wmWindowManager *wm, ARegion *ar) { - ListBase *keymap; + wmKeyMap *keymap; ED_region_panels_init(wm, ar); - keymap= WM_keymap_listbase(wm, "Buttons Generic", SPACE_BUTS, 0); + keymap= WM_keymap_find(wm->defaultconf, "Buttons Generic", SPACE_BUTS, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -156,6 +156,8 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar) if(sbuts->mainb == BCONTEXT_SCENE) ED_region_panels(C, ar, vertical, "scene", sbuts->mainb); + else if(sbuts->mainb == BCONTEXT_RENDER) + ED_region_panels(C, ar, vertical, "render", sbuts->mainb); else if(sbuts->mainb == BCONTEXT_WORLD) ED_region_panels(C, ar, vertical, "world", sbuts->mainb); else if(sbuts->mainb == BCONTEXT_OBJECT) @@ -176,6 +178,8 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar) ED_region_panels(C, ar, vertical, "modifier", sbuts->mainb); else if (sbuts->mainb == BCONTEXT_CONSTRAINT) ED_region_panels(C, ar, vertical, "constraint", sbuts->mainb); + else if(sbuts->mainb == BCONTEXT_BONE_CONSTRAINT) + ED_region_panels(C, ar, vertical, "bone_constraint", sbuts->mainb); sbuts->re_align= 0; sbuts->mainbo= sbuts->mainb; @@ -183,40 +187,13 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar) void buttons_operatortypes(void) { - WM_operatortype_append(OBJECT_OT_group_add); - WM_operatortype_append(OBJECT_OT_group_remove); - - WM_operatortype_append(OBJECT_OT_material_slot_add); - WM_operatortype_append(OBJECT_OT_material_slot_remove); - WM_operatortype_append(OBJECT_OT_material_slot_assign); - WM_operatortype_append(OBJECT_OT_material_slot_select); - WM_operatortype_append(OBJECT_OT_material_slot_deselect); - - WM_operatortype_append(MATERIAL_OT_new); - WM_operatortype_append(TEXTURE_OT_new); - WM_operatortype_append(WORLD_OT_new); - - WM_operatortype_append(OBJECT_OT_particle_system_add); - WM_operatortype_append(OBJECT_OT_particle_system_remove); - - WM_operatortype_append(PARTICLE_OT_new); - WM_operatortype_append(PARTICLE_OT_new_target); - WM_operatortype_append(PARTICLE_OT_remove_target); - WM_operatortype_append(PARTICLE_OT_target_move_up); - WM_operatortype_append(PARTICLE_OT_target_move_down); - WM_operatortype_append(PARTICLE_OT_connect_hair); - WM_operatortype_append(PARTICLE_OT_disconnect_hair); - - WM_operatortype_append(SCENE_OT_render_layer_add); - WM_operatortype_append(SCENE_OT_render_layer_remove); - WM_operatortype_append(BUTTONS_OT_toolbox); WM_operatortype_append(BUTTONS_OT_file_browse); } -void buttons_keymap(struct wmWindowManager *wm) +void buttons_keymap(struct wmKeyConfig *keyconf) { - ListBase *keymap= WM_keymap_listbase(wm, "Buttons Generic", SPACE_BUTS, 0); + wmKeyMap *keymap= WM_keymap_find(keyconf, "Buttons Generic", SPACE_BUTS, 0); WM_keymap_add_item(keymap, "BUTTONS_OT_toolbox", RIGHTMOUSE, KM_PRESS, 0, 0); } @@ -259,58 +236,6 @@ static void buttons_header_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); } -#if 0 -/* add handlers, stuff you only do once or on area/region changes */ -static void buttons_context_area_init(wmWindowManager *wm, ARegion *ar) -{ - UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); -} - -#define CONTEXTY 30 - -static void buttons_context_area_draw(const bContext *C, ARegion *ar) -{ - SpaceButs *sbuts= CTX_wm_space_buts(C); - uiStyle *style= U.uistyles.first; - uiBlock *block; - uiLayout *layout; - View2D *v2d= &ar->v2d; - float col[3]; - int x, y, w, h; - - buttons_context_compute(C, sbuts); - - w= v2d->cur.xmax - v2d->cur.xmin; - h= v2d->cur.ymax - v2d->cur.ymin; - UI_view2d_view_ortho(C, v2d); - - /* create UI */ - block= uiBeginBlock(C, ar, "buttons_context", UI_EMBOSS); - layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_PANEL, - style->panelspace, h - (h-UI_UNIT_Y)/2, w, 20, style); - - buttons_context_draw(C, layout); - - uiBlockLayoutResolve(C, block, &x, &y); - uiEndBlock(C, block); - - /* draw */ - UI_SetTheme(SPACE_BUTS, RGN_TYPE_WINDOW); /* XXX */ - - UI_GetThemeColor3fv(TH_BACK, col); - glClearColor(col[0], col[1], col[2], 0.0); - glClear(GL_COLOR_BUFFER_BIT); - - UI_view2d_totRect_set(v2d, x, -y); - UI_view2d_view_ortho(C, v2d); - - uiDrawBlock(C, block); - - /* restore view matrix */ - UI_view2d_view_restore(C); -} -#endif - /* reused! */ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) { @@ -424,19 +349,6 @@ void ED_spacetype_buttons(void) art->draw= buttons_header_area_draw; BLI_addhead(&st->regiontypes, art); -#if 0 - /* regions: context */ - art= MEM_callocN(sizeof(ARegionType), "spacetype buttons region"); - art->regionid = RGN_TYPE_CHANNELS; - art->minsizey= CONTEXTY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; - art->init= buttons_context_area_init; - art->draw= buttons_context_area_draw;; - art->listener= buttons_area_listener; - - BLI_addhead(&st->regiontypes, art); -#endif - BKE_spacetype_register(st); } |