Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2009-06-02 22:10:06 +0400
committerTon Roosendaal <ton@blender.org>2009-06-02 22:10:06 +0400
commitca24322413e78b60ece51902da1b8a9ac22d13ba (patch)
treef9111a453452e478a941fa4f35344bc4f382020b /source/blender/editors/interface/interface.c
parent67494dcad3330b1c056cef4b9aa21030c856cf5d (diff)
2.5
Part one of new text button type: SEARCH_MENU This opens a popup showing all matches for a typed string, nice for object names, materials, operators, and so on. Warning: Currently menu doesn't function yet! Only draws choices. As test I've added an operator search button in top bar. It only shows operators that can be used in this context now. Also that is part of the WIP, tomorrow more fun :)
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r--source/blender/editors/interface/interface.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index e9a886375c3..4fb2f27a618 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1359,7 +1359,7 @@ int ui_get_but_string_max_length(uiBut *but)
void ui_get_but_string(uiBut *but, char *str, int maxlen)
{
- if(but->rnaprop && ELEM(but->type, TEX, IDPOIN)) {
+ if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
PropertyType type;
char *buf= NULL;
@@ -1402,6 +1402,11 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen)
BLI_strncpy(str, but->poin, maxlen);
return;
}
+ else if(but->type == SEARCH_MENU) {
+ /* string */
+ BLI_strncpy(str, but->poin, maxlen);
+ return;
+ }
else {
/* number */
double value;
@@ -1491,7 +1496,7 @@ static void ui_rna_ID_autocomplete(bContext *C, char *str, void *arg_but)
int ui_set_but_string(bContext *C, uiBut *but, const char *str)
{
- if(but->rnaprop && ELEM(but->type, TEX, IDPOIN)) {
+ if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) {
if(RNA_property_editable(&but->rnapoin, but->rnaprop)) {
PropertyType type;
@@ -1535,6 +1540,11 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str)
BLI_strncpy(but->poin, str, but->hardmax);
return 1;
}
+ else if(but->type == SEARCH_MENU) {
+ /* string */
+ BLI_strncpy(but->poin, str, but->hardmax);
+ return 1;
+ }
else {
double value;
@@ -1817,11 +1827,11 @@ void ui_check_but(uiBut *but)
/* if something changed in the button */
double value;
float okwidth;
- int transopts= ui_translate_buttons();
+// int transopts= ui_translate_buttons();
ui_is_but_sel(but);
- if(but->type==TEX || but->type==IDPOIN) transopts= 0;
+// if(but->type==TEX || but->type==IDPOIN) transopts= 0;
/* test for min and max, icon sliders, etc */
switch( but->type ) {
@@ -1926,6 +1936,7 @@ void ui_check_but(uiBut *but)
case IDPOIN:
case TEX:
+ case SEARCH_MENU:
if(!but->editstr) {
char str[UI_MAX_DRAW_STR];
@@ -3065,6 +3076,29 @@ void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1,
ui_check_but(but);
}
+/* arg is pointer to string/name, use callbacks below to make this work */
+uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, short x1, short y1, short x2, short y2, char *tip)
+{
+ uiBut *but= ui_def_but(block, SEARCH_MENU, retval, "", x1, y1, x2, y2, arg, 0.0, maxlen, 0.0, 0.0, tip);
+
+ but->icon= (BIFIconID) icon;
+ but->flag|= UI_HAS_ICON;
+
+ but->flag|= UI_ICON_LEFT|UI_TEXT_LEFT;
+ but->flag|= UI_ICON_SUBMENU;
+
+ ui_check_but(but);
+
+ return but;
+}
+
+void uiButSetSearchFunc(uiBut *but, uiButSearchFunc func, void *arg)
+{
+ but->search_func= func;
+ but->search_arg= arg;
+}
+
+
/* Program Init/Exit */
void UI_init(void)