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
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')
-rw-r--r--source/blender/editors/CMakeLists.txt1
-rw-r--r--source/blender/editors/include/ED_space_api.h1
-rw-r--r--source/blender/editors/interface/interface_template_search_menu.c1
-rw-r--r--source/blender/editors/interface/resources.c3
-rw-r--r--source/blender/editors/space_api/CMakeLists.txt1
-rw-r--r--source/blender/editors/space_api/spacetypes.c1
-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
10 files changed, 308 insertions, 0 deletions
diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt
index a2ae350ce4b..092198cea86 100644
--- a/source/blender/editors/CMakeLists.txt
+++ b/source/blender/editors/CMakeLists.txt
@@ -53,6 +53,7 @@ if(WITH_BLENDER)
add_subdirectory(space_outliner)
add_subdirectory(space_script)
add_subdirectory(space_sequencer)
+ add_subdirectory(space_spreadsheet)
add_subdirectory(space_statusbar)
add_subdirectory(space_text)
add_subdirectory(space_topbar)
diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h
index fc474ea464d..1a3aa7e5496 100644
--- a/source/blender/editors/include/ED_space_api.h
+++ b/source/blender/editors/include/ED_space_api.h
@@ -55,6 +55,7 @@ void ED_spacetype_userpref(void);
void ED_spacetype_clip(void);
void ED_spacetype_statusbar(void);
void ED_spacetype_topbar(void);
+void ED_spacetype_spreadsheet(void);
/* calls for instancing and freeing spacetype static data
* called in WM_init_exit */
diff --git a/source/blender/editors/interface/interface_template_search_menu.c b/source/blender/editors/interface/interface_template_search_menu.c
index e1f8f63dcbf..74668b2f3a3 100644
--- a/source/blender/editors/interface/interface_template_search_menu.c
+++ b/source/blender/editors/interface/interface_template_search_menu.c
@@ -642,6 +642,7 @@ static struct MenuSearch_Data *menu_items_from_ui_create(
SPACE_MENU_NOP(SPACE_SCRIPT);
SPACE_MENU_NOP(SPACE_STATUSBAR);
SPACE_MENU_NOP(SPACE_TOPBAR);
+ SPACE_MENU_NOP(SPACE_SPREADSHEET);
}
}
for (int i = 0; i < idname_array_len; i++) {
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 80e54f4f92f..afac254f542 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -160,6 +160,9 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
case SPACE_STATUSBAR:
ts = &btheme->space_statusbar;
break;
+ case SPACE_SPREADSHEET:
+ ts = &btheme->space_spreadsheet;
+ break;
default:
ts = &btheme->space_view3d;
break;
diff --git a/source/blender/editors/space_api/CMakeLists.txt b/source/blender/editors/space_api/CMakeLists.txt
index 573afb76f0e..85c07223f2d 100644
--- a/source/blender/editors/space_api/CMakeLists.txt
+++ b/source/blender/editors/space_api/CMakeLists.txt
@@ -50,6 +50,7 @@ set(LIB
bf_editor_space_outliner
bf_editor_space_script
bf_editor_space_sequencer
+ bf_editor_space_spreadsheet
bf_editor_space_statusbar
bf_editor_space_text
bf_editor_space_topbar
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index ff05fb3bad6..adb824b8934 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -95,6 +95,7 @@ void ED_spacetypes_init(void)
ED_spacetype_clip();
ED_spacetype_statusbar();
ED_spacetype_topbar();
+ ED_spacetype_spreadsheet();
/* Register operator types for screen and all spaces. */
ED_operatortypes_userpref();
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()
+{
+}