[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23289] trunk/blender/source/blender/ editors: UI
Brecht Van Lommel
brecht at blender.org
Wed Sep 16 21:36:17 CEST 2009
Revision: 23289
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23289
Author: blendix
Date: 2009-09-16 21:36:17 +0200 (Wed, 16 Sep 2009)
Log Message:
-----------
UI
* Removed some legacy code which is not needed anymore now.
* Move some test_*poin_but functions to logic space code,
since that's the only place using it still.
* uiIconFromID now uses RNA info to lookup the icon, to avoid
code duplication, and means it works for more ID types.
Modified Paths:
--------------
trunk/blender/source/blender/editors/include/UI_interface.h
trunk/blender/source/blender/editors/interface/interface_templates.c
trunk/blender/source/blender/editors/interface/interface_utils.c
trunk/blender/source/blender/editors/space_buttons/space_buttons.c
trunk/blender/source/blender/editors/space_graph/graph_buttons.c
trunk/blender/source/blender/editors/space_logic/logic_window.c
Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h 2009-09-16 19:27:23 UTC (rev 23288)
+++ trunk/blender/source/blender/editors/include/UI_interface.h 2009-09-16 19:36:17 UTC (rev 23289)
@@ -418,7 +418,6 @@
uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int retval, char *str,
short x1, short y1, short x2, short y2, void *idpp, char *tip);
-int uiDefIDPoinButs(uiBlock *block, struct Main *main, struct ID *parid, struct ID *id, int id_code, short *pin_p, int x, int y, uiIDPoinFunc func, int events);
int uiIconFromID(struct ID *id);
@@ -531,29 +530,6 @@
void UI_add_area_handlers(struct ListBase *handlers);
void UI_add_popup_handlers(struct bContext *C, struct ListBase *handlers, uiPopupBlockHandle *menu);
-/* Legacy code
- * Callbacks and utils to get 2.48 work */
-
-void test_idbutton_cb(struct bContext *C, void *namev, void *arg2);
-void test_scriptpoin_but(struct bContext *C, char *name, struct ID **idpp);
-void test_actionpoin_but(struct bContext *C, char *name, struct ID **idpp);
-void test_obpoin_but(struct bContext *C, char *name, struct ID **idpp);
-void test_meshobpoin_but(struct bContext *C, char *name, struct ID **idpp);
-void test_meshpoin_but(struct bContext *C, char *name, struct ID **idpp);
-void test_matpoin_but(struct bContext *C, char *name, struct ID **idpp);
-void test_scenepoin_but(struct bContext *C, char *name, struct ID **idpp);
-void test_grouppoin_but(struct bContext *C, char *name, struct ID **idpp);
-void test_texpoin_but(struct bContext *C, char *name, struct ID **idpp);
-void test_imapoin_but(struct bContext *C, char *name, struct ID **idpp);
-void autocomplete_bone(struct bContext *C, char *str, void *arg_v);
-void autocomplete_vgroup(struct bContext *C, char *str, void *arg_v);
-
-struct rctf;
-void curvemap_buttons(uiBlock *block, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect);
-void curvemap_layout(uiLayout *layout, struct CurveMapping *cumap, char labeltype, short event, short redraw, struct rctf *rect);
-void colorband_buttons(uiBlock *block, struct ColorBand *coba, struct rctf *rect, int small);
-
-
/* Module
*
* init and exit should be called before using this module. init_userdef must
Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c 2009-09-16 19:27:23 UTC (rev 23288)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c 2009-09-16 19:36:17 UTC (rev 23289)
@@ -762,6 +762,22 @@
}
}
+static void test_obpoin_but(bContext *C, char *name, ID **idpp)
+{
+ ID *id;
+
+ id= CTX_data_main(C)->object.first;
+ while(id) {
+ if( strcmp(name, id->name+2)==0 ) {
+ *idpp= id;
+ id_lib_extern(id); /* checks lib data, sets correct flag for saving then */
+ return;
+ }
+ id= id->next;
+ }
+ *idpp= NULL;
+}
+
/* draw panel showing settings for a constraint */
static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
{
@@ -956,11 +972,11 @@
/* subtarget */
if (is_armature_target(ct->tar)) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-(66+yoffset),150,18, &ct->subtarget, 0, 24, 0, 0, "Subtarget Bone");
- uiButSetCompleteFunc(but, autocomplete_bone, (void *)ct->tar);
+ //uiButSetCompleteFunc(but, autocomplete_bone, (void *)ct->tar);
}
else if (is_geom_target(ct->tar)) {
but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "VG:", xco+120, yco-(66+yoffset),150,18, &ct->subtarget, 0, 24, 0, 0, "Name of Vertex Group defining 'target' points");
- uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)ct->tar);
+ //uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)ct->tar);
}
else {
strcpy(ct->subtarget, "");
@@ -1762,9 +1778,6 @@
int groups, cols, layers;
int group, col, layer, row;
- if (!ptr->data)
- return;
-
prop= RNA_struct_find_property(ptr, propname);
if (!prop) {
printf("uiTemplateLayer: layers property not found: %s\n", propname);
@@ -2036,7 +2049,7 @@
/************************* Operator Search Template **************************/
-static void operator_call_cb(struct bContext *C, void *arg1, void *arg2)
+static void operator_call_cb(bContext *C, void *arg1, void *arg2)
{
wmOperatorType *ot= arg2;
@@ -2044,7 +2057,7 @@
WM_operator_name_call(C, ot->idname, WM_OP_INVOKE_DEFAULT, NULL);
}
-static void operator_search_cb(const struct bContext *C, void *arg, char *str, uiSearchItems *items)
+static void operator_search_cb(const bContext *C, void *arg, char *str, uiSearchItems *items)
{
wmOperatorType *ot = WM_operatortype_first();
Modified: trunk/blender/source/blender/editors/interface/interface_utils.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_utils.c 2009-09-16 19:27:23 UTC (rev 23288)
+++ trunk/blender/source/blender/editors/interface/interface_utils.c 2009-09-16 19:36:17 UTC (rev 23289)
@@ -23,31 +23,13 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#include <math.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "MEM_guardedalloc.h"
-
-#include "DNA_action_types.h"
-#include "DNA_color_types.h"
-#include "DNA_listBase.h"
-#include "DNA_material_types.h"
-#include "DNA_lamp_types.h""
#include "DNA_object_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_texture_types.h"
-#include "DNA_windowmanager_types.h"
-#include "BLI_blenlib.h"
-
-#include "BKE_colortools.h"
#include "BKE_context.h"
-#include "BKE_idprop.h"
-#include "BKE_icons.h"
-#include "BKE_library.h"
-#include "BKE_main.h"
-#include "BKE_texture.h"
#include "BKE_utildefines.h"
#include "RNA_access.h"
@@ -55,18 +37,6 @@
#include "UI_interface.h"
#include "UI_resources.h"
-#include "ED_screen.h"
-#include "ED_util.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "interface_intern.h"
-
-#define DEF_BUT_WIDTH 150
-#define DEF_ICON_BUT_WIDTH 20
-#define DEF_BUT_HEIGHT 20
-
/*************************** RNA Utilities ******************************/
uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int index, char *name, int icon, int x1, int y1, int x2, int y2)
@@ -177,1047 +147,38 @@
else
col= NULL;
- /* temp hack to show normal button for spin/screw */
- if(strcmp(name, "Axis")==0) {
- uiDefButR(uiLayoutGetBlock(col), BUT_NORMAL, 0, name, 0, 0, 100, 100, ptr, "axis", -1, 0, 0, -1, -1, NULL);
- }
- else uiItemFullR(col, "", 0, ptr, prop, -1, 0, 0);
+ uiItemFullR(col, "", 0, ptr, prop, -1, 0, 0);
}
RNA_STRUCT_END;
}
/***************************** ID Utilities *******************************/
-/* note, C code version, will be replaced with version in interface_templates.c */
-typedef struct uiIDPoinParams {
- uiIDPoinFunc func;
- ListBase *lb;
- ID *id;
- short id_code;
- short browsenr;
-} uiIDPoinParams;
-
-static void idpoin_cb(bContext *C, void *arg_params, void *arg_event)
+int uiIconFromID(ID *id)
{
- uiIDPoinParams *params= (uiIDPoinParams*)arg_params;
- ListBase *lb= params->lb;
- uiIDPoinFunc func= params->func;
- ID *id= params->id, *idtest;
- int nr, event= GET_INT_FROM_POINTER(arg_event);
+ Object *ob;
+ PointerRNA ptr;
+ short idcode;
- if(event == UI_ID_BROWSE && params->browsenr == 32767)
- event= UI_ID_ADD_NEW;
- else if(event == UI_ID_BROWSE && params->browsenr == 32766)
- event= UI_ID_OPEN;
-
- switch(event) {
- case UI_ID_RENAME:
- if(id) test_idbutton(id->name+2);
- else return;
- break;
- case UI_ID_BROWSE: {
- /* ID can be NULL, if nothing was assigned yet */
- if(lb->first==NULL) return;
-
- if(params->browsenr== -2) {
- /* XXX implement or find a replacement (ID can be NULL!)
- * activate_databrowse((ID *)G.buts->lockpoin, GS(id->name), 0, B_MESHBROWSE, ¶ms->browsenr, do_global_buttons); */
- return;
- }
- if(params->browsenr < 0)
- return;
-
- for(idtest=lb->first, nr=1; idtest; idtest=idtest->next, nr++) {
- if(nr==params->browsenr) {
- if(id == idtest)
- return;
-
- id= idtest;
-
- break;
- }
- }
- break;
- }
- case UI_ID_DELETE:
- id= NULL;
- break;
- case UI_ID_FAKE_USER:
- if(id) {
- if(id->flag & LIB_FAKEUSER) id->us++;
- else id->us--;
- }
- else return;
- break;
- case UI_ID_PIN:
- break;
- case UI_ID_ADD_NEW:
- break;
- case UI_ID_OPEN:
- break;
- case UI_ID_ALONE:
- if(!id || id->us < 1)
- return;
- break;
- case UI_ID_LOCAL:
- if(!id || id->us < 1)
- return;
- break;
- case UI_ID_AUTO_NAME:
- break;
- }
-
- if(func)
- func(C, id, event);
-}
-
-/* ***************************** ID Search browse menu ********************** */
-
-static void id_search_call_cb(struct bContext *C, void *arg_params, void *item)
-{
- uiIDPoinParams *params= (uiIDPoinParams*)arg_params;
-
- if(item && params->func)
- params->func(C, item, UI_ID_BROWSE);
-
-}
-
-static void id_search_cb(const struct bContext *C, void *arg_params, char *str, uiSearchItems *items)
-{
- uiIDPoinParams *params= (uiIDPoinParams*)arg_params;
- ID *id;
+ if(id==NULL)
+ return 0;
- for(id= params->lb->first; id; id= id->next) {
- int iconid= 0;
-
-
- /* icon */
- switch(GS(id->name))
- {
- case ID_MA: /* fall through */
- case ID_TE: /* fall through */
- case ID_IM: /* fall through */
- case ID_WO: /* fall through */
- case ID_LA: /* fall through */
- iconid= BKE_icon_getid(id);
- break;
- default:
- break;
- }
-
- if(BLI_strcasestr(id->name+2, str)) {
- if(0==uiSearchItemAdd(items, id->name+2, id, iconid))
- break;
- }
- }
-}
+ idcode= GS(id->name);
-static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_params)
-{
- static char search[256];
- static uiIDPoinParams params;
- wmEvent event;
- wmWindow *win= CTX_wm_window(C);
- uiBlock *block;
- uiBut *but;
-
- /* clear initial search string, then all items show */
- search[0]= 0;
- /* params is malloced, can be freed by parent button */
- params= *((uiIDPoinParams*)arg_params);
-
- block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS);
- uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1);
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list