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:
Diffstat (limited to 'source/blender/editors/space_spreadsheet/spreadsheet_layout.cc')
-rw-r--r--source/blender/editors/space_spreadsheet/spreadsheet_layout.cc42
1 files changed, 42 insertions, 0 deletions
diff --git a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc
index bca80cff773..f1ca65817f6 100644
--- a/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc
+++ b/source/blender/editors/space_spreadsheet/spreadsheet_layout.cc
@@ -161,6 +161,18 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer {
nullptr);
UI_but_drawflag_disable(but, UI_BUT_ICON_LEFT);
}
+ else if (cell_value.value_float2.has_value()) {
+ const float2 value = *cell_value.value_float2;
+ this->draw_float_vector(params, Span(&value.x, 2));
+ }
+ else if (cell_value.value_float3.has_value()) {
+ const float3 value = *cell_value.value_float3;
+ this->draw_float_vector(params, Span(&value.x, 3));
+ }
+ else if (cell_value.value_color.has_value()) {
+ const Color4f value = *cell_value.value_color;
+ this->draw_float_vector(params, Span(&value.r, 4));
+ }
else if (cell_value.value_object.has_value()) {
const ObjectCellValue value = *cell_value.value_object;
uiDefIconTextBut(params.block,
@@ -199,6 +211,36 @@ class SpreadsheetLayoutDrawer : public SpreadsheetDrawer {
}
}
+ void draw_float_vector(const CellDrawParams &params, const Span<float> values) const
+ {
+ BLI_assert(!values.is_empty());
+ const float segment_width = (float)params.width / values.size();
+ for (const int i : values.index_range()) {
+ std::stringstream ss;
+ const float value = values[i];
+ ss << std::fixed << std::setprecision(3) << value;
+ const std::string value_str = ss.str();
+ uiBut *but = uiDefIconTextBut(params.block,
+ UI_BTYPE_LABEL,
+ 0,
+ ICON_NONE,
+ value_str.c_str(),
+ params.xmin + i * segment_width,
+ params.ymin,
+ segment_width,
+ params.height,
+ nullptr,
+ 0,
+ 0,
+ 0,
+ 0,
+ nullptr);
+ /* Right-align Floats. */
+ UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT);
+ UI_but_drawflag_enable(but, UI_BUT_TEXT_RIGHT);
+ }
+ }
+
int column_width(int column_index) const final
{
return spreadsheet_layout_.columns[column_index].width;