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:
Diffstat (limited to 'source/blender/editors/space_info')
-rw-r--r--source/blender/editors/space_info/CMakeLists.txt2
-rw-r--r--source/blender/editors/space_info/info_draw.c192
-rw-r--r--source/blender/editors/space_info/info_intern.h18
-rw-r--r--source/blender/editors/space_info/info_ops.c2
-rw-r--r--source/blender/editors/space_info/info_report.c392
-rw-r--r--source/blender/editors/space_info/space_info.c100
6 files changed, 697 insertions, 9 deletions
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 <math.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <limits.h>
+
+
+#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 <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+#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);
}
-