From 43f396218f5d1a8cb0449cc945eb975ec1d943d7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 11 Nov 2010 13:36:57 +0000 Subject: move report/operator view out of the 'Console' into the 'Info' space (file menu). Ton will work on moving the File menu out of the Info space before release. notes. - reply Operator isn't working anymore. - UI for reports is commented out so its not mixed with the file menu. --- release/scripts/op/console_python.py | 6 - release/scripts/ui/space_console.py | 41 +-- release/scripts/ui/space_info.py | 30 ++ source/blender/blenloader/intern/readfile.c | 29 ++ source/blender/editors/include/ED_screen.h | 3 + source/blender/editors/screen/area.c | 2 +- source/blender/editors/screen/screen_ops.c | 11 + .../blender/editors/space_console/CMakeLists.txt | 1 - .../blender/editors/space_console/console_draw.c | 172 ++------- .../blender/editors/space_console/console_intern.h | 17 +- source/blender/editors/space_console/console_ops.c | 36 +- .../blender/editors/space_console/console_report.c | 399 --------------------- .../blender/editors/space_console/space_console.c | 64 +--- source/blender/editors/space_info/CMakeLists.txt | 2 + source/blender/editors/space_info/info_draw.c | 192 ++++++++++ source/blender/editors/space_info/info_intern.h | 18 +- source/blender/editors/space_info/info_ops.c | 2 + source/blender/editors/space_info/info_report.c | 392 ++++++++++++++++++++ source/blender/editors/space_info/space_info.c | 100 +++++- source/blender/makesdna/DNA_space_types.h | 32 +- source/blender/makesrna/intern/rna_space.c | 67 ++-- source/blender/makesrna/intern/rna_userdef.c | 2 +- source/blender/windowmanager/WM_types.h | 34 +- source/blender/windowmanager/intern/wm.c | 2 +- source/blender/windowmanager/intern/wm_keymap.c | 4 + source/blender/windowmanager/intern/wm_operators.c | 2 +- 26 files changed, 898 insertions(+), 762 deletions(-) delete mode 100644 source/blender/editors/space_console/console_report.c create mode 100644 source/blender/editors/space_info/info_draw.c create mode 100644 source/blender/editors/space_info/info_report.c diff --git a/release/scripts/op/console_python.py b/release/scripts/op/console_python.py index 23ee157b279..be960d9a0d4 100644 --- a/release/scripts/op/console_python.py +++ b/release/scripts/op/console_python.py @@ -110,9 +110,6 @@ def execute(context): except: return {'CANCELLED'} - if sc.console_type != 'PYTHON': - return {'CANCELLED'} - console, stdout, stderr = get_console(hash(context.region)) # redirect output @@ -200,9 +197,6 @@ def autocomplete(context): if not console: return {'CANCELLED'} - if sc.console_type != 'PYTHON': - return {'CANCELLED'} - # dont allow the stdin to be used, can lock blender. # note: unlikely stdin would be used for autocomp. but its possible. stdin_backup = sys.stdin diff --git a/release/scripts/ui/space_console.py b/release/scripts/ui/space_console.py index 558bded5e7f..99ddeb13651 100644 --- a/release/scripts/ui/space_console.py +++ b/release/scripts/ui/space_console.py @@ -34,29 +34,10 @@ class CONSOLE_HT_header(bpy.types.Header): if context.area.show_menus: sub = row.row(align=True) + sub.menu("CONSOLE_MT_console") - if sc.console_type == 'REPORT': - sub.menu("CONSOLE_MT_report") - else: - sub.menu("CONSOLE_MT_console") - - layout.separator() - layout.prop(sc, "console_type", expand=True) - - if sc.console_type == 'REPORT': - row = layout.row(align=True) - row.prop(sc, "show_report_debug", text="Debug") - row.prop(sc, "show_report_info", text="Info") - row.prop(sc, "show_report_operator", text="Operators") - row.prop(sc, "show_report_warning", text="Warnings") - row.prop(sc, "show_report_error", text="Errors") - - row = layout.row() - row.enabled = sc.show_report_operator - row.operator("console.report_replay") - else: - row = layout.row(align=True) - row.operator("console.autocomplete", text="Autocomplete") + row = layout.row(align=True) + row.operator("console.autocomplete", text="Autocomplete") class CONSOLE_MT_console(bpy.types.Menu): @@ -76,18 +57,6 @@ class CONSOLE_MT_console(bpy.types.Menu): layout.operator("screen.screen_full_area") -class CONSOLE_MT_report(bpy.types.Menu): - bl_label = "Report" - - def draw(self, context): - layout = self.layout - layout.column() - layout.operator("console.select_all_toggle") - layout.operator("console.select_border") - layout.operator("console.report_delete") - layout.operator("console.report_copy") - - class CONSOLE_MT_language(bpy.types.Menu): bl_label = "Languages..." @@ -138,10 +107,6 @@ class ConsoleAutocomplete(bpy.types.Operator): bl_idname = "console.autocomplete" bl_label = "Console Autocomplete" - @classmethod - def poll(cls, context): - return context.space_data.console_type != 'REPORT' - def execute(self, context): sc = context.space_data module = __import__("console_" + sc.language) diff --git a/release/scripts/ui/space_info.py b/release/scripts/ui/space_info.py index 0b5122756bd..1aebe51e0d2 100644 --- a/release/scripts/ui/space_info.py +++ b/release/scripts/ui/space_info.py @@ -28,6 +28,7 @@ class INFO_HT_header(bpy.types.Header): wm = context.window_manager window = context.window + sinfo = context.space_data scene = context.scene rd = scene.render @@ -69,6 +70,35 @@ class INFO_HT_header(bpy.types.Header): layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER', text="") + # XXX: BEFORE RELEASE, MOVE FILE MENU OUT OF INFO!!! + """ + row = layout.row(align=True) + row.prop(sinfo, "show_report_debug", text="Debug") + row.prop(sinfo, "show_report_info", text="Info") + row.prop(sinfo, "show_report_operator", text="Operators") + row.prop(sinfo, "show_report_warning", text="Warnings") + row.prop(sinfo, "show_report_error", text="Errors") + + row = layout.row() + row.enabled = sinfo.show_report_operator + row.operator("info.report_replay") + + row.menu("INFO_MT_report") + """ + + +class INFO_MT_report(bpy.types.Menu): + bl_label = "Report" + + def draw(self, context): + layout = self.layout + layout.column() + layout.operator("console.select_all_toggle") + layout.operator("console.select_border") + layout.operator("console.report_delete") + layout.operator("console.report_copy") + + class INFO_MT_file(bpy.types.Menu): bl_label = "File" diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 131d080d2c8..37181cb3a06 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11112,6 +11112,35 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + { + bScreen *sc; + for (sc= main->screen.first; sc; sc= sc->id.next) { + ScrArea *sa; + for (sa= sc->areabase.first; sa; sa= sa->next) { + SpaceLink *sl; + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if (sl->spacetype == SPACE_INFO) { + SpaceInfo *sinfo= (SpaceInfo *)sl; + ARegion *ar; + + sinfo->rpt_mask= INFO_RPT_OP; + + for (ar= sa->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + ar->v2d.scroll = (V2D_SCROLL_RIGHT); + ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */ + ar->v2d.keepofs = V2D_LOCKOFS_X; + ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); + ar->v2d.keeptot= V2D_KEEPTOT_BOUNDS; + ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; + } + } + } + } + } + } + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index b679ca64a28..07fae14cc06 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -141,6 +141,9 @@ int ED_operator_sequencer_active(struct bContext *C); int ED_operator_image_active(struct bContext *C); int ED_operator_nla_active(struct bContext *C); int ED_operator_logic_active(struct bContext *C); +int ED_operator_info_active(struct bContext *C); +int ED_operator_console_active(struct bContext *C); + int ED_operator_object_active(struct bContext *C); int ED_operator_object_active_editable(struct bContext *C); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index e7c6441c077..dcb3762c6f1 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1165,7 +1165,7 @@ static char *editortype_pup(void) "|%l" - "|Console %x18" + "|Python Console %x18" ); } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 76e37c831d6..d85746d4b3e 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -226,6 +226,17 @@ int ED_operator_logic_active(bContext *C) return ed_spacetype_test(C, SPACE_LOGIC); } +int ED_operator_info_active(bContext *C) +{ + return ed_spacetype_test(C, SPACE_INFO); +} + + +int ED_operator_console_active(bContext *C) +{ + return ed_spacetype_test(C, SPACE_CONSOLE); +} + int ED_operator_object_active(bContext *C) { Object *ob = ED_object_active_context(C); diff --git a/source/blender/editors/space_console/CMakeLists.txt b/source/blender/editors/space_console/CMakeLists.txt index dbef838db65..83912388bcd 100644 --- a/source/blender/editors/space_console/CMakeLists.txt +++ b/source/blender/editors/space_console/CMakeLists.txt @@ -34,7 +34,6 @@ SET(INC SET(SRC console_draw.c console_ops.c - console_report.c space_console.c ) diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 5c2ba2cf838..5a9c3249abc 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -73,39 +73,6 @@ static void console_line_color(unsigned char fg[3], int type) } } -static void console_report_color(unsigned char *fg, unsigned char *bg, Report *report, int bool) -{ - /* - if (type & RPT_ERROR_ALL) { fg[0]=220; fg[1]=0; fg[2]=0; } - else if (type & RPT_WARNING_ALL) { fg[0]=220; fg[1]=96; fg[2]=96; } - else if (type & RPT_OPERATOR_ALL) { fg[0]=96; fg[1]=128; fg[2]=255; } - else if (type & RPT_INFO_ALL) { fg[0]=0; fg[1]=170; fg[2]=0; } - else if (type & RPT_DEBUG_ALL) { fg[0]=196; fg[1]=196; fg[2]=196; } - else { fg[0]=196; fg[1]=196; fg[2]=196; } - */ - if(report->flag & SELECT) { - fg[0]=255; fg[1]=255; fg[2]=255; - if(bool) { - bg[0]=96; bg[1]=128; bg[2]=255; - } - else { - bg[0]=90; bg[1]=122; bg[2]=249; - } - } - - else { - fg[0]=0; fg[1]=0; fg[2]=0; - - if(bool) { - bg[0]=120; bg[1]=120; bg[2]=120; - } - else { - bg[0]=114; bg[1]=114; bg[2]=114; - } - - } -} - typedef struct ConsoleDrawContext { int cwidth; int lheight; @@ -201,131 +168,50 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha } - -/* reports! */ -static int report_textview_begin(TextViewContext *tvc) +static int console_textview_main__internal(struct SpaceConsole *sc, struct ARegion *ar, ReportList *UNUSED(reports), int draw, int mval[2], void **mouse_pick, int *pos_pick) { - SpaceConsole *sc= (SpaceConsole *)tvc->arg1; - ReportList *reports= (ReportList *)tvc->arg2; - - tvc->lheight= sc->lheight; - tvc->sel_start= sc->sel_start; - tvc->sel_end= sc->sel_end; - - /* iterator */ - tvc->iter= reports->list.last; - - glClearColor(120.0/255.0, 120.0/255.0, 120.0/255.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); + ConsoleLine cl_dummy= {0}; + int ret= 0; - return (tvc->iter != NULL); -} - -static void report_textview_end(TextViewContext *UNUSED(tvc)) -{ - /* pass */ -} + View2D *v2d= &ar->v2d; -static int report_textview_step(TextViewContext *tvc) -{ - return ((tvc->iter= (void *)((Link *)tvc->iter)->prev) != NULL); -} + TextViewContext tvc= {0}; + tvc.begin= console_textview_begin; + tvc.end= console_textview_end; -static int report_textview_line_get(struct TextViewContext *tvc, const char **line, int *len) -{ - Report *report= (Report *)tvc->iter; - *line= report->message; - *len= report->len; + tvc.step= console_textview_step; + tvc.line_get= console_textview_line_get; + tvc.line_color= console_textview_line_color; - return 1; -} + tvc.arg1= sc; + tvc.arg2= NULL; -static int report_textview_line_color(struct TextViewContext *tvc, unsigned char fg[3], unsigned char bg[3]) -{ - Report *report= (Report *)tvc->iter; - console_report_color(fg, bg, report, tvc->iter_index % 2); - return TVC_LINE_FG | TVC_LINE_BG; -} - - -static int console_text_main__internal(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports, int draw, int mval[2], void **mouse_pick, int *pos_pick) -{ - if(sc->type==CONSOLE_TYPE_PYTHON) { - int ret= 0; - - View2D *v2d= &ar->v2d; - - TextViewContext tvc= {0}; - tvc.begin= console_textview_begin; - tvc.end= console_textview_end; - - tvc.step= console_textview_step; - tvc.line_get= console_textview_line_get; - tvc.line_color= console_textview_line_color; - - tvc.arg1= sc; - tvc.arg2= NULL; - - /* view */ - tvc.sel_start= sc->sel_start; - tvc.sel_end= sc->sel_end; - tvc.lheight= sc->lheight; - tvc.ymin= v2d->cur.ymin; - tvc.ymax= v2d->cur.ymax; - tvc.winx= ar->winx; - - { - ConsoleLine cl_dummy= {0}; - console_scrollback_prompt_begin(sc, &cl_dummy); - ret= textview_draw(&tvc, draw, mval, mouse_pick, pos_pick); - console_scrollback_prompt_end(sc, &cl_dummy); - } - - return ret; - } - else { - int ret= 0; + /* view */ + tvc.sel_start= sc->sel_start; + tvc.sel_end= sc->sel_end; + tvc.lheight= sc->lheight; + tvc.ymin= v2d->cur.ymin; + tvc.ymax= v2d->cur.ymax; + tvc.winx= ar->winx; - View2D *v2d= &ar->v2d; + console_scrollback_prompt_begin(sc, &cl_dummy); + ret= textview_draw(&tvc, draw, mval, mouse_pick, pos_pick); + console_scrollback_prompt_end(sc, &cl_dummy); - TextViewContext tvc= {0}; - tvc.begin= report_textview_begin; - tvc.end= report_textview_end; - - tvc.step= report_textview_step; - tvc.line_get= report_textview_line_get; - tvc.line_color= report_textview_line_color; - - tvc.arg1= sc; - tvc.arg2= reports; - - /* view */ - tvc.sel_start= sc->sel_start; - tvc.sel_end= sc->sel_end; - tvc.lheight= sc->lheight; - tvc.ymin= v2d->cur.ymin; - tvc.ymax= v2d->cur.ymax; - tvc.winx= ar->winx; - - { - ret= textview_draw(&tvc, draw, mval, mouse_pick, pos_pick); - } - - return ret; - } + return ret; } -void console_text_main(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports) +void console_textview_main(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports) { int mval[2] = {INT_MAX, INT_MAX}; - console_text_main__internal(sc, ar, reports, 1, mval, NULL, NULL); + console_textview_main__internal(sc, ar, reports, 1, mval, NULL, NULL); } -int console_text_height(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports) +int console_textview_height(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports) { int mval[2] = {INT_MAX, INT_MAX}; - return console_text_main__internal(sc, ar, reports, 0, mval, NULL, NULL); + return console_textview_main__internal(sc, ar, reports, 0, mval, NULL, NULL); } void *console_text_pick(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports, int mouse_y) @@ -336,7 +222,7 @@ void *console_text_pick(struct SpaceConsole *sc, struct ARegion *ar, ReportList mval[0]= 0; mval[1]= mouse_y; - console_text_main__internal(sc, ar, reports, 0, mval, &mouse_pick, NULL); + console_textview_main__internal(sc, ar, reports, 0, mval, &mouse_pick, NULL); return (void *)mouse_pick; } @@ -349,6 +235,6 @@ int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, ReportList *r mval_clamp[0]= CLAMPIS(mval[0], CONSOLE_DRAW_MARGIN, ar->winx-(CONSOLE_DRAW_SCROLL + CONSOLE_DRAW_MARGIN)); mval_clamp[1]= CLAMPIS(mval[1], CONSOLE_DRAW_MARGIN, ar->winy-CONSOLE_DRAW_MARGIN); - console_text_main__internal(sc, ar, reports, 0, mval_clamp, &mouse_pick, &pos_pick); + console_textview_main__internal(sc, ar, reports, 0, mval_clamp, &mouse_pick, &pos_pick); return pos_pick; } diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h index 8e6b5dbfcdd..b8d53785d74 100644 --- a/source/blender/editors/space_console/console_intern.h +++ b/source/blender/editors/space_console/console_intern.h @@ -32,8 +32,8 @@ struct ReportList; struct bContext; /* console_draw.c */ -void console_text_main(struct SpaceConsole *sc, struct ARegion *ar, struct ReportList *reports); -int console_text_height(struct SpaceConsole *sc, struct ARegion *ar, struct ReportList *reports); /* needed to calculate the scrollbar */ +void console_textview_main(struct SpaceConsole *sc, struct ARegion *ar, struct ReportList *reports); +int console_textview_height(struct SpaceConsole *sc, struct ARegion *ar, struct ReportList *reports); /* needed to calculate the scrollbar */ void *console_text_pick(struct SpaceConsole *sc, struct ARegion *ar, struct ReportList *reports, int mouse_y); /* needed for selection */ int console_char_pick(struct SpaceConsole *sc, struct ARegion *ar, ReportList *reports, int mval[2]); @@ -64,19 +64,6 @@ void CONSOLE_OT_copy(struct wmOperatorType *ot); void CONSOLE_OT_paste(struct wmOperatorType *ot); void CONSOLE_OT_select_set(struct wmOperatorType *ot); - - -/* console_report.c */ -void CONSOLE_OT_select_pick(struct wmOperatorType *ot); /* report selection */ -void CONSOLE_OT_select_all_toggle(struct wmOperatorType *ot); -void CONSOLE_OT_select_border(struct wmOperatorType *ot); - -void CONSOLE_OT_report_replay(struct wmOperatorType *ot); -void CONSOLE_OT_report_delete(struct wmOperatorType *ot); -void CONSOLE_OT_report_copy(struct wmOperatorType *ot); - - - enum { LINE_BEGIN, LINE_END, PREV_CHAR, NEXT_CHAR, PREV_WORD, NEXT_WORD }; enum { DEL_ALL, DEL_NEXT_CHAR, DEL_PREV_CHAR, DEL_SELECTION, DEL_NEXT_SEL, DEL_PREV_SEL }; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index c5c1f8d1d4c..6aef967b851 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -259,22 +259,6 @@ static int console_line_insert(ConsoleLine *ci, char *str) return len; } -static int console_edit_poll(bContext *C) -{ - SpaceConsole *sc= CTX_wm_space_console(C); - - if(!sc || sc->type != CONSOLE_TYPE_PYTHON) - return 0; - - return 1; -} -#if 0 -static int console_poll(bContext *C) -{ - return (CTX_wm_space_console(C) != NULL); -} -#endif - /* static funcs for text editing */ /* similar to the text editor, with some not used. keep compatible */ @@ -356,7 +340,7 @@ void CONSOLE_OT_move(wmOperatorType *ot) /* api callbacks */ ot->exec= move_exec; - ot->poll= console_edit_poll; + ot->poll= ED_operator_console_active; /* properties */ RNA_def_enum(ot->srna, "type", move_type_items, LINE_BEGIN, "Type", "Where to move cursor to."); @@ -424,7 +408,7 @@ void CONSOLE_OT_insert(wmOperatorType *ot) /* api callbacks */ ot->exec= insert_exec; ot->invoke= insert_invoke; - ot->poll= console_edit_poll; + ot->poll= ED_operator_console_active; /* properties */ RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position."); @@ -493,7 +477,7 @@ void CONSOLE_OT_delete(wmOperatorType *ot) /* api callbacks */ ot->exec= delete_exec; - ot->poll= console_edit_poll; + ot->poll= ED_operator_console_active; /* properties */ RNA_def_enum(ot->srna, "type", delete_type_items, DEL_NEXT_CHAR, "Type", "Which part of the text to delete."); @@ -534,7 +518,7 @@ void CONSOLE_OT_clear(wmOperatorType *ot) /* api callbacks */ ot->exec= clear_exec; - ot->poll= console_edit_poll; + ot->poll= ED_operator_console_active; /* properties */ RNA_def_boolean(ot->srna, "scrollback", 1, "Scrollback", "Clear the scrollback history"); @@ -596,7 +580,7 @@ void CONSOLE_OT_history_cycle(wmOperatorType *ot) /* api callbacks */ ot->exec= history_cycle_exec; - ot->poll= console_edit_poll; + ot->poll= ED_operator_console_active; /* properties */ RNA_def_boolean(ot->srna, "reverse", 0, "Reverse", "reverse cycle history"); @@ -644,7 +628,7 @@ void CONSOLE_OT_history_append(wmOperatorType *ot) /* api callbacks */ ot->exec= history_append_exec; - ot->poll= console_edit_poll; + ot->poll= ED_operator_console_active; /* properties */ RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position."); @@ -689,7 +673,7 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot) /* api callbacks */ ot->exec= scrollback_append_exec; - ot->poll= console_edit_poll; + ot->poll= ED_operator_console_active; /* properties */ RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position."); @@ -772,7 +756,7 @@ void CONSOLE_OT_copy(wmOperatorType *ot) ot->idname= "CONSOLE_OT_copy"; /* api callbacks */ - ot->poll= console_edit_poll; + ot->poll= ED_operator_console_active; ot->exec= copy_exec; /* properties */ @@ -822,7 +806,7 @@ void CONSOLE_OT_paste(wmOperatorType *ot) ot->idname= "CONSOLE_OT_paste"; /* api callbacks */ - ot->poll= console_edit_poll; + ot->poll= ED_operator_console_active; ot->exec= paste_exec; /* properties */ @@ -941,5 +925,5 @@ void CONSOLE_OT_select_set(wmOperatorType *ot) ot->invoke= console_modal_select_invoke; ot->modal= console_modal_select; ot->cancel= console_modal_select_cancel; - ot->poll= console_edit_poll; + ot->poll= ED_operator_console_active; } diff --git a/source/blender/editors/space_console/console_report.c b/source/blender/editors/space_console/console_report.c deleted file mode 100644 index a714952eaaf..00000000000 --- a/source/blender/editors/space_console/console_report.c +++ /dev/null @@ -1,399 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Campbell Barton - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include -#include - -#include "MEM_guardedalloc.h" - - -#include "BLI_blenlib.h" -#include "BLI_dynstr.h" - -#include "BKE_context.h" - -#include "WM_api.h" -#include "WM_types.h" - -#include "ED_screen.h" -#include "ED_types.h" - -#include "RNA_access.h" -#include "RNA_define.h" - -#include "console_intern.h" - -int console_report_mask(SpaceConsole *sc) -{ - int report_mask = 0; - - if(sc->rpt_mask & CONSOLE_RPT_DEBUG) report_mask |= RPT_DEBUG_ALL; - if(sc->rpt_mask & CONSOLE_RPT_INFO) report_mask |= RPT_INFO_ALL; - if(sc->rpt_mask & CONSOLE_RPT_OP) report_mask |= RPT_OPERATOR_ALL; - if(sc->rpt_mask & CONSOLE_RPT_WARN) report_mask |= RPT_WARNING_ALL; - if(sc->rpt_mask & CONSOLE_RPT_ERR) report_mask |= RPT_ERROR_ALL; - - return report_mask; -} - -static int console_report_poll(bContext *C) -{ - SpaceConsole *sc= CTX_wm_space_console(C); - - if(!sc || sc->type != CONSOLE_TYPE_REPORT) - return 0; - - return 1; -} - -static int report_replay_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceConsole *sc= CTX_wm_space_console(C); - ReportList *reports= CTX_wm_reports(C); - int report_mask= console_report_mask(sc); - Report *report; - - sc->type= CONSOLE_TYPE_PYTHON; - - for(report=reports->list.last; report; report=report->prev) { - if((report->type & report_mask) && (report->type & RPT_OPERATOR_ALL) && (report->flag & SELECT)) { - console_history_add_str(sc, report->message, 0); - WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, NULL); - - ED_area_tag_redraw(CTX_wm_area(C)); - } - } - - sc->type= CONSOLE_TYPE_REPORT; - - ED_area_tag_redraw(CTX_wm_area(C)); - - return OPERATOR_FINISHED; -} - -void CONSOLE_OT_report_replay(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Replay Operators"; - ot->description= "Replay selected reports"; - ot->idname= "CONSOLE_OT_report_replay"; - - /* api callbacks */ - ot->poll= console_report_poll; - ot->exec= report_replay_exec; - - /* flags */ - /* ot->flag= OPTYPE_REGISTER; */ - - /* properties */ -} - -static int select_report_pick_exec(bContext *C, wmOperator *op) -{ - int report_index= RNA_int_get(op->ptr, "report_index"); - Report *report= BLI_findlink(&CTX_wm_reports(C)->list, report_index); - - if(!report) - return OPERATOR_CANCELLED; - - report->flag ^= SELECT; /* toggle */ - - ED_area_tag_redraw(CTX_wm_area(C)); - - return OPERATOR_FINISHED; -} - -static int select_report_pick_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - SpaceConsole *sc= CTX_wm_space_console(C); - ARegion *ar= CTX_wm_region(C); - ReportList *reports= CTX_wm_reports(C); - Report *report; - - report= console_text_pick(sc, ar, reports, event->mval[1]); - - RNA_int_set(op->ptr, "report_index", BLI_findindex(&reports->list, report)); - - return select_report_pick_exec(C, op); -} - - -void CONSOLE_OT_select_pick(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Select report"; - ot->description= "Select reports by index"; - ot->idname= "CONSOLE_OT_select_pick"; - - /* api callbacks */ - ot->poll= console_report_poll; - ot->invoke= select_report_pick_invoke; - ot->exec= select_report_pick_exec; - - /* flags */ - /* ot->flag= OPTYPE_REGISTER; */ - - /* properties */ - RNA_def_int(ot->srna, "report_index", 0, 0, INT_MAX, "Report", "The index of the report.", 0, INT_MAX); -} - - - -static int report_select_all_toggle_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceConsole *sc= CTX_wm_space_console(C); - ReportList *reports= CTX_wm_reports(C); - int report_mask= console_report_mask(sc); - int deselect= 0; - - Report *report; - - for(report=reports->list.last; report; report=report->prev) { - if((report->type & report_mask) && (report->flag & SELECT)) { - deselect= 1; - break; - } - } - - - if(deselect) { - for(report=reports->list.last; report; report=report->prev) - if(report->type & report_mask) - report->flag &= ~SELECT; - } - else { - for(report=reports->list.last; report; report=report->prev) - if(report->type & report_mask) - report->flag |= SELECT; - } - - ED_area_tag_redraw(CTX_wm_area(C)); - - return OPERATOR_FINISHED; -} - -void CONSOLE_OT_select_all_toggle(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "(De)Select All"; - ot->description= "(de)select all reports"; - ot->idname= "CONSOLE_OT_select_all_toggle"; - - /* api callbacks */ - ot->poll= console_report_poll; - ot->exec= report_select_all_toggle_exec; - - /* flags */ - /*ot->flag= OPTYPE_REGISTER;*/ - - /* properties */ -} - -/* borderselect operator */ -static int borderselect_exec(bContext *C, wmOperator *op) -{ - SpaceConsole *sc= CTX_wm_space_console(C); - ARegion *ar= CTX_wm_region(C); - ReportList *reports= CTX_wm_reports(C); - int report_mask= console_report_mask(sc); - Report *report_min, *report_max, *report; - - //View2D *v2d= UI_view2d_fromcontext(C); - - - rcti rect; - //rctf rectf, rq; - short selecting= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT); - //short mval[2]; - - rect.xmin= RNA_int_get(op->ptr, "xmin"); - rect.ymin= RNA_int_get(op->ptr, "ymin"); - rect.xmax= RNA_int_get(op->ptr, "xmax"); - rect.ymax= RNA_int_get(op->ptr, "ymax"); - - /* - mval[0]= rect.xmin; - mval[1]= rect.ymin; - UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmin, &rectf.ymin); - mval[0]= rect.xmax; - mval[1]= rect.ymax; - UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmax, &rectf.ymax); -*/ - - report_min= console_text_pick(sc, ar, reports, rect.ymax); - report_max= console_text_pick(sc, ar, reports, rect.ymin); - - /* get the first report if none found */ - if(report_min==NULL) { - // printf("find_min\n"); - for(report=reports->list.first; report; report=report->next) { - if(report->type & report_mask) { - report_min= report; - break; - } - } - } - - if(report_max==NULL) { - // printf("find_max\n"); - for(report=reports->list.last; report; report=report->prev) { - if(report->type & report_mask) { - report_max= report; - break; - } - } - } - - if(report_min==NULL || report_max==NULL) - return OPERATOR_CANCELLED; - - for(report= report_min; (report != report_max->next); report= report->next) { - - if((report->type & report_mask)==0) - continue; - - if(selecting) - report->flag |= SELECT; - else - report->flag &= ~SELECT; - } - - ED_area_tag_redraw(CTX_wm_area(C)); - - return OPERATOR_FINISHED; -} - - -/* ****** Border Select ****** */ -void CONSOLE_OT_select_border(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Border Select"; - ot->description= "Toggle border selection"; - ot->idname= "CONSOLE_OT_select_border"; - - /* api callbacks */ - ot->invoke= WM_border_select_invoke; - ot->exec= borderselect_exec; - ot->modal= WM_border_select_modal; - - ot->poll= console_report_poll; - - /* flags */ - /* ot->flag= OPTYPE_REGISTER; */ - - /* rna */ - WM_operator_properties_gesture_border(ot, FALSE); -} - - - -static int report_delete_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceConsole *sc= CTX_wm_space_console(C); - ReportList *reports= CTX_wm_reports(C); - int report_mask= console_report_mask(sc); - - - Report *report, *report_next; - - for(report=reports->list.first; report; ) { - - report_next=report->next; - - if((report->type & report_mask) && (report->flag & SELECT)) { - BLI_remlink(&reports->list, report); - MEM_freeN(report->message); - MEM_freeN(report); - } - - report= report_next; - } - - ED_area_tag_redraw(CTX_wm_area(C)); - - return OPERATOR_FINISHED; -} - -void CONSOLE_OT_report_delete(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Delete Reports"; - ot->description= "Delete selected reports"; - ot->idname= "CONSOLE_OT_report_delete"; - - /* api callbacks */ - ot->poll= console_report_poll; - ot->exec= report_delete_exec; - - /* flags */ - /*ot->flag= OPTYPE_REGISTER;*/ - - /* properties */ -} - - -static int report_copy_exec(bContext *C, wmOperator *UNUSED(op)) -{ - SpaceConsole *sc= CTX_wm_space_console(C); - ReportList *reports= CTX_wm_reports(C); - int report_mask= console_report_mask(sc); - - Report *report; - - DynStr *buf_dyn= BLI_dynstr_new(); - char *buf_str; - - for(report=reports->list.first; report; report= report->next) { - if((report->type & report_mask) && (report->flag & SELECT)) { - BLI_dynstr_append(buf_dyn, report->message); - BLI_dynstr_append(buf_dyn, "\n"); - } - } - - buf_str= BLI_dynstr_get_cstring(buf_dyn); - BLI_dynstr_free(buf_dyn); - - WM_clipboard_text_set(buf_str, 0); - - MEM_freeN(buf_str); - return OPERATOR_FINISHED; -} - -void CONSOLE_OT_report_copy(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Copy Reports to Clipboard"; - ot->description= "Copy selected reports to Clipboard"; - ot->idname= "CONSOLE_OT_report_copy"; - - /* api callbacks */ - ot->poll= console_report_poll; - ot->exec= report_copy_exec; - - /* flags */ - /*ot->flag= OPTYPE_REGISTER;*/ - - /* properties */ -} diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 66e780f3a04..55fb6a50bb4 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -53,12 +53,12 @@ #include "console_intern.h" // own include -static void console_update_rect(const bContext *C, ARegion *ar) +static void console_textview_update_rect(const bContext *C, ARegion *ar) { SpaceConsole *sc= CTX_wm_space_console(C); View2D *v2d= &ar->v2d; - UI_view2d_totRect_set(v2d, ar->winx-1, console_text_height(sc, ar, CTX_wm_reports(C))); + UI_view2d_totRect_set(v2d, ar->winx-1, console_textview_height(sc, ar, CTX_wm_reports(C))); } /* ******************** default callbacks for console space ***************** */ @@ -72,8 +72,6 @@ static SpaceLink *console_new(const bContext *UNUSED(C)) sconsole->spacetype= SPACE_CONSOLE; sconsole->lheight= 14; - sconsole->type= CONSOLE_TYPE_PYTHON; - sconsole->rpt_mask= CONSOLE_RPT_OP; /* ? - not sure whats a good default here?*/ /* header */ ar= MEM_callocN(sizeof(ARegion), "header for console"); @@ -89,7 +87,7 @@ static SpaceLink *console_new(const bContext *UNUSED(C)) BLI_addtail(&sconsole->regionbase, ar); ar->regiontype= RGN_TYPE_WINDOW; - + /* keep in sync with info */ ar->v2d.scroll |= (V2D_SCROLL_RIGHT); ar->v2d.align |= V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */ ar->v2d.keepofs |= V2D_LOCKOFS_X; @@ -158,12 +156,11 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar) /* ************* dropboxes ************* */ -static int id_drop_poll(bContext *C, wmDrag *drag, wmEvent *UNUSED(event)) +static int id_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - SpaceConsole *sc= CTX_wm_space_console(C); - if(sc->type==CONSOLE_TYPE_PYTHON) - if(drag->type==WM_DRAG_ID) - return 1; +// SpaceConsole *sc= CTX_wm_space_console(C); + if(drag->type==WM_DRAG_ID) + return 1; return 0; } @@ -178,12 +175,11 @@ static void id_drop_copy(wmDrag *drag, wmDropBox *drop) RNA_string_set(drop->ptr, "text", text); } -static int path_drop_poll(bContext *C, wmDrag *drag, wmEvent *UNUSED(event)) +static int path_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - SpaceConsole *sc= CTX_wm_space_console(C); - if(sc->type==CONSOLE_TYPE_PYTHON) - if(drag->type==WM_DRAG_PATH) - return 1; +// SpaceConsole *sc= CTX_wm_space_console(C); + if(drag->type==WM_DRAG_PATH) + return 1; return 0; } @@ -213,14 +209,14 @@ static void console_main_area_draw(const bContext *C, ARegion *ar) View2D *v2d= &ar->v2d; View2DScrollers *scrollers; - if((sc->type==CONSOLE_TYPE_PYTHON) && (sc->scrollback.first==NULL)) + if(sc->scrollback.first==NULL) WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL); /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - console_update_rect(C, ar); + console_textview_update_rect(C, ar); /* worlks best with no view2d matrix set */ UI_view2d_view_ortho(v2d); @@ -228,7 +224,7 @@ static void console_main_area_draw(const bContext *C, ARegion *ar) /* data... */ console_history_verify(C); /* make sure we have some command line */ - console_text_main(sc, ar, CTX_wm_reports(C)); + console_textview_main(sc, ar, CTX_wm_reports(C)); /* reset view matrix */ UI_view2d_view_restore(C); @@ -255,15 +251,6 @@ void console_operatortypes(void) WM_operatortype_append(CONSOLE_OT_copy); WM_operatortype_append(CONSOLE_OT_paste); WM_operatortype_append(CONSOLE_OT_select_set); - - /* console_report.c */ - WM_operatortype_append(CONSOLE_OT_select_pick); - WM_operatortype_append(CONSOLE_OT_select_all_toggle); - WM_operatortype_append(CONSOLE_OT_select_border); - - WM_operatortype_append(CONSOLE_OT_report_replay); - WM_operatortype_append(CONSOLE_OT_report_delete); - WM_operatortype_append(CONSOLE_OT_report_copy); } void console_keymap(struct wmKeyConfig *keyconf) @@ -331,16 +318,6 @@ void console_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* python operator - space_text.py */ #endif - /* report selection */ - WM_keymap_add_item(keymap, "CONSOLE_OT_select_pick", SELECTMOUSE, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "CONSOLE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "CONSOLE_OT_select_border", BKEY, KM_PRESS, 0, 0); - - WM_keymap_add_item(keymap, "CONSOLE_OT_report_replay", RKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "CONSOLE_OT_report_delete", XKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "CONSOLE_OT_report_delete", DELKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "CONSOLE_OT_report_copy", CKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "CONSOLE_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "CONSOLE_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); #ifdef __APPLE__ @@ -367,19 +344,15 @@ static void console_header_area_draw(const bContext *C, ARegion *ar) ED_region_header(C, ar); } -static void console_main_area_listener(ScrArea *sa, wmNotifier *wmn) +static void console_main_area_listener(ARegion *ar, wmNotifier *wmn) { - SpaceConsole *sc= sa->spacedata.first; + // SpaceInfo *sinfo= sa->spacedata.first; /* context changes */ switch(wmn->category) { case NC_SPACE: if(wmn->data == ND_SPACE_CONSOLE) { /* generic redraw request */ - ED_area_tag_redraw(sa); - } - else if(wmn->data == ND_SPACE_CONSOLE_REPORT && sc->type==CONSOLE_TYPE_REPORT) { - /* redraw also but only for report view, could do less redraws by checking the type */ - ED_area_tag_redraw(sa); + ED_region_tag_redraw(ar); } break; } @@ -401,7 +374,6 @@ void ED_spacetype_console(void) st->operatortypes= console_operatortypes; st->keymap= console_keymap; st->dropboxes= console_dropboxes; - st->listener= console_main_area_listener; /* regions: main window */ art= MEM_callocN(sizeof(ARegionType), "spacetype console region"); @@ -410,7 +382,7 @@ void ED_spacetype_console(void) art->init= console_main_area_init; art->draw= console_main_area_draw; - + art->listener= console_main_area_listener; diff --git a/source/blender/editors/space_info/CMakeLists.txt b/source/blender/editors/space_info/CMakeLists.txt index ff65efeead0..47bbfec5fe5 100644 --- a/source/blender/editors/space_info/CMakeLists.txt +++ b/source/blender/editors/space_info/CMakeLists.txt @@ -34,6 +34,8 @@ SET(INC SET(SRC info_ops.c info_stats.c + info_draw.c + info_report.c textview.c space_info.c ) diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c new file mode 100644 index 00000000000..e11c50eda9e --- /dev/null +++ b/source/blender/editors/space_info/info_draw.c @@ -0,0 +1,192 @@ +/** + * $Id: info_ops.c 32551 2010-10-18 06:41:16Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2010 Blender Foundation. + * All rights reserved. + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + + +#include +#include +#include +#include +#include + + +#include "BLF_api.h" + +#include "BLI_blenlib.h" + +#include "DNA_space_types.h" +#include "DNA_screen_types.h" + +// #include "BKE_suggestions.h" +#include "BKE_report.h" +#include "BKE_utildefines.h" + +#include "MEM_guardedalloc.h" + +#include "BIF_gl.h" +#include "BIF_glutil.h" + +#include "ED_datafiles.h" +#include "ED_types.h" + +#include "UI_resources.h" + +#include "../space_info/textview.h" + +static void info_report_color(unsigned char *fg, unsigned char *bg, Report *report, int bool) +{ + /* + if (type & RPT_ERROR_ALL) { fg[0]=220; fg[1]=0; fg[2]=0; } + else if (type & RPT_WARNING_ALL) { fg[0]=220; fg[1]=96; fg[2]=96; } + else if (type & RPT_OPERATOR_ALL) { fg[0]=96; fg[1]=128; fg[2]=255; } + else if (type & RPT_INFO_ALL) { fg[0]=0; fg[1]=170; fg[2]=0; } + else if (type & RPT_DEBUG_ALL) { fg[0]=196; fg[1]=196; fg[2]=196; } + else { fg[0]=196; fg[1]=196; fg[2]=196; } + */ + if(report->flag & SELECT) { + fg[0]=255; fg[1]=255; fg[2]=255; + if(bool) { + bg[0]=96; bg[1]=128; bg[2]=255; + } + else { + bg[0]=90; bg[1]=122; bg[2]=249; + } + } + + else { + fg[0]=0; fg[1]=0; fg[2]=0; + + if(bool) { + bg[0]=120; bg[1]=120; bg[2]=120; + } + else { + bg[0]=114; bg[1]=114; bg[2]=114; + } + + } +} + + +/* reports! */ +static int report_textview_begin(TextViewContext *tvc) +{ + // SpaceConsole *sc= (SpaceConsole *)tvc->arg1; + ReportList *reports= (ReportList *)tvc->arg2; + + tvc->lheight= 14; //sc->lheight; + tvc->sel_start= 0; + tvc->sel_end= 0; + + /* iterator */ + tvc->iter= reports->list.last; + + glClearColor(120.0/255.0, 120.0/255.0, 120.0/255.0, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + + return (tvc->iter != NULL); +} + +static void report_textview_end(TextViewContext *UNUSED(tvc)) +{ + /* pass */ +} + +static int report_textview_step(TextViewContext *tvc) +{ + return ((tvc->iter= (void *)((Link *)tvc->iter)->prev) != NULL); +} + +static int report_textview_line_get(struct TextViewContext *tvc, const char **line, int *len) +{ + Report *report= (Report *)tvc->iter; + *line= report->message; + *len= report->len; + + return 1; +} + +static int report_textview_line_color(struct TextViewContext *tvc, unsigned char fg[3], unsigned char bg[3]) +{ + Report *report= (Report *)tvc->iter; + info_report_color(fg, bg, report, tvc->iter_index % 2); + return TVC_LINE_FG | TVC_LINE_BG; +} + + +static int info_textview_main__internal(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports, int draw, int mval[2], void **mouse_pick, int *pos_pick) +{ + int ret= 0; + + View2D *v2d= &ar->v2d; + + TextViewContext tvc= {0}; + tvc.begin= report_textview_begin; + tvc.end= report_textview_end; + + tvc.step= report_textview_step; + tvc.line_get= report_textview_line_get; + tvc.line_color= report_textview_line_color; + + tvc.arg1= sinfo; + tvc.arg2= reports; + + /* view */ + tvc.sel_start= 0; + tvc.sel_end= 0; + tvc.lheight= 14; //sc->lheight; + tvc.ymin= v2d->cur.ymin; + tvc.ymax= v2d->cur.ymax; + tvc.winx= ar->winx; + + ret= textview_draw(&tvc, draw, mval, mouse_pick, pos_pick); + + return ret; +} + +void *info_text_pick(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports, int mouse_y) +{ + void *mouse_pick= NULL; + int mval[2]; + + mval[0]= 0; + mval[1]= mouse_y; + + info_textview_main__internal(sinfo, ar, reports, 0, mval, &mouse_pick, NULL); + return (void *)mouse_pick; +} + + +int info_textview_height(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports) +{ + int mval[2] = {INT_MAX, INT_MAX}; + return info_textview_main__internal(sinfo, ar, reports, 0, mval, NULL, NULL); +} + +void info_textview_main(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports) +{ + int mval[2] = {INT_MAX, INT_MAX}; + info_textview_main__internal(sinfo, ar, reports, 1, mval, NULL, NULL); +} diff --git a/source/blender/editors/space_info/info_intern.h b/source/blender/editors/space_info/info_intern.h index 4053bbf5a1f..4953bc1b4be 100644 --- a/source/blender/editors/space_info/info_intern.h +++ b/source/blender/editors/space_info/info_intern.h @@ -30,7 +30,9 @@ /* internal exports only */ +struct SpaceInfo; struct wmOperatorType; +struct ReportList; void FILE_OT_pack_all(struct wmOperatorType *ot); void FILE_OT_unpack_all(struct wmOperatorType *ot); @@ -41,5 +43,19 @@ void FILE_OT_find_missing_files(struct wmOperatorType *ot); void INFO_OT_reports_display_update(struct wmOperatorType *ot); -#endif /* ED_INFO_INTERN_H */ +/* info_draw.c */ +void *info_text_pick(struct SpaceInfo *sinfo, struct ARegion *ar, ReportList *reports, int mouse_y); +int info_textview_height(struct SpaceInfo *sinfo, struct ARegion *ar, struct ReportList *reports); +void info_textview_main(struct SpaceInfo *sinfo, struct ARegion *ar, struct ReportList *reports); + +/* info_report.c */ +/* console_report.c */ +void INFO_OT_select_pick(struct wmOperatorType *ot); /* report selection */ +void INFO_OT_select_all_toggle(struct wmOperatorType *ot); +void INFO_OT_select_border(struct wmOperatorType *ot); +void INFO_OT_report_replay(struct wmOperatorType *ot); +void INFO_OT_report_delete(struct wmOperatorType *ot); +void INFO_OT_report_copy(struct wmOperatorType *ot); + +#endif /* ED_INFO_INTERN_H */ diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index aeb32cda6bd..3ed4f07d150 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -395,3 +395,5 @@ void INFO_OT_reports_display_update(wmOperatorType *ot) /* properties */ } + +/* report operators */ diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c new file mode 100644 index 00000000000..0fc8e157d92 --- /dev/null +++ b/source/blender/editors/space_info/info_report.c @@ -0,0 +1,392 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include +#include + +#include "MEM_guardedalloc.h" + + +#include "BLI_blenlib.h" +#include "BLI_dynstr.h" + +#include "BKE_context.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_screen.h" +#include "ED_types.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "info_intern.h" + +int info_report_mask(SpaceInfo *sinfo) +{ + int report_mask = 0; + + if(sinfo->rpt_mask & INFO_RPT_DEBUG) report_mask |= RPT_DEBUG_ALL; + if(sinfo->rpt_mask & INFO_RPT_INFO) report_mask |= RPT_INFO_ALL; + if(sinfo->rpt_mask & INFO_RPT_OP) report_mask |= RPT_OPERATOR_ALL; + if(sinfo->rpt_mask & INFO_RPT_WARN) report_mask |= RPT_WARNING_ALL; + if(sinfo->rpt_mask & INFO_RPT_ERR) report_mask |= RPT_ERROR_ALL; + + return report_mask; +} + +// TODO, get this working again! +static int report_replay_exec(bContext *C, wmOperator *UNUSED(op)) +{ +// SpaceInfo *sc= CTX_wm_space_info(C); +// ReportList *reports= CTX_wm_reports(C); +// int report_mask= info_report_mask(sc); +// Report *report; + +#if 0 + sc->type= CONSOLE_TYPE_PYTHON; + + for(report=reports->list.last; report; report=report->prev) { + if((report->type & report_mask) && (report->type & RPT_OPERATOR_ALL) && (report->flag & SELECT)) { + console_history_add_str(sc, report->message, 0); + WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, NULL); + + ED_area_tag_redraw(CTX_wm_area(C)); + } + } + + sc->type= CONSOLE_TYPE_REPORT; +#endif + ED_area_tag_redraw(CTX_wm_area(C)); + + return OPERATOR_FINISHED; +} + +void INFO_OT_report_replay(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Replay Operators"; + ot->description= "Replay selected reports"; + ot->idname= "INFO_OT_report_replay"; + + /* api callbacks */ + ot->poll= ED_operator_info_active; + ot->exec= report_replay_exec; + + /* flags */ + /* ot->flag= OPTYPE_REGISTER; */ + + /* properties */ +} + +static int select_report_pick_exec(bContext *C, wmOperator *op) +{ + int report_index= RNA_int_get(op->ptr, "report_index"); + Report *report= BLI_findlink(&CTX_wm_reports(C)->list, report_index); + + if(!report) + return OPERATOR_CANCELLED; + + report->flag ^= SELECT; /* toggle */ + + ED_area_tag_redraw(CTX_wm_area(C)); + + return OPERATOR_FINISHED; +} + +static int select_report_pick_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + SpaceInfo *sinfo= CTX_wm_space_info(C); + ARegion *ar= CTX_wm_region(C); + ReportList *reports= CTX_wm_reports(C); + Report *report; + + report= info_text_pick(sinfo, ar, reports, event->mval[1]); + + RNA_int_set(op->ptr, "report_index", BLI_findindex(&reports->list, report)); + + return select_report_pick_exec(C, op); +} + + +void INFO_OT_select_pick(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Select report"; + ot->description= "Select reports by index"; + ot->idname= "INFO_OT_select_pick"; + + /* api callbacks */ + ot->poll= ED_operator_info_active; + ot->invoke= select_report_pick_invoke; + ot->exec= select_report_pick_exec; + + /* flags */ + /* ot->flag= OPTYPE_REGISTER; */ + + /* properties */ + RNA_def_int(ot->srna, "report_index", 0, 0, INT_MAX, "Report", "The index of the report.", 0, INT_MAX); +} + + + +static int report_select_all_toggle_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceInfo *sinfo= CTX_wm_space_info(C); + ReportList *reports= CTX_wm_reports(C); + int report_mask= info_report_mask(sinfo); + int deselect= 0; + + Report *report; + + for(report=reports->list.last; report; report=report->prev) { + if((report->type & report_mask) && (report->flag & SELECT)) { + deselect= 1; + break; + } + } + + + if(deselect) { + for(report=reports->list.last; report; report=report->prev) + if(report->type & report_mask) + report->flag &= ~SELECT; + } + else { + for(report=reports->list.last; report; report=report->prev) + if(report->type & report_mask) + report->flag |= SELECT; + } + + ED_area_tag_redraw(CTX_wm_area(C)); + + return OPERATOR_FINISHED; +} + +void INFO_OT_select_all_toggle(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "(De)Select All"; + ot->description= "(de)select all reports"; + ot->idname= "INFO_OT_select_all_toggle"; + + /* api callbacks */ + ot->poll= ED_operator_info_active; + ot->exec= report_select_all_toggle_exec; + + /* flags */ + /*ot->flag= OPTYPE_REGISTER;*/ + + /* properties */ +} + +/* borderselect operator */ +static int borderselect_exec(bContext *C, wmOperator *op) +{ + SpaceInfo *sinfo= CTX_wm_space_info(C); + ARegion *ar= CTX_wm_region(C); + ReportList *reports= CTX_wm_reports(C); + int report_mask= info_report_mask(sinfo); + Report *report_min, *report_max, *report; + + //View2D *v2d= UI_view2d_fromcontext(C); + + + rcti rect; + //rctf rectf, rq; + short selecting= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT); + //short mval[2]; + + rect.xmin= RNA_int_get(op->ptr, "xmin"); + rect.ymin= RNA_int_get(op->ptr, "ymin"); + rect.xmax= RNA_int_get(op->ptr, "xmax"); + rect.ymax= RNA_int_get(op->ptr, "ymax"); + + /* + mval[0]= rect.xmin; + mval[1]= rect.ymin; + UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmin, &rectf.ymin); + mval[0]= rect.xmax; + mval[1]= rect.ymax; + UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmax, &rectf.ymax); +*/ + + report_min= info_text_pick(sinfo, ar, reports, rect.ymax); + report_max= info_text_pick(sinfo, ar, reports, rect.ymin); + + /* get the first report if none found */ + if(report_min==NULL) { + // printf("find_min\n"); + for(report=reports->list.first; report; report=report->next) { + if(report->type & report_mask) { + report_min= report; + break; + } + } + } + + if(report_max==NULL) { + // printf("find_max\n"); + for(report=reports->list.last; report; report=report->prev) { + if(report->type & report_mask) { + report_max= report; + break; + } + } + } + + if(report_min==NULL || report_max==NULL) + return OPERATOR_CANCELLED; + + for(report= report_min; (report != report_max->next); report= report->next) { + + if((report->type & report_mask)==0) + continue; + + if(selecting) + report->flag |= SELECT; + else + report->flag &= ~SELECT; + } + + ED_area_tag_redraw(CTX_wm_area(C)); + + return OPERATOR_FINISHED; +} + + +/* ****** Border Select ****** */ +void INFO_OT_select_border(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Border Select"; + ot->description= "Toggle border selection"; + ot->idname= "INFO_OT_select_border"; + + /* api callbacks */ + ot->invoke= WM_border_select_invoke; + ot->exec= borderselect_exec; + ot->modal= WM_border_select_modal; + + ot->poll= ED_operator_info_active; + + /* flags */ + /* ot->flag= OPTYPE_REGISTER; */ + + /* rna */ + WM_operator_properties_gesture_border(ot, FALSE); +} + + + +static int report_delete_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceInfo *sinfo= CTX_wm_space_info(C); + ReportList *reports= CTX_wm_reports(C); + int report_mask= info_report_mask(sinfo); + + + Report *report, *report_next; + + for(report=reports->list.first; report; ) { + + report_next=report->next; + + if((report->type & report_mask) && (report->flag & SELECT)) { + BLI_remlink(&reports->list, report); + MEM_freeN(report->message); + MEM_freeN(report); + } + + report= report_next; + } + + ED_area_tag_redraw(CTX_wm_area(C)); + + return OPERATOR_FINISHED; +} + +void INFO_OT_report_delete(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Delete Reports"; + ot->description= "Delete selected reports"; + ot->idname= "INFO_OT_report_delete"; + + /* api callbacks */ + ot->poll= ED_operator_info_active; + ot->exec= report_delete_exec; + + /* flags */ + /*ot->flag= OPTYPE_REGISTER;*/ + + /* properties */ +} + + +static int report_copy_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceInfo *sinfo= CTX_wm_space_info(C); + ReportList *reports= CTX_wm_reports(C); + int report_mask= info_report_mask(sinfo); + + Report *report; + + DynStr *buf_dyn= BLI_dynstr_new(); + char *buf_str; + + for(report=reports->list.first; report; report= report->next) { + if((report->type & report_mask) && (report->flag & SELECT)) { + BLI_dynstr_append(buf_dyn, report->message); + BLI_dynstr_append(buf_dyn, "\n"); + } + } + + buf_str= BLI_dynstr_get_cstring(buf_dyn); + BLI_dynstr_free(buf_dyn); + + WM_clipboard_text_set(buf_str, 0); + + MEM_freeN(buf_str); + return OPERATOR_FINISHED; +} + +void INFO_OT_report_copy(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Copy Reports to Clipboard"; + ot->description= "Copy selected reports to Clipboard"; + ot->idname= "INFO_OT_report_copy"; + + /* api callbacks */ + ot->poll= ED_operator_info_active; + ot->exec= report_copy_exec; + + /* flags */ + /*ot->flag= OPTYPE_REGISTER;*/ + + /* properties */ +} diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 5173621d9c1..95c1614ffd5 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -49,6 +49,7 @@ #include "UI_resources.h" #include "UI_interface.h" +#include "UI_view2d.h" #include "info_intern.h" // own include @@ -62,7 +63,9 @@ static SpaceLink *info_new(const bContext *UNUSED(C)) sinfo= MEM_callocN(sizeof(SpaceInfo), "initinfo"); sinfo->spacetype= SPACE_INFO; - + + sinfo->rpt_mask= INFO_RPT_OP; + /* header */ ar= MEM_callocN(sizeof(ARegion), "header for info"); @@ -76,6 +79,17 @@ static SpaceLink *info_new(const bContext *UNUSED(C)) BLI_addtail(&sinfo->regionbase, ar); ar->regiontype= RGN_TYPE_WINDOW; + /* keep in sync with console */ + ar->v2d.scroll |= (V2D_SCROLL_RIGHT); + ar->v2d.align |= V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */ + ar->v2d.keepofs |= V2D_LOCKOFS_X; + ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); + ar->v2d.keeptot= V2D_KEEPTOT_BOUNDS; + ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; + + /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */ + //ar->v2d.keepzoom= (V2D_KEEPASPECT|V2D_LIMITZOOM); + return (SpaceLink *)sinfo; } @@ -105,16 +119,54 @@ static SpaceLink *info_duplicate(SpaceLink *sl) /* add handlers, stuff you only do once or on area/region changes */ -static void info_main_area_init(wmWindowManager *UNUSED(wm), ARegion *UNUSED(ar)) +static void info_main_area_init(wmWindowManager *wm, ARegion *ar) { + wmKeyMap *keymap; + + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); + + /* own keymap */ + keymap= WM_keymap_find(wm->defaultconf, "Info", SPACE_INFO, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); } -static void info_main_area_draw(const bContext *UNUSED(C), ARegion *UNUSED(ar)) +static void info_textview_update_rect(const bContext *C, ARegion *ar) { - + SpaceInfo *sinfo= CTX_wm_space_info(C); + View2D *v2d= &ar->v2d; + + UI_view2d_totRect_set(v2d, ar->winx-1, info_textview_height(sinfo, ar, CTX_wm_reports(C))); +} + +static void info_main_area_draw(const bContext *C, ARegion *ar) +{ + /* draw entirely, view changes should be handled here */ + SpaceInfo *sinfo= CTX_wm_space_info(C); + View2D *v2d= &ar->v2d; + View2DScrollers *scrollers; + /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); + + /* quick way to avoid drawing if not bug enough */ + if(ar->winy < 16) + return; + + info_textview_update_rect(C, ar); + + /* worlks best with no view2d matrix set */ + UI_view2d_view_ortho(v2d); + + info_textview_main(sinfo, ar, CTX_wm_reports(C)); + + /* reset view matrix */ + UI_view2d_view_restore(C); + + /* scrollers */ + scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP); + UI_view2d_scrollers_draw(C, v2d, scrollers); + UI_view2d_scrollers_free(scrollers); } void info_operatortypes(void) @@ -125,8 +177,16 @@ void info_operatortypes(void) WM_operatortype_append(FILE_OT_make_paths_absolute); WM_operatortype_append(FILE_OT_report_missing_files); WM_operatortype_append(FILE_OT_find_missing_files); - WM_operatortype_append(INFO_OT_reports_display_update); + + /* info_report.c */ + WM_operatortype_append(INFO_OT_select_pick); + WM_operatortype_append(INFO_OT_select_all_toggle); + WM_operatortype_append(INFO_OT_select_border); + + WM_operatortype_append(INFO_OT_report_replay); + WM_operatortype_append(INFO_OT_report_delete); + WM_operatortype_append(INFO_OT_report_copy); } void info_keymap(struct wmKeyConfig *keyconf) @@ -134,6 +194,20 @@ void info_keymap(struct wmKeyConfig *keyconf) wmKeyMap *keymap= WM_keymap_find(keyconf, "Window", 0, 0); WM_keymap_verify_item(keymap, "INFO_OT_reports_display_update", TIMER, KM_ANY, KM_ANY, 0); + + /* info space */ + keymap= WM_keymap_find(keyconf, "Info", SPACE_INFO, 0); + + + /* report selection */ + WM_keymap_add_item(keymap, "INFO_OT_select_pick", SELECTMOUSE, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "INFO_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "INFO_OT_select_border", BKEY, KM_PRESS, 0, 0); + + WM_keymap_add_item(keymap, "INFO_OT_report_replay", RKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "INFO_OT_report_delete", XKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "INFO_OT_report_delete", DELKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "INFO_OT_report_copy", CKEY, KM_PRESS, KM_CTRL, 0); } /* add handlers, stuff you only do once or on area/region changes */ @@ -147,9 +221,19 @@ static void info_header_area_draw(const bContext *C, ARegion *ar) ED_region_header(C, ar); } -static void info_main_area_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn)) +static void info_main_area_listener(ARegion *ar, wmNotifier *wmn) { + // SpaceInfo *sinfo= sa->spacedata.first; + /* context changes */ + switch(wmn->category) { + case NC_SPACE: + if(wmn->data == ND_SPACE_INFO_REPORT) { + /* redraw also but only for report view, could do less redraws by checking the type */ + ED_region_tag_redraw(ar); + } + break; + } } static void info_header_listener(ARegion *ar, wmNotifier *wmn) @@ -223,10 +307,11 @@ void ED_spacetype_info(void) /* regions: main window */ art= MEM_callocN(sizeof(ARegionType), "spacetype info region"); art->regionid = RGN_TYPE_WINDOW; + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->init= info_main_area_init; art->draw= info_main_area_draw; art->listener= info_main_area_listener; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; BLI_addhead(&st->regiontypes, art); @@ -246,4 +331,3 @@ void ED_spacetype_info(void) BKE_spacetype_register(st); } - diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 0ca31983ac5..eafb03accb8 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -84,11 +84,20 @@ typedef struct SpaceInfo { short blockhandler[8]; /* XXX depricate this */ - struct bScreen *screen; /* browse screen */ - struct Scene *scene; /* browse scene */ + char rpt_mask; + char pad[7]; } SpaceInfo; +/* SpaceInfo.rpt_mask */ +enum { + INFO_RPT_DEBUG = 1<<0, + INFO_RPT_INFO = 1<<1, + INFO_RPT_OP = 1<<2, + INFO_RPT_WARN = 1<<3, + INFO_RPT_ERR = 1<<4, +}; + /* 'Graph' Editor (formerly known as the IPO Editor) */ typedef struct SpaceIpo { SpaceLink *next, *prev; @@ -505,21 +514,6 @@ enum { CONSOLE_LINE_ERROR }; -/* SpaceConsole.rpt_mask */ -enum { - CONSOLE_TYPE_PYTHON=0, - CONSOLE_TYPE_REPORT, -}; - -/* SpaceConsole.type see BKE_report.h */ -enum { - CONSOLE_RPT_DEBUG = 1<<0, - CONSOLE_RPT_INFO = 1<<1, - CONSOLE_RPT_OP = 1<<2, - CONSOLE_RPT_WARN = 1<<3, - CONSOLE_RPT_ERR = 1<<4, -}; - typedef struct SpaceConsole { SpaceLink *next, *prev; ListBase regionbase; /* storage of regions for inactive spaces */ @@ -529,9 +523,7 @@ typedef struct SpaceConsole { short blockhandler[8]; // XXX are these needed? /* space vars */ - int type; /* console/report/..? */ - int rpt_mask; /* which reports to display */ - int flag, lheight; + int lheight, pad; ListBase scrollback; /* ConsoleLine; output */ ListBase history; /* ConsoleLine; command history, current edited line is the first */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 315e1429254..36c4647a6e4 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -62,7 +62,7 @@ EnumPropertyItem space_type_items[] = { {SPACE_TIME, "TIMELINE", 0, "Timeline", ""}, {SPACE_NODE, "NODE_EDITOR", 0, "Node Editor", ""}, {SPACE_LOGIC, "LOGIC_EDITOR", 0, "Logic Editor", ""}, - {SPACE_CONSOLE, "CONSOLE", 0, "Console", ""}, + {SPACE_CONSOLE, "CONSOLE", 0, "Python Console", ""}, {SPACE_USERPREF, "USER_PREFERENCES", 0, "User Preferences", ""}, {0, NULL, 0, NULL, NULL}}; @@ -2012,11 +2012,6 @@ static void rna_def_console_line(BlenderRNA *brna) RNA_def_property_int_funcs(prop, NULL, NULL, "rna_ConsoleLine_cursor_index_range"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CONSOLE, NULL); } - -static EnumPropertyItem console_type_items[] = { - {CONSOLE_TYPE_PYTHON, "PYTHON", 0, "Python", ""}, - {CONSOLE_TYPE_REPORT, "REPORT", 0, "Report", ""}, - {0, NULL, 0, NULL, NULL}}; static void rna_def_space_console(BlenderRNA *brna) { @@ -2033,12 +2028,7 @@ static void rna_def_space_console(BlenderRNA *brna) RNA_def_property_range(prop, 8, 32); RNA_def_property_ui_text(prop, "Font Size", "Font size to use for displaying the text"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CONSOLE, NULL); - - prop= RNA_def_property(srna, "console_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "type"); - RNA_def_property_enum_items(prop, console_type_items); - RNA_def_property_ui_text(prop, "Type", "Console type"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CONSOLE, NULL); + prop= RNA_def_property(srna, "select_start", PROP_INT, PROP_UNSIGNED); /* copied from text editor */ RNA_def_property_int_sdna(prop, NULL, "sel_start"); @@ -2048,32 +2038,6 @@ static void rna_def_space_console(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "sel_end"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CONSOLE, NULL); - /* reporting display */ - prop= RNA_def_property(srna, "show_report_debug", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", CONSOLE_RPT_DEBUG); - RNA_def_property_ui_text(prop, "Show Debug", "Display debug reporting info"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CONSOLE_REPORT, NULL); - - prop= RNA_def_property(srna, "show_report_info", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", CONSOLE_RPT_INFO); - RNA_def_property_ui_text(prop, "Show Info", "Display general information"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CONSOLE_REPORT, NULL); - - prop= RNA_def_property(srna, "show_report_operator", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", CONSOLE_RPT_OP); - RNA_def_property_ui_text(prop, "Show Operator", "Display the operator log"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CONSOLE_REPORT, NULL); - - prop= RNA_def_property(srna, "show_report_warning", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", CONSOLE_RPT_WARN); - RNA_def_property_ui_text(prop, "Show Warn", "Display warnings"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CONSOLE_REPORT, NULL); - - prop= RNA_def_property(srna, "show_report_error", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", CONSOLE_RPT_ERR); - RNA_def_property_ui_text(prop, "Show Error", "Display error text"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CONSOLE_REPORT, NULL); - prop= RNA_def_property(srna, "prompt", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Prompt", "Command line prompt"); @@ -2225,10 +2189,37 @@ static void rna_def_space_filebrowser(BlenderRNA *brna) static void rna_def_space_info(BlenderRNA *brna) { StructRNA *srna; + PropertyRNA *prop; srna= RNA_def_struct(brna, "SpaceInfo", "Space"); RNA_def_struct_sdna(srna, "SpaceInfo"); RNA_def_struct_ui_text(srna, "Space Info", "Info space data"); + + /* reporting display */ + prop= RNA_def_property(srna, "show_report_debug", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", INFO_RPT_DEBUG); + RNA_def_property_ui_text(prop, "Show Debug", "Display debug reporting info"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_INFO_REPORT, NULL); + + prop= RNA_def_property(srna, "show_report_info", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", INFO_RPT_INFO); + RNA_def_property_ui_text(prop, "Show Info", "Display general information"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_INFO_REPORT, NULL); + + prop= RNA_def_property(srna, "show_report_operator", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", INFO_RPT_OP); + RNA_def_property_ui_text(prop, "Show Operator", "Display the operator log"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_INFO_REPORT, NULL); + + prop= RNA_def_property(srna, "show_report_warning", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", INFO_RPT_WARN); + RNA_def_property_ui_text(prop, "Show Warn", "Display warnings"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_INFO_REPORT, NULL); + + prop= RNA_def_property(srna, "show_report_error", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "rpt_mask", INFO_RPT_ERR); + RNA_def_property_ui_text(prop, "Show Error", "Display error text"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_INFO_REPORT, NULL); } static void rna_def_space_userpref(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index c343c9c9788..879378a4053 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1698,7 +1698,7 @@ static void rna_def_userdef_themes(BlenderRNA *brna) {14, "USER_PREFERENCES", ICON_PREFERENCES, "User Preferences", ""}, {15, "INFO", ICON_INFO, "Info", ""}, {16, "FILE_BROWSER", ICON_FILESEL, "File Browser", ""}, - {17, "CONSOLE", ICON_CONSOLE, "Console", ""}, + {17, "CONSOLE", ICON_CONSOLE, "Python Console", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Theme", NULL); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 7af6de6c86c..134e3890b16 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -241,23 +241,23 @@ typedef struct wmNotifier { /* NC_SPACE */ #define ND_SPACE_CONSOLE (1<<16) /* general redraw */ -#define ND_SPACE_CONSOLE_REPORT (2<<16) /* update for reports, could specify type */ -#define ND_SPACE_INFO (2<<16) -#define ND_SPACE_IMAGE (3<<16) -#define ND_SPACE_FILE_PARAMS (4<<16) -#define ND_SPACE_FILE_LIST (5<<16) -#define ND_SPACE_NODE (6<<16) -#define ND_SPACE_OUTLINER (7<<16) -#define ND_SPACE_VIEW3D (8<<16) -#define ND_SPACE_PROPERTIES (9<<16) -#define ND_SPACE_TEXT (10<<16) -#define ND_SPACE_TIME (11<<16) -#define ND_SPACE_GRAPH (12<<16) -#define ND_SPACE_DOPESHEET (13<<16) -#define ND_SPACE_NLA (14<<16) -#define ND_SPACE_SEQUENCER (15<<16) -#define ND_SPACE_NODE_VIEW (16<<16) -#define ND_SPACE_CHANGED (17<<16) /*sent to a new editor type after it's replaced an old one*/ +#define ND_SPACE_INFO_REPORT (2<<16) /* update for reports, could specify type */ +#define ND_SPACE_INFO (3<<16) +#define ND_SPACE_IMAGE (4<<16) +#define ND_SPACE_FILE_PARAMS (5<<16) +#define ND_SPACE_FILE_LIST (6<<16) +#define ND_SPACE_NODE (7<<16) +#define ND_SPACE_OUTLINER (8<<16) +#define ND_SPACE_VIEW3D (9<<16) +#define ND_SPACE_PROPERTIES (10<<16) +#define ND_SPACE_TEXT (11<<16) +#define ND_SPACE_TIME (12<<16) +#define ND_SPACE_GRAPH (13<<16) +#define ND_SPACE_DOPESHEET (14<<16) +#define ND_SPACE_NLA (15<<16) +#define ND_SPACE_SEQUENCER (16<<16) +#define ND_SPACE_NODE_VIEW (17<<16) +#define ND_SPACE_CHANGED (18<<16) /*sent to a new editor type after it's replaced an old one*/ /* subtype, 256 entries too */ #define NOTE_SUBTYPE 0x0000FF00 diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 76b5762fa4e..fa4ff7a7b9b 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -127,7 +127,7 @@ void wm_operator_register(bContext *C, wmOperator *op) } /* so the console is redrawn */ - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CONSOLE_REPORT, NULL); + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO_REPORT, NULL); WM_event_add_notifier(C, NC_WM|ND_HISTORY, NULL); } diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 5da9bb46cfd..628c2aa1922 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -888,6 +888,10 @@ wmKeyMap *WM_keymap_guess_opname(const bContext *C, char *opname) else if (strstr(opname, "CONSOLE_OT")) { km = WM_keymap_find_all(C, "Console", sl->spacetype, 0); } + /* Console */ + else if (strstr(opname, "INFO_OT")) { + km = WM_keymap_find_all(C, "Info", sl->spacetype, 0); + } /* Transform */ else if (strstr(opname, "TRANSFORM_OT")) { diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 42e64646351..b686048e7c8 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -3286,7 +3286,7 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_assign(keymap, "ACTION_OT_select_border"); WM_modalkeymap_assign(keymap, "ANIM_OT_channels_select_border"); WM_modalkeymap_assign(keymap, "ANIM_OT_previewrange_set"); - WM_modalkeymap_assign(keymap, "CONSOLE_OT_select_border"); + WM_modalkeymap_assign(keymap, "INFO_OT_select_border"); WM_modalkeymap_assign(keymap, "FILE_OT_select_border"); WM_modalkeymap_assign(keymap, "GRAPH_OT_select_border"); WM_modalkeymap_assign(keymap, "MARKER_OT_select_border"); -- cgit v1.2.3