[Bf-blender-cvs] [81d4e4d35e3] temp-spreadsheet-editor: split spreadsheet editor code into multiple files
Jacques Lucke
noreply at git.blender.org
Thu Feb 25 17:22:26 CET 2021
Commit: 81d4e4d35e3330b4735994649e6625937650192e
Author: Jacques Lucke
Date: Thu Feb 25 17:20:49 2021 +0100
Branches: temp-spreadsheet-editor
https://developer.blender.org/rB81d4e4d35e3330b4735994649e6625937650192e
split spreadsheet editor code into multiple files
===================================================================
M source/blender/editors/space_spreadsheet/CMakeLists.txt
M source/blender/editors/space_spreadsheet/space_spreadsheet.cc
A source/blender/editors/space_spreadsheet/spreadsheet_draw.cc
A source/blender/editors/space_spreadsheet/spreadsheet_draw.hh
A source/blender/editors/space_spreadsheet/spreadsheet_drawers.cc
A source/blender/editors/space_spreadsheet/spreadsheet_drawers.hh
A source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.cc
A source/blender/editors/space_spreadsheet/spreadsheet_from_geometry.hh
===================================================================
diff --git a/source/blender/editors/space_spreadsheet/CMakeLists.txt b/source/blender/editors/space_spreadsheet/CMakeLists.txt
index 76c912ad02a..f8485c5da2e 100644
--- a/source/blender/editors/space_spreadsheet/CMakeLists.txt
+++ b/source/blender/editors/space_spreadsheet/CMakeLists.txt
@@ -20,6 +20,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenfont
+ ../../bmesh
../../depsgraph
../../functions
../../gpu
@@ -32,8 +33,14 @@ set(INC
set(SRC
space_spreadsheet.cc
+ spreadsheet_draw.cc
+ spreadsheet_drawers.cc
+ spreadsheet_from_geometry.cc
spreadsheet_ops.cc
+ spreadsheet_draw.hh
+ spreadsheet_drawers.hh
+ spreadsheet_from_geometry.hh
spreadsheet_intern.hh
)
diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
index 1e8b3ab1ded..769fcb30800 100644
--- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
+++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
@@ -15,16 +15,13 @@
*/
#include <cstring>
-#include <iomanip>
-#include <sstream>
#include "BLI_index_range.hh"
#include "BLI_listbase.h"
-#include "BLI_rect.h"
#include "BLI_resource_collector.hh"
-#include "BLI_utildefines.h"
-#include "BKE_geometry_set.hh"
+#include "BKE_mesh_wrapper.h"
+#include "BKE_modifier.h"
#include "BKE_screen.h"
#include "ED_screen.h"
@@ -48,26 +45,15 @@
#include "WM_types.h"
-#include "GPU_immediate.h"
-
#include "BLF_api.h"
+#include "spreadsheet_from_geometry.hh"
#include "spreadsheet_intern.hh"
-using blender::float3;
using blender::IndexRange;
-using blender::MutableSpan;
using blender::ResourceCollector;
-using blender::Set;
-using blender::Span;
-using blender::StringRef;
-using blender::StringRefNull;
-using blender::Vector;
-using blender::bke::ReadAttribute;
-using blender::bke::ReadAttributePtr;
-using blender::fn::CPPType;
-using blender::fn::GMutableSpan;
-using blender::fn::GSpan;
+
+using namespace blender::ed::spreadsheet;
static SpaceLink *spreadsheet_create(const ScrArea *UNUSED(area), const Scene *UNUSED(scene))
{
@@ -121,366 +107,6 @@ static void spreadsheet_main_region_init(wmWindowManager *UNUSED(wm), ARegion *r
UI_view2d_region_reinit(®ion->v2d, V2D_COMMONVIEW_LIST, region->winx, region->winy);
}
-class ColumnHeaderDrawer {
- public:
- virtual ~ColumnHeaderDrawer() = default;
- virtual void draw_header(uiBlock *block, const rcti &rect) const = 0;
-};
-
-struct CellDrawParams {
- uiBlock *block;
- int xmin, ymin;
- int width, height;
- int index;
-};
-
-class CellDrawer {
- public:
- virtual ~CellDrawer() = default;
- virtual void draw_cell(const CellDrawParams ¶ms) const = 0;
-};
-
-struct SpreadsheetColumnLayout {
- int width;
- const ColumnHeaderDrawer *header_drawer = nullptr;
- const CellDrawer *cell_drawer = nullptr;
-};
-
-struct SpreadsheetLayout {
- int index_column_width;
- int title_row_height;
- int row_height;
- Vector<SpreadsheetColumnLayout> columns;
-};
-
-class TextColumnHeaderDrawer final : public ColumnHeaderDrawer {
- private:
- std::string text_;
-
- public:
- TextColumnHeaderDrawer(std::string text) : text_(std::move(text))
- {
- }
-
- void draw_header(uiBlock *block, const rcti &rect) const final
- {
- uiBut *but = uiDefIconTextBut(block,
- UI_BTYPE_LABEL,
- 0,
- ICON_NONE,
- text_.c_str(),
- rect.xmin,
- rect.ymin,
- BLI_rcti_size_x(&rect),
- BLI_rcti_size_y(&rect),
- nullptr,
- 0,
- 0,
- 0,
- 0,
- nullptr);
- UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT);
- UI_but_drawflag_disable(but, UI_BUT_TEXT_RIGHT);
- }
-};
-
-class ConstantTextCellDrawer final : public CellDrawer {
- private:
- std::string text_;
-
- public:
- ConstantTextCellDrawer(std::string text) : text_(std::move(text))
- {
- }
-
- void draw_cell(const CellDrawParams ¶ms) const final
- {
- uiDefIconTextBut(params.block,
- UI_BTYPE_LABEL,
- 0,
- ICON_NONE,
- text_.c_str(),
- params.xmin,
- params.ymin,
- params.width,
- params.height,
- nullptr,
- 0,
- 0,
- 0,
- 0,
- nullptr);
- }
-};
-
-static void draw_index_column_background(const uint pos,
- const ARegion *region,
- const SpreadsheetLayout &spreadsheet_layout)
-{
- immUniformThemeColorShade(TH_BACK, 11);
- immRecti(pos,
- 0,
- region->winy - spreadsheet_layout.title_row_height,
- spreadsheet_layout.index_column_width,
- 0);
-}
-
-static void draw_alternating_row_overlay(const uint pos,
- const int scroll_offset_y,
- const ARegion *region,
- const SpreadsheetLayout &spreadsheet_layout)
-{
- immUniformThemeColor(TH_ROW_ALTERNATE);
- GPU_blend(GPU_BLEND_ALPHA);
- const int row_pair_height = spreadsheet_layout.row_height * 2;
- const int row_top_y = region->winy - spreadsheet_layout.title_row_height -
- scroll_offset_y % row_pair_height;
- for (const int i : IndexRange(region->winy / row_pair_height + 1)) {
- int x_left = 0;
- int x_right = region->winx;
- int y_top = row_top_y - i * row_pair_height - spreadsheet_layout.row_height;
- int y_bottom = y_top - spreadsheet_layout.row_height;
- y_top = std::min(y_top, region->winy - spreadsheet_layout.title_row_height);
- y_bottom = std::min(y_bottom, region->winy - spreadsheet_layout.title_row_height);
- immRecti(pos, x_left, y_top, x_right, y_bottom);
- }
- GPU_blend(GPU_BLEND_NONE);
-}
-
-static void draw_title_row_background(const uint pos,
- const ARegion *region,
- const SpreadsheetLayout &spreadsheet_layout)
-{
- immUniformThemeColorShade(TH_BACK, 11);
- immRecti(pos, 0, region->winy, region->winx, region->winy - spreadsheet_layout.title_row_height);
-}
-
-static void draw_separator_lines(const uint pos,
- const int scroll_offset_x,
- const ARegion *region,
- const SpreadsheetLayout &spreadsheet_layout)
-{
- immUniformThemeColorShade(TH_BACK, -11);
-
- immBeginAtMost(GPU_PRIM_LINES, spreadsheet_layout.columns.size() * 2 + 4);
-
- /* Index column line. */
- immVertex2i(pos, spreadsheet_layout.index_column_width, region->winy);
- immVertex2i(pos, spreadsheet_layout.index_column_width, 0);
-
- /* Title row line. */
- immVertex2i(pos, 0, region->winy - spreadsheet_layout.title_row_height);
- immVertex2i(pos, region->winx, region->winy - spreadsheet_layout.title_row_height);
-
- /* Column separator lines. */
- int line_x = spreadsheet_layout.index_column_width - scroll_offset_x;
- for (const int i : spreadsheet_layout.columns.index_range()) {
- const SpreadsheetColumnLayout &column = spreadsheet_layout.columns[i];
- line_x += column.width;
- if (line_x >= spreadsheet_layout.index_column_width) {
- immVertex2i(pos, line_x, region->winy);
- immVertex2i(pos, line_x, 0);
- }
- }
- immEnd();
-}
-
-static void get_visible_rows(const SpreadsheetLayout &spreadsheet_layout,
- const ARegion *region,
- const int scroll_offset_y,
- int *r_first_row,
- int *r_max_visible_rows)
-{
- *r_first_row = -scroll_offset_y / spreadsheet_layout.row_height;
- *r_max_visible_rows = region->winy / spreadsheet_layout.row_height + 1;
-}
-
-static void draw_row_indices(const int scroll_offset_y,
- const Span<int64_t> row_indices,
- const bContext *C,
- ARegion *region,
- const SpreadsheetLayout &spreadsheet_layout)
-{
- GPU_scissor_test(true);
- GPU_scissor(0,
- 0,
- spreadsheet_layout.index_column_width,
- region->winy - spreadsheet_layout.title_row_height);
-
- uiBlock *indices_block = UI_block_begin(C, region, __func__, UI_EMBOSS_NONE);
- int first_row, max_visible_rows;
- get_visible_rows(spreadsheet_layout, region, scroll_offset_y, &first_row, &max_visible_rows);
- for (const int i : IndexRange(first_row, max_visible_rows)) {
- if (i >= row_indices.size()) {
- break;
- }
- const int index = row_indices[i];
- const std::string index_str = std::to_string(index);
- const int x = 0;
- const int y = region->winy - spreadsheet_layout.title_row_height -
- (i + 1) * spreadsheet_layout.row_height - scroll_offset_y;
- const int width = spreadsheet_layout.index_column_width;
- const int height = spreadsheet_layout.row_height;
- uiBut *but = uiDefIconTextBut(indices_block,
- UI_BTYPE_LABEL,
- 0,
- ICON_NONE,
- index_str.c_str(),
- x,
- y,
- width,
- height,
- nullptr,
- 0,
- 0,
- 0,
- 0,
- nullptr);
- UI_but_drawflag_enable(but, UI_BUT_TEXT_RIGHT);
- UI_but_drawf
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list