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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-28 22:51:06 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-28 22:51:06 +0400
commit9a874da36c2e9eb5a4d48c8c7bbce3db48f882a9 (patch)
treed0b93897f73e1b2b461b57b85b73911dccdfa77a /source/blender/editors/interface
parent5d7a7525a4a5d593fd708801d5fd54f4d5a3035a (diff)
2.5: File browse button in ui layouts now works, e.g. for render
output path or fluidsim path.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_anim.c4
-rw-r--r--source/blender/editors/interface/interface_handlers.c11
-rw-r--r--source/blender/editors/interface/interface_layout.c32
3 files changed, 45 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index 4a2ef50a31b..d2e9236fcff 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -165,6 +165,10 @@ void uiAnimContextProperty(const bContext *C, struct PointerRNA *ptr, struct Pro
uiBlock *block;
uiBut *but;
+ memset(ptr, 0, sizeof(*ptr));
+ *prop= NULL;
+ *index= 0;
+
if(ar) {
for(block=ar->uiblocks.first; block; block=block->next) {
for(but=block->buttons.first; but; but= but->next) {
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 50877439e89..93293a6f352 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3687,6 +3687,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA
static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *but, int mousemove)
{
uiBlock *block= but->block;
+ uiBut *bt;
/* ensure we are in the exit state */
if(data->state != BUTTON_STATE_EXIT)
@@ -3712,7 +3713,14 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
if(!data->cancel)
ui_apply_autokey_undo(C, but);
- /* disable tooltips until mousemove */
+ /* disable tooltips until mousemove + last active flag */
+ for(block=data->region->uiblocks.first; block; block=block->next) {
+ for(bt=block->buttons.first; bt; bt=bt->next)
+ bt->flag &= ~UI_BUT_LAST_ACTIVE;
+
+ block->tooltipdisabled= 1;
+ }
+
ui_blocks_set_tooltips(data->region, 0);
/* clean up */
@@ -3728,6 +3736,7 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b
MEM_freeN(but->active);
but->active= NULL;
but->flag &= ~(UI_ACTIVE|UI_SELECT);
+ but->flag |= UI_BUT_LAST_ACTIVE;
ui_check_but(but);
/* adds empty mousemove in queue for re-init handler, in case mouse is
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 2705cde27c9..6932ad350b0 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -486,7 +486,9 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, i
if(subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) {
uiBlockSetCurLayout(block, uiLayoutRow(sub, 1));
uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w-UI_UNIT_X, h);
- but= uiDefIconBut(block, BUT, 0, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL, 0.0f, 0.0f, 0.0f, 0.0f, "DUMMY file select button"); /* XXX */
+
+ /* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty */
+ but= uiDefIconButO(block, BUT, "BUTTONS_OT_file_browse", WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, "Browse for file or directory.");
}
else
but= uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w, h);
@@ -495,6 +497,34 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, i
return but;
}
+void uiFileBrowseContextProperty(const bContext *C, PointerRNA *ptr, PropertyRNA **prop)
+{
+ ARegion *ar= CTX_wm_region(C);
+ uiBlock *block;
+ uiBut *but, *prevbut;
+
+ memset(ptr, 0, sizeof(*ptr));
+ *prop= NULL;
+
+ if(!ar)
+ return;
+
+ for(block=ar->uiblocks.first; block; block=block->next) {
+ for(but=block->buttons.first; but; but= but->next) {
+ prevbut= but->prev;
+
+ /* find the button before the active one */
+ if((but->flag & UI_BUT_LAST_ACTIVE) && prevbut && prevbut->rnapoin.id.data) {
+ if(RNA_property_type(prevbut->rnaprop) == PROP_STRING) {
+ *ptr= prevbut->rnapoin;
+ *prop= prevbut->rnaprop;
+ return;
+ }
+ }
+ }
+ }
+}
+
/********************* Button Items *************************/
/* disabled item */