2009-07-16 00:50:27 +00:00
|
|
|
/**
|
|
|
|
* $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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Campbell Barton
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_arithb.h"
|
|
|
|
|
|
|
|
#include "BKE_colortools.h"
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "BKE_screen.h"
|
|
|
|
|
|
|
|
#include "ED_space_api.h"
|
|
|
|
#include "ED_screen.h"
|
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
|
|
#include "console_intern.h" // own include
|
|
|
|
|
2009-07-17 02:31:28 +00:00
|
|
|
static void console_update_rect(const bContext *C, ARegion *ar)
|
2009-07-16 22:47:27 +00:00
|
|
|
{
|
|
|
|
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)));
|
|
|
|
}
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
/* ******************** default callbacks for console space ***************** */
|
|
|
|
|
|
|
|
static SpaceLink *console_new(const bContext *C)
|
|
|
|
{
|
|
|
|
ARegion *ar;
|
|
|
|
SpaceConsole *sconsole;
|
|
|
|
|
|
|
|
sconsole= MEM_callocN(sizeof(SpaceConsole), "initconsole");
|
|
|
|
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");
|
|
|
|
|
|
|
|
BLI_addtail(&sconsole->regionbase, ar);
|
|
|
|
ar->regiontype= RGN_TYPE_HEADER;
|
|
|
|
ar->alignment= RGN_ALIGN_BOTTOM;
|
|
|
|
|
|
|
|
|
|
|
|
/* main area */
|
|
|
|
ar= MEM_callocN(sizeof(ARegion), "main area for text");
|
|
|
|
|
|
|
|
BLI_addtail(&sconsole->regionbase, ar);
|
|
|
|
ar->regiontype= RGN_TYPE_WINDOW;
|
|
|
|
|
2009-07-16 22:47:27 +00:00
|
|
|
|
2009-07-17 12:35:57 +00:00
|
|
|
ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
|
2009-07-16 22:47:27 +00:00
|
|
|
ar->v2d.align |= V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */
|
|
|
|
ar->v2d.keepofs |= V2D_LOCKOFS_X;
|
2009-07-29 22:57:53 +00:00
|
|
|
ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
|
2009-07-16 22:47:27 +00:00
|
|
|
ar->v2d.keeptot= V2D_KEEPTOT_BOUNDS;
|
2009-07-16 00:50:27 +00:00
|
|
|
ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
|
2009-07-16 22:47:27 +00:00
|
|
|
|
|
|
|
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
|
2009-07-29 22:57:53 +00:00
|
|
|
//ar->v2d.keepzoom= (V2D_KEEPASPECT|V2D_LIMITZOOM);
|
2009-07-16 22:47:27 +00:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
return (SpaceLink *)sconsole;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not spacelink itself */
|
|
|
|
static void console_free(SpaceLink *sl)
|
|
|
|
{
|
|
|
|
SpaceConsole *sc= (SpaceConsole*) sl;
|
|
|
|
|
|
|
|
while(sc->scrollback.first)
|
|
|
|
console_scrollback_free(sc, sc->scrollback.first);
|
|
|
|
|
|
|
|
while(sc->history.first)
|
|
|
|
console_history_free(sc, sc->history.first);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* spacetype; init callback */
|
|
|
|
static void console_init(struct wmWindowManager *wm, ScrArea *sa)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static SpaceLink *console_duplicate(SpaceLink *sl)
|
|
|
|
{
|
|
|
|
SpaceConsole *sconsolen= MEM_dupallocN(sl);
|
|
|
|
|
|
|
|
/* clear or remove stuff from old */
|
|
|
|
|
|
|
|
/* TODO - duplicate?, then we also need to duplicate the py namespace */
|
|
|
|
sconsolen->scrollback.first= sconsolen->scrollback.last= NULL;
|
|
|
|
sconsolen->history.first= sconsolen->history.last= NULL;
|
|
|
|
|
|
|
|
return (SpaceLink *)sconsolen;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
|
|
|
static void console_main_area_init(wmWindowManager *wm, ARegion *ar)
|
|
|
|
{
|
|
|
|
ListBase *keymap;
|
2009-07-16 22:47:27 +00:00
|
|
|
|
|
|
|
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
|
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
/* own keymap */
|
|
|
|
keymap= WM_keymap_listbase(wm, "Console", SPACE_CONSOLE, 0); /* XXX weak? */
|
|
|
|
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void console_main_area_draw(const bContext *C, ARegion *ar)
|
|
|
|
{
|
|
|
|
/* draw entirely, view changes should be handled here */
|
|
|
|
SpaceConsole *sc= CTX_wm_space_console(C);
|
2009-07-16 22:47:27 +00:00
|
|
|
View2D *v2d= &ar->v2d;
|
|
|
|
View2DScrollers *scrollers;
|
2009-07-16 00:50:27 +00:00
|
|
|
//float col[3];
|
|
|
|
|
|
|
|
/* add helper text, why not? */
|
|
|
|
if(sc->scrollback.first==NULL) {
|
|
|
|
console_scrollback_add_str(C, " * Python Interactive Console *", 0);
|
|
|
|
console_scrollback_add_str(C, "Command History: Up/Down Arrow", 0);
|
|
|
|
console_scrollback_add_str(C, "Cursor: Left/Right Home/End", 0);
|
|
|
|
console_scrollback_add_str(C, "Remove: Backspace/Delete", 0);
|
|
|
|
console_scrollback_add_str(C, "Execute: Enter", 0);
|
2009-07-28 08:50:11 +00:00
|
|
|
console_scrollback_add_str(C, "Autocomplete: Ctrl+Space", 0);
|
2009-07-16 00:50:27 +00:00
|
|
|
console_scrollback_add_str(C, "Ctrl +/- Wheel: Zoom", 0);
|
|
|
|
console_scrollback_add_str(C, "Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.ui", 0);
|
|
|
|
}
|
|
|
|
|
2009-07-16 22:47:27 +00:00
|
|
|
/* clear and setup matrix */
|
|
|
|
//UI_GetThemeColor3fv(TH_BACK, col);
|
|
|
|
//glClearColor(col[0], col[1], col[2], 0.0);
|
|
|
|
glClearColor(0, 0, 0, 1.0);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
|
|
console_update_rect(C, ar);
|
|
|
|
|
|
|
|
/* worlks best with no view2d matrix set */
|
|
|
|
UI_view2d_view_ortho(C, v2d);
|
|
|
|
|
|
|
|
/* data... */
|
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
console_history_verify(C); /* make sure we have some command line */
|
|
|
|
console_text_main(sc, ar, CTX_wm_reports(C));
|
|
|
|
|
|
|
|
/* reset view matrix */
|
2009-07-16 22:47:27 +00:00
|
|
|
UI_view2d_view_restore(C);
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
/* scrollers */
|
2009-07-16 22:47:27 +00:00
|
|
|
scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
|
2009-07-16 00:50:27 +00:00
|
|
|
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
|
|
|
UI_view2d_scrollers_free(scrollers);
|
|
|
|
}
|
|
|
|
|
|
|
|
void console_operatortypes(void)
|
|
|
|
{
|
2009-07-19 00:49:44 +00:00
|
|
|
/* console_ops.c */
|
2009-07-16 00:50:27 +00:00
|
|
|
WM_operatortype_append(CONSOLE_OT_move);
|
|
|
|
WM_operatortype_append(CONSOLE_OT_delete);
|
|
|
|
WM_operatortype_append(CONSOLE_OT_insert);
|
|
|
|
|
|
|
|
/* for use by python only */
|
|
|
|
WM_operatortype_append(CONSOLE_OT_history_append);
|
|
|
|
WM_operatortype_append(CONSOLE_OT_scrollback_append);
|
|
|
|
|
|
|
|
WM_operatortype_append(CONSOLE_OT_clear);
|
|
|
|
WM_operatortype_append(CONSOLE_OT_history_cycle);
|
2009-07-26 04:31:46 +00:00
|
|
|
WM_operatortype_append(CONSOLE_OT_copy);
|
2009-07-30 01:52:00 +00:00
|
|
|
WM_operatortype_append(CONSOLE_OT_paste);
|
2009-07-16 00:50:27 +00:00
|
|
|
WM_operatortype_append(CONSOLE_OT_zoom);
|
2009-07-18 16:27:25 +00:00
|
|
|
|
2009-07-19 00:49:44 +00:00
|
|
|
|
|
|
|
/* 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);
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void console_keymap(struct wmWindowManager *wm)
|
|
|
|
{
|
|
|
|
ListBase *keymap= WM_keymap_listbase(wm, "Console", SPACE_CONSOLE, 0);
|
|
|
|
|
2009-09-09 19:43:05 +00:00
|
|
|
#ifdef __APPLE__
|
2009-07-16 00:50:27 +00:00
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_BEGIN);
|
2009-09-09 19:43:05 +00:00
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_END);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", LINE_BEGIN);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", LINE_END);
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", HOMEKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_BEGIN);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", ENDKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_END);
|
|
|
|
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_zoom", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_zoom", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
|
|
|
|
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_zoom", PADPLUSKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_zoom", PADMINUS, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
|
|
|
|
|
|
|
|
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_CHAR);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_CHAR);
|
|
|
|
|
|
|
|
RNA_boolean_set(WM_keymap_add_item(keymap, "CONSOLE_OT_history_cycle", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "reverse", 1);
|
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_history_cycle", DOWNARROWKEY, KM_PRESS, 0, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", PREV_WORD);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", NEXT_WORD);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_LINE);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_LINE);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", PAGEUPKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_PAGE);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", PAGEDOWNKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_PAGE);
|
|
|
|
|
|
|
|
|
|
|
|
//RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_CHAR);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_CHAR);
|
|
|
|
//RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_CHAR);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_WORD);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_PREV_WORD);
|
|
|
|
*/
|
|
|
|
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_CHAR);
|
|
|
|
RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_CHAR);
|
|
|
|
|
|
|
|
#ifndef DISABLE_PYTHON
|
2009-09-04 04:29:54 +00:00
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_execute", RETKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */
|
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_execute", PADENTER, KM_PRESS, 0, 0);
|
2009-07-24 23:07:18 +00:00
|
|
|
|
2009-07-16 22:47:27 +00:00
|
|
|
//WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", TABKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */
|
2009-07-28 08:50:11 +00:00
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* python operator - space_text.py */
|
2009-07-16 00:50:27 +00:00
|
|
|
#endif
|
2009-07-16 22:47:27 +00:00
|
|
|
|
2009-07-19 00:49:44 +00:00
|
|
|
/* 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);
|
2009-07-26 04:31:46 +00:00
|
|
|
|
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
|
2009-07-30 01:52:00 +00:00
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
|
2009-07-19 00:49:44 +00:00
|
|
|
|
2009-07-16 22:47:27 +00:00
|
|
|
RNA_string_set(WM_keymap_add_item(keymap, "CONSOLE_OT_insert", TABKEY, KM_PRESS, 0, 0)->ptr, "text", " "); /* fake tabs */
|
2009-07-24 23:07:18 +00:00
|
|
|
WM_keymap_add_item(keymap, "CONSOLE_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last!
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************** header region ******************/
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
|
|
|
static void console_header_area_init(wmWindowManager *wm, ARegion *ar)
|
|
|
|
{
|
|
|
|
ED_region_header_init(ar);
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
SpaceConsole *sc= sa->spacedata.first;
|
|
|
|
|
|
|
|
/* context changes */
|
|
|
|
switch(wmn->category) {
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
case NC_SPACE:
|
|
|
|
if(wmn->data == ND_SPACE_CONSOLE) { /* generic redraw request */
|
2009-07-16 00:50:27 +00:00
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
}
|
2.5
Notifiers
---------
Various fixes for wrong use of notifiers, and some new notifiers
to make things a bit more clear and consistent, with two notable
changes:
* Geometry changes are now done with NC_GEOM, rather than
NC_OBJECT|ND_GEOM_, so an object does need to be available.
* Space data now use NC_SPACE|ND_SPACE_*, instead of data
notifiers or even NC_WINDOW in some cases. Note that NC_SPACE
should only be used for notifying about changes in space data,
we don't want to go back to allqueue(REDRAW..).
Depsgraph
---------
The dependency graph now has a different flush call:
DAG_object_flush_update(scene, ob, flag)
is replaced by:
DAG_id_flush_update(id, flag)
It still works basically the same, one difference is that it now
also accepts object data (e.g. Mesh), again to avoid requiring an
Object to be available. Other ID types will simply do nothing at
the moment.
Docs
----
I made some guidelines for how/when to do which kinds of updates
and notifiers. I can't specify totally exact how to make these
decisions, but these are basically the guidelines I use. So, new
and updated docs are here:
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/NotifiersUpdates
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataNotifiers
2009-09-04 20:51:09 +00:00
|
|
|
else if(wmn->data == ND_SPACE_CONSOLE_REPORT && sc->type==CONSOLE_TYPE_REPORT) {
|
2009-07-16 00:50:27 +00:00
|
|
|
/* redraw also but only for report view, could do less redraws by checking the type */
|
|
|
|
ED_area_tag_redraw(sa);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only called once, from space/spacetypes.c */
|
|
|
|
void ED_spacetype_console(void)
|
|
|
|
{
|
|
|
|
SpaceType *sc= MEM_callocN(sizeof(SpaceType), "spacetype console");
|
|
|
|
ARegionType *art;
|
|
|
|
|
|
|
|
sc->spaceid= SPACE_CONSOLE;
|
|
|
|
|
|
|
|
sc->new= console_new;
|
|
|
|
sc->free= console_free;
|
|
|
|
sc->init= console_init;
|
|
|
|
sc->duplicate= console_duplicate;
|
|
|
|
sc->operatortypes= console_operatortypes;
|
|
|
|
sc->keymap= console_keymap;
|
|
|
|
sc->listener= console_main_area_listener;
|
|
|
|
|
|
|
|
/* regions: main window */
|
|
|
|
art= MEM_callocN(sizeof(ARegionType), "spacetype console region");
|
|
|
|
art->regionid = RGN_TYPE_WINDOW;
|
2009-07-16 22:47:27 +00:00
|
|
|
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
|
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
art->init= console_main_area_init;
|
|
|
|
art->draw= console_main_area_draw;
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-16 22:47:27 +00:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
BLI_addhead(&sc->regiontypes, art);
|
|
|
|
|
|
|
|
/* regions: header */
|
|
|
|
art= MEM_callocN(sizeof(ARegionType), "spacetype console region");
|
|
|
|
art->regionid = RGN_TYPE_HEADER;
|
|
|
|
art->minsizey= HEADERY;
|
|
|
|
art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
|
|
|
|
|
|
|
|
art->init= console_header_area_init;
|
|
|
|
art->draw= console_header_area_draw;
|
|
|
|
|
|
|
|
BLI_addhead(&sc->regiontypes, art);
|
|
|
|
|
|
|
|
|
2009-07-18 16:27:25 +00:00
|
|
|
BKE_spacetype_register(sc);
|
|
|
|
}
|