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:
authorJacques Lucke <jacques@blender.org>2021-03-08 18:23:21 +0300
committerJacques Lucke <jacques@blender.org>2021-03-08 18:25:08 +0300
commit9cb5f0a2282a7a84f7f8636b43a32bdc04b51cd5 (patch)
tree59e8cbfbc6035069507dc1085c425247af40772e /source/blender/editors/space_spreadsheet
parentd230c9b96c516e718014fb50914fcada1a7ec98f (diff)
Spreadsheet: add boilerplate code for new editor type
This adds the initial boilerplate code that is required to introduce the new spreadsheet editor. The editor is still hidden from the ui. It can be made visible by undoing the change in `rna_screen.c`. This patch does not contain any business logic for the spreadsheet editor. Differential Revision: https://developer.blender.org/D10645 Ref T86279.
Diffstat (limited to 'source/blender/editors/space_spreadsheet')
-rw-r--r--source/blender/editors/space_spreadsheet/CMakeLists.txt39
-rw-r--r--source/blender/editors/space_spreadsheet/space_spreadsheet.cc221
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_intern.hh19
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_ops.cc21
4 files changed, 300 insertions, 0 deletions
diff --git a/source/blender/editors/space_spreadsheet/CMakeLists.txt b/source/blender/editors/space_spreadsheet/CMakeLists.txt
new file mode 100644
index 00000000000..8be5f506dd7
--- /dev/null
+++ b/source/blender/editors/space_spreadsheet/CMakeLists.txt
@@ -0,0 +1,39 @@
+# ***** 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.
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+ ../include
+ ../../blenkernel
+ ../../blenlib
+ ../../makesdna
+ ../../makesrna
+ ../../windowmanager
+ ../../../../intern/glew-mx
+ ../../../../intern/guardedalloc
+)
+
+set(SRC
+ space_spreadsheet.cc
+ spreadsheet_ops.cc
+
+ spreadsheet_intern.hh
+)
+
+set(LIB
+)
+
+blender_add_lib(bf_editor_space_spreadsheet "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
new file mode 100644
index 00000000000..27276b4bedc
--- /dev/null
+++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
@@ -0,0 +1,221 @@
+/*
+ * 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.
+ */
+
+#include <cstring>
+
+#include "BLI_listbase.h"
+
+#include "BKE_screen.h"
+
+#include "ED_screen.h"
+#include "ED_space_api.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "UI_resources.h"
+#include "UI_view2d.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "spreadsheet_intern.hh"
+
+static SpaceLink *spreadsheet_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
+{
+ SpaceSpreadsheet *spreadsheet_space = (SpaceSpreadsheet *)MEM_callocN(sizeof(SpaceSpreadsheet),
+ "spreadsheet space");
+ spreadsheet_space->spacetype = SPACE_SPREADSHEET;
+
+ {
+ /* header */
+ ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet header");
+ BLI_addtail(&spreadsheet_space->regionbase, region);
+ region->regiontype = RGN_TYPE_HEADER;
+ region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
+ }
+
+ {
+ /* main window */
+ ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), "spreadsheet main region");
+ BLI_addtail(&spreadsheet_space->regionbase, region);
+ region->regiontype = RGN_TYPE_WINDOW;
+ }
+
+ return (SpaceLink *)spreadsheet_space;
+}
+
+static void spreadsheet_free(SpaceLink *UNUSED(sl))
+{
+}
+
+static void spreadsheet_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(area))
+{
+}
+
+static SpaceLink *spreadsheet_duplicate(SpaceLink *sl)
+{
+ return (SpaceLink *)MEM_dupallocN(sl);
+}
+
+static void spreadsheet_keymap(wmKeyConfig *UNUSED(keyconf))
+{
+}
+
+static void spreadsheet_main_region_init(wmWindowManager *wm, ARegion *region)
+{
+ region->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM;
+ region->v2d.align = V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y;
+ region->v2d.keepzoom = V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT;
+ region->v2d.keeptot = V2D_KEEPTOT_STRICT;
+ region->v2d.minzoom = region->v2d.maxzoom = 1.0f;
+
+ UI_view2d_region_reinit(&region->v2d, V2D_COMMONVIEW_LIST, region->winx, region->winy);
+
+ wmKeyMap *keymap = WM_keymap_ensure(wm->defaultconf, "View2D Buttons List", 0, 0);
+ WM_event_add_keymap_handler(&region->handlers, keymap);
+}
+
+static void spreadsheet_main_region_draw(const bContext *UNUSED(C), ARegion *UNUSED(region))
+{
+ UI_ThemeClearColor(TH_BACK);
+}
+
+static void spreadsheet_main_region_listener(const wmRegionListenerParams *params)
+{
+ ARegion *region = params->region;
+ wmNotifier *wmn = params->notifier;
+
+ switch (wmn->category) {
+ case NC_SCENE: {
+ switch (wmn->data) {
+ case ND_MODE:
+ case ND_OB_ACTIVE: {
+ ED_region_tag_redraw(region);
+ break;
+ }
+ }
+ break;
+ }
+ case NC_OBJECT: {
+ ED_region_tag_redraw(region);
+ break;
+ }
+ case NC_SPACE: {
+ if (wmn->data == ND_SPACE_SPREADSHEET) {
+ ED_region_tag_redraw(region);
+ }
+ break;
+ }
+ case NC_GEOM: {
+ ED_region_tag_redraw(region);
+ break;
+ }
+ }
+}
+
+static void spreadsheet_header_region_init(wmWindowManager *UNUSED(wm), ARegion *region)
+{
+ ED_region_header_init(region);
+}
+
+static void spreadsheet_header_region_draw(const bContext *C, ARegion *region)
+{
+ ED_region_header(C, region);
+}
+
+static void spreadsheet_header_region_free(ARegion *UNUSED(region))
+{
+}
+
+static void spreadsheet_header_region_listener(const wmRegionListenerParams *params)
+{
+ ARegion *region = params->region;
+ wmNotifier *wmn = params->notifier;
+
+ switch (wmn->category) {
+ case NC_SCENE: {
+ switch (wmn->data) {
+ case ND_MODE:
+ case ND_OB_ACTIVE: {
+ ED_region_tag_redraw(region);
+ break;
+ }
+ }
+ break;
+ }
+ case NC_OBJECT: {
+ ED_region_tag_redraw(region);
+ break;
+ }
+ case NC_SPACE: {
+ if (wmn->data == ND_SPACE_SPREADSHEET) {
+ ED_region_tag_redraw(region);
+ }
+ break;
+ }
+ case NC_GEOM: {
+ ED_region_tag_redraw(region);
+ break;
+ }
+ }
+}
+
+void ED_spacetype_spreadsheet(void)
+{
+ SpaceType *st = (SpaceType *)MEM_callocN(sizeof(SpaceType), "spacetype spreadsheet");
+ ARegionType *art;
+
+ st->spaceid = SPACE_SPREADSHEET;
+ strncpy(st->name, "Spreadsheet", BKE_ST_MAXNAME);
+
+ st->create = spreadsheet_create;
+ st->free = spreadsheet_free;
+ st->init = spreadsheet_init;
+ st->duplicate = spreadsheet_duplicate;
+ st->operatortypes = spreadsheet_operatortypes;
+ st->keymap = spreadsheet_keymap;
+
+ /* regions: main window */
+ art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype spreadsheet region");
+ art->regionid = RGN_TYPE_WINDOW;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
+
+ art->init = spreadsheet_main_region_init;
+ art->draw = spreadsheet_main_region_draw;
+ art->listener = spreadsheet_main_region_listener;
+ BLI_addhead(&st->regiontypes, art);
+
+ /* regions: header */
+ art = (ARegionType *)MEM_callocN(sizeof(ARegionType), "spacetype spreadsheet header region");
+ art->regionid = RGN_TYPE_HEADER;
+ art->prefsizey = HEADERY;
+ art->keymapflag = 0;
+ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER;
+
+ art->init = spreadsheet_header_region_init;
+ art->draw = spreadsheet_header_region_draw;
+ art->free = spreadsheet_header_region_free;
+ art->listener = spreadsheet_header_region_listener;
+ BLI_addhead(&st->regiontypes, art);
+
+ BKE_spacetype_register(st);
+}
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_intern.hh b/source/blender/editors/space_spreadsheet/spreadsheet_intern.hh
new file mode 100644
index 00000000000..10a875e2c14
--- /dev/null
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_intern.hh
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+void spreadsheet_operatortypes(void);
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc b/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc
new file mode 100644
index 00000000000..770bd207e8d
--- /dev/null
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_ops.cc
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+#include "spreadsheet_intern.hh"
+
+void spreadsheet_operatortypes()
+{
+}