2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-07-16 00:50:27 +00:00
|
|
|
* 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
|
2018-06-01 18:19:39 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2009-07-16 00:50:27 +00:00
|
|
|
*
|
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-07-16 00:50:27 +00:00
|
|
|
*/
|
2011-02-27 20:29:51 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup spconsole
|
2011-02-27 20:29:51 +00:00
|
|
|
*/
|
|
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
#include <stdio.h>
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <string.h>
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_global.h"
|
2009-07-16 00:50:27 +00:00
|
|
|
#include "BKE_screen.h"
|
|
|
|
|
|
|
|
|
|
#include "ED_screen.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "ED_space_api.h"
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
#include "UI_view2d.h"
|
|
|
|
|
|
2018-06-27 19:07:23 -06:00
|
|
|
#include "GPU_framebuffer.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "console_intern.h" /* own include */
|
2009-07-16 00:50:27 +00:00
|
|
|
|
|
|
|
|
/* ******************** default callbacks for console space ***************** */
|
|
|
|
|
|
2020-08-04 14:39:53 +02:00
|
|
|
static SpaceLink *console_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region;
|
2009-07-16 00:50:27 +00:00
|
|
|
SpaceConsole *sconsole;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
sconsole = MEM_callocN(sizeof(SpaceConsole), "initconsole");
|
|
|
|
|
sconsole->spacetype = SPACE_CONSOLE;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
sconsole->lheight = 14;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
/* header */
|
2020-03-06 16:56:42 +01:00
|
|
|
region = MEM_callocN(sizeof(ARegion), "header for console");
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
BLI_addtail(&sconsole->regionbase, region);
|
|
|
|
|
region->regiontype = RGN_TYPE_HEADER;
|
|
|
|
|
region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
/* main region */
|
2020-03-06 16:56:42 +01:00
|
|
|
region = MEM_callocN(sizeof(ARegion), "main region for text");
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
BLI_addtail(&sconsole->regionbase, region);
|
|
|
|
|
region->regiontype = RGN_TYPE_WINDOW;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-11-11 13:36:57 +00:00
|
|
|
/* keep in sync with info */
|
2020-06-18 12:21:38 +10:00
|
|
|
region->v2d.scroll |= V2D_SCROLL_RIGHT;
|
2020-03-06 16:56:42 +01:00
|
|
|
region->v2d.align |= V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y; /* align bottom left */
|
|
|
|
|
region->v2d.keepofs |= V2D_LOCKOFS_X;
|
|
|
|
|
region->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
|
|
|
|
|
region->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
|
|
|
|
|
region->v2d.minzoom = region->v2d.maxzoom = 1.0f;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2012-03-28 11:53:18 +00:00
|
|
|
/* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
|
2020-03-06 16:56:42 +01:00
|
|
|
// region->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)
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceConsole *sc = (SpaceConsole *)sl;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
while (sc->scrollback.first) {
|
2009-07-16 00:50:27 +00:00
|
|
|
console_scrollback_free(sc, sc->scrollback.first);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
while (sc->history.first) {
|
2009-07-16 00:50:27 +00:00
|
|
|
console_history_free(sc, sc->history.first);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* spacetype; init callback */
|
2020-04-03 13:25:03 +02:00
|
|
|
static void console_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static SpaceLink *console_duplicate(SpaceLink *sl)
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceConsole *sconsolen = MEM_dupallocN(sl);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
/* clear or remove stuff from old */
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
/* TODO - duplicate?, then we also need to duplicate the py namespace */
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&sconsolen->scrollback);
|
|
|
|
|
BLI_listbase_clear(&sconsolen->history);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
return (SpaceLink *)sconsolen;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2020-03-06 16:56:42 +01:00
|
|
|
static void console_main_region_init(wmWindowManager *wm, ARegion *region)
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
2009-09-17 21:36:02 +00:00
|
|
|
wmKeyMap *keymap;
|
2010-05-08 07:25:26 +00:00
|
|
|
ListBase *lb;
|
2009-07-16 22:47:27 +00:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
const float prev_y_min = region->v2d.cur.ymin; /* so re-sizing keeps the cursor visible */
|
2011-09-18 01:34:53 +00:00
|
|
|
|
2013-04-12 12:30:05 +00:00
|
|
|
/* force it on init, for old files, until it becomes config */
|
2020-03-06 16:56:42 +01:00
|
|
|
region->v2d.scroll = (V2D_SCROLL_RIGHT);
|
2013-04-12 12:30:05 +00:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
UI_view2d_region_reinit(®ion->v2d, V2D_COMMONVIEW_CUSTOM, region->winx, region->winy);
|
2009-07-16 22:47:27 +00:00
|
|
|
|
2011-09-18 01:34:53 +00:00
|
|
|
/* always keep the bottom part of the view aligned, less annoying */
|
2020-03-06 16:56:42 +01:00
|
|
|
if (prev_y_min != region->v2d.cur.ymin) {
|
|
|
|
|
const float cur_y_range = BLI_rctf_size_y(®ion->v2d.cur);
|
|
|
|
|
region->v2d.cur.ymin = prev_y_min;
|
|
|
|
|
region->v2d.cur.ymax = prev_y_min + cur_y_range;
|
2011-09-18 01:34:53 +00:00
|
|
|
}
|
|
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
/* own keymap */
|
2018-08-31 13:36:14 +10:00
|
|
|
keymap = WM_keymap_ensure(wm->defaultconf, "Console", SPACE_CONSOLE, 0);
|
2020-03-06 16:56:42 +01:00
|
|
|
WM_event_add_keymap_handler_v2d_mask(®ion->handlers, keymap);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-05-08 07:25:26 +00:00
|
|
|
/* add drop boxes */
|
2012-03-28 11:53:18 +00:00
|
|
|
lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
WM_event_add_dropbox_handler(®ion->handlers, lb);
|
2010-05-08 07:25:26 +00:00
|
|
|
}
|
|
|
|
|
|
2014-06-30 18:12:29 +10:00
|
|
|
/* same as 'text_cursor' */
|
2020-04-03 13:25:03 +02:00
|
|
|
static void console_cursor(wmWindow *win, ScrArea *UNUSED(area), ARegion *region)
|
2014-06-30 18:12:29 +10:00
|
|
|
{
|
2019-09-26 14:31:48 +02:00
|
|
|
int wmcursor = WM_CURSOR_TEXT_EDIT;
|
2019-11-25 22:49:44 +11:00
|
|
|
const wmEvent *event = win->eventstate;
|
2020-03-06 16:56:42 +01:00
|
|
|
if (UI_view2d_mouse_in_scrollers(region, ®ion->v2d, event->x, event->y)) {
|
2019-09-26 14:31:48 +02:00
|
|
|
wmcursor = WM_CURSOR_DEFAULT;
|
2014-06-30 18:12:29 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_cursor_set(win, wmcursor);
|
|
|
|
|
}
|
2010-05-08 07:25:26 +00:00
|
|
|
|
|
|
|
|
/* ************* dropboxes ************* */
|
|
|
|
|
|
2018-08-07 10:38:20 +02:00
|
|
|
static bool id_drop_poll(bContext *UNUSED(C),
|
|
|
|
|
wmDrag *drag,
|
|
|
|
|
const wmEvent *UNUSED(event),
|
|
|
|
|
const char **UNUSED(tooltip))
|
2010-05-08 07:25:26 +00:00
|
|
|
{
|
Asset System: Support dragging assets and appending on drop
For the Asset Browser, it needs to be possible to drag assets into various
editors, which may not come from the current .blend file. In other words, the
dragging needs to work with just the asset metadata, without direct access to
the data-block itself.
Idea is simple: When dragging an asset, store the source file-path and
data-block name and when dropping, append the data-block. It uses existing drop
operators, but the function to get the dropped data-block is replaced with one
that returns the local data-block, or, in case of an external asset, appends
the data-block first.
The drop operators need to be adjusted to use this new function that respects
assets. With this patch it only works for dragging assets into the 3D view.
Note that I expect this to be a short-lived change. A refactor like D4071 is
needed to make the drag & drop system more future proof for assets and other
use cases.
Part of the first Asset Browser milestone. Check the #asset_browser_milestone_1
project milestone on developer.blender.org.
Differential Revision: https://developer.blender.org/D9721
Reviewed by: Bastien Montagne, Brecht Van Lommel
2020-12-14 13:31:55 +01:00
|
|
|
return WM_drag_get_local_ID(drag, 0) != NULL;
|
2010-05-08 07:25:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void id_drop_copy(wmDrag *drag, wmDropBox *drop)
|
|
|
|
|
{
|
Asset System: Support dragging assets and appending on drop
For the Asset Browser, it needs to be possible to drag assets into various
editors, which may not come from the current .blend file. In other words, the
dragging needs to work with just the asset metadata, without direct access to
the data-block itself.
Idea is simple: When dragging an asset, store the source file-path and
data-block name and when dropping, append the data-block. It uses existing drop
operators, but the function to get the dropped data-block is replaced with one
that returns the local data-block, or, in case of an external asset, appends
the data-block first.
The drop operators need to be adjusted to use this new function that respects
assets. With this patch it only works for dragging assets into the 3D view.
Note that I expect this to be a short-lived change. A refactor like D4071 is
needed to make the drag & drop system more future proof for assets and other
use cases.
Part of the first Asset Browser milestone. Check the #asset_browser_milestone_1
project milestone on developer.blender.org.
Differential Revision: https://developer.blender.org/D9721
Reviewed by: Bastien Montagne, Brecht Van Lommel
2020-12-14 13:31:55 +01:00
|
|
|
ID *id = WM_drag_get_local_ID(drag, 0);
|
2010-05-08 07:25:26 +00:00
|
|
|
|
|
|
|
|
/* copy drag path to properties */
|
2019-08-22 20:43:19 +03:00
|
|
|
char *text = RNA_path_full_ID_py(G_MAIN, id);
|
2010-05-08 07:25:26 +00:00
|
|
|
RNA_string_set(drop->ptr, "text", text);
|
2012-12-02 07:13:19 +00:00
|
|
|
MEM_freeN(text);
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
2018-08-07 10:38:20 +02:00
|
|
|
static bool path_drop_poll(bContext *UNUSED(C),
|
|
|
|
|
wmDrag *drag,
|
|
|
|
|
const wmEvent *UNUSED(event),
|
|
|
|
|
const char **UNUSED(tooltip))
|
2010-05-08 07:25:26 +00:00
|
|
|
{
|
2018-08-07 10:57:09 +02:00
|
|
|
return (drag->type == WM_DRAG_PATH);
|
2010-05-08 07:25:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void path_drop_copy(wmDrag *drag, wmDropBox *drop)
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
char pathname[FILE_MAX + 2];
|
2011-08-30 10:07:50 +00:00
|
|
|
BLI_snprintf(pathname, sizeof(pathname), "\"%s\"", drag->path);
|
2010-05-08 07:25:26 +00:00
|
|
|
RNA_string_set(drop->ptr, "text", pathname);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* this region dropbox definition */
|
|
|
|
|
static void console_dropboxes(void)
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
ListBase *lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2010-05-08 07:25:26 +00:00
|
|
|
WM_dropbox_add(lb, "CONSOLE_OT_insert", id_drop_poll, id_drop_copy);
|
|
|
|
|
WM_dropbox_add(lb, "CONSOLE_OT_insert", path_drop_poll, path_drop_copy);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************* end drop *********** */
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
static void console_main_region_draw(const bContext *C, ARegion *region)
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
|
|
|
|
/* draw entirely, view changes should be handled here */
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceConsole *sc = CTX_wm_space_console(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
View2D *v2d = ®ion->v2d;
|
2010-11-30 22:39:41 +00:00
|
|
|
|
2019-03-26 21:16:47 +11:00
|
|
|
if (BLI_listbase_is_empty(&sc->scrollback)) {
|
2009-11-05 11:17:09 +00:00
|
|
|
WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL);
|
2019-03-26 21:16:47 +11:00
|
|
|
}
|
2009-11-05 11:17:09 +00:00
|
|
|
|
2009-07-16 22:47:27 +00:00
|
|
|
/* clear and setup matrix */
|
2010-04-06 07:02:16 +00:00
|
|
|
UI_ThemeClearColor(TH_BACK);
|
2009-07-16 22:47:27 +00:00
|
|
|
|
|
|
|
|
/* worlks best with no view2d matrix set */
|
2010-10-14 01:22:14 +00:00
|
|
|
UI_view2d_view_ortho(v2d);
|
2009-07-16 22:47:27 +00:00
|
|
|
|
|
|
|
|
/* data... */
|
|
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
console_history_verify(C); /* make sure we have some command line */
|
2020-03-06 16:56:42 +01:00
|
|
|
console_textview_main(sc, region);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
/* reset view matrix */
|
2009-07-16 22:47:27 +00:00
|
|
|
UI_view2d_view_restore(C);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
/* scrollers */
|
2020-06-22 21:44:18 +02:00
|
|
|
UI_view2d_scrollers_draw(v2d, NULL);
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void console_operatortypes(void)
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
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);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-04 07:24:19 +00:00
|
|
|
WM_operatortype_append(CONSOLE_OT_indent);
|
2019-11-22 20:50:17 +11:00
|
|
|
WM_operatortype_append(CONSOLE_OT_indent_or_autocomplete);
|
2012-06-04 07:24:19 +00:00
|
|
|
WM_operatortype_append(CONSOLE_OT_unindent);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
/* for use by python only */
|
2018-06-04 09:31:30 +02:00
|
|
|
WM_operatortype_append(CONSOLE_OT_history_append);
|
2009-07-16 00:50:27 +00:00
|
|
|
WM_operatortype_append(CONSOLE_OT_scrollback_append);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-09 14:58:57 +00:00
|
|
|
WM_operatortype_append(CONSOLE_OT_clear);
|
|
|
|
|
WM_operatortype_append(CONSOLE_OT_clear_line);
|
2009-07-16 00:50:27 +00:00
|
|
|
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-12-27 20:22:06 +00:00
|
|
|
WM_operatortype_append(CONSOLE_OT_select_set);
|
2015-03-16 16:01:32 +11:00
|
|
|
WM_operatortype_append(CONSOLE_OT_select_word);
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void console_keymap(struct wmKeyConfig *keyconf)
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
2018-11-08 15:59:51 +11:00
|
|
|
WM_keymap_ensure(keyconf, "Console", SPACE_CONSOLE, 0);
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/****************** header region ******************/
|
|
|
|
|
|
|
|
|
|
/* add handlers, stuff you only do once or on area/region changes */
|
2020-03-06 16:56:42 +01:00
|
|
|
static void console_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_header_init(region);
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-06 16:56:42 +01:00
|
|
|
static void console_header_region_draw(const bContext *C, ARegion *region)
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_header(C, region);
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-19 12:59:00 +11:00
|
|
|
static void console_main_region_listener(const wmRegionListenerParams *params)
|
2009-07-16 00:50:27 +00:00
|
|
|
{
|
2021-01-18 17:28:47 -06:00
|
|
|
ScrArea *area = params->area;
|
|
|
|
|
ARegion *region = params->region;
|
|
|
|
|
wmNotifier *wmn = params->notifier;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
/* context changes */
|
2012-03-28 11:53:18 +00:00
|
|
|
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: {
|
2015-12-18 16:02:31 +11:00
|
|
|
if (wmn->data == ND_SPACE_CONSOLE) {
|
|
|
|
|
if (wmn->action == NA_EDITED) {
|
2020-04-03 13:25:03 +02:00
|
|
|
if ((wmn->reference && area) && (wmn->reference == area->spacedata.first)) {
|
2015-12-18 16:02:31 +11:00
|
|
|
/* we've modified the geometry (font size), re-calculate rect */
|
2020-03-06 16:56:42 +01:00
|
|
|
console_textview_update_rect(wmn->reference, region);
|
|
|
|
|
ED_region_tag_redraw(region);
|
2015-12-18 16:02:31 +11:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* generic redraw request */
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_tag_redraw(region);
|
2015-12-18 16:02:31 +11:00
|
|
|
}
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2015-12-18 16:02:31 +11:00
|
|
|
}
|
2009-07-16 00:50:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* only called once, from space/spacetypes.c */
|
|
|
|
|
void ED_spacetype_console(void)
|
|
|
|
|
{
|
2012-03-28 11:53:18 +00:00
|
|
|
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype console");
|
|
|
|
|
ARegionType *art;
|
2009-07-16 22:47:27 +00:00
|
|
|
|
2014-06-30 18:12:29 +10:00
|
|
|
st->spaceid = SPACE_CONSOLE;
|
2015-11-28 17:14:45 +01:00
|
|
|
strncpy(st->name, "Console", BKE_ST_MAXNAME);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2020-08-04 14:39:53 +02:00
|
|
|
st->create = console_create;
|
2012-03-28 11:53:18 +00:00
|
|
|
st->free = console_free;
|
|
|
|
|
st->init = console_init;
|
|
|
|
|
st->duplicate = console_duplicate;
|
|
|
|
|
st->operatortypes = console_operatortypes;
|
|
|
|
|
st->keymap = console_keymap;
|
|
|
|
|
st->dropboxes = console_dropboxes;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
/* regions: main window */
|
2012-03-28 11:53:18 +00:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype console region");
|
2009-07-16 00:50:27 +00:00
|
|
|
art->regionid = RGN_TYPE_WINDOW;
|
2012-03-28 11:53:18 +00:00
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
|
2009-07-16 22:47:27 +00:00
|
|
|
|
2015-11-28 17:14:45 +01:00
|
|
|
art->init = console_main_region_init;
|
|
|
|
|
art->draw = console_main_region_draw;
|
2014-06-30 18:12:29 +10:00
|
|
|
art->cursor = console_cursor;
|
2019-11-25 22:49:44 +11:00
|
|
|
art->event_cursor = true;
|
2009-12-19 22:37:51 +00:00
|
|
|
art->listener = console_main_region_listener;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-07-16 00:50:27 +00:00
|
|
|
/* regions: header */
|
2015-11-28 17:14:45 +01:00
|
|
|
art = MEM_callocN(sizeof(ARegionType), "spacetype console region");
|
|
|
|
|
art->regionid = RGN_TYPE_HEADER;
|
|
|
|
|
art->prefsizey = HEADERY;
|
|
|
|
|
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
|
2018-06-04 09:31:30 +02:00
|
|
|
|
2009-12-19 22:37:51 +00:00
|
|
|
art->init = console_header_region_init;
|
|
|
|
|
art->draw = console_header_region_draw;
|
2009-07-16 00:50:27 +00:00
|
|
|
|
2009-12-19 22:37:51 +00:00
|
|
|
BLI_addhead(&st->regiontypes, art);
|
2009-07-16 00:50:27 +00:00
|
|
|
|
2009-12-19 22:37:51 +00:00
|
|
|
BKE_spacetype_register(st);
|
2009-07-18 16:27:25 +00:00
|
|
|
}
|