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:
authorCampbell Barton <ideasman42@gmail.com>2011-10-20 04:48:00 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-10-20 04:48:00 +0400
commit445279524a6c10fc09cd365a63fa9b69e364be83 (patch)
tree3097d3e39f13161a7fc807710a6ab687fcfd40f2 /source/blender/editors
parent4512f10db981bdd9083bd6763fc993f2a162ac53 (diff)
debug build option WITH_PYTHON_UI_INFO, so you can right click and edit the python source for UI layout directly.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/interface/interface.c18
-rw-r--r--source/blender/editors/interface/interface_handlers.c11
-rw-r--r--source/blender/editors/interface/interface_intern.h5
-rw-r--r--source/blender/editors/space_text/space_text.c5
4 files changed, 39 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index b6c72c2e96f..ac1fab365f0 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -2559,6 +2559,24 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str,
if(block->curlayout)
ui_layout_add_but(block->curlayout, but);
+#ifdef WITH_PYTHON_UI_INFO
+ {
+ extern void PyC_FileAndNum_Safe(const char **filename, int *lineno);
+
+ const char *fn;
+ int lineno= -1;
+ PyC_FileAndNum_Safe(&fn, &lineno);
+ if (lineno != -1) {
+ BLI_strncpy(but->py_dbg_fn, fn, sizeof(but->py_dbg_fn));
+ but->py_dbg_ln= lineno;
+ }
+ else {
+ but->py_dbg_fn[0]= '\0';
+ but->py_dbg_ln= -1;
+ }
+ }
+#endif /* WITH_PYTHON_UI_INFO */
+
return but;
}
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index f4400d2d7db..4df9d7f12e2 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -4438,6 +4438,17 @@ static int ui_but_menu(bContext *C, uiBut *but)
}
}
+#ifdef WITH_PYTHON_UI_INFO
+ if (but->py_dbg_ln != -1) {
+ PointerRNA ptr_props;
+
+ WM_operator_properties_create(&ptr_props, "WM_OT_text_edit");
+ RNA_string_set(&ptr_props, "filepath", but->py_dbg_fn);
+ RNA_int_set(&ptr_props, "line", but->py_dbg_ln);
+ uiItemFullO(layout, "WM_OT_text_edit", "Edit Source", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0);
+ }
+#endif /* WITH_PYTHON_UI_INFO */
+
uiPupMenuEnd(C, pup);
return 1;
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 12e9d39e896..c5843397c12 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -252,6 +252,11 @@ struct uiBut {
/* pointer back */
uiBlock *block;
+
+#ifdef WITH_PYTHON_UI_INFO
+ char py_dbg_fn[240];
+ int py_dbg_ln;
+#endif
};
struct uiBlock {
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index 47f051e1ec4..51f4f1e579c 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -136,7 +136,12 @@ static void text_listener(ScrArea *sa, wmNotifier *wmn)
switch(wmn->data) {
case ND_DISPLAY:
+ ED_area_tag_redraw(sa);
+ break;
case ND_CURSOR:
+ if(st->text && st->text == wmn->reference)
+ text_scroll_to_cursor(st, sa);
+
ED_area_tag_redraw(sa);
break;
}