[Bf-blender-cvs] [18d99cd5fb6] temp-spreadsheet-editor: draw bool attributes
Jacques Lucke
noreply at git.blender.org
Thu Feb 25 13:33:58 CET 2021
Commit: 18d99cd5fb6be162c88c512c89a37dce7b5663a6
Author: Jacques Lucke
Date: Thu Feb 25 13:06:33 2021 +0100
Branches: temp-spreadsheet-editor
https://developer.blender.org/rB18d99cd5fb6be162c88c512c89a37dce7b5663a6
draw bool attributes
===================================================================
M source/blender/editors/space_spreadsheet/space_spreadsheet.cc
===================================================================
diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
index e388a20c5da..8bd3d98d0c4 100644
--- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
+++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
@@ -549,6 +549,37 @@ template<typename GetValueF> class IntCellDrawer : public CellDrawer {
}
};
+template<typename GetValueF> class BoolCellDrawer : public CellDrawer {
+ private:
+ const GetValueF get_value_;
+
+ public:
+ BoolCellDrawer(GetValueF get_value) : get_value_(std::move(get_value))
+ {
+ }
+
+ void draw_cell(const CellDrawParams ¶ms) const final
+ {
+ const bool value = get_value_(params.index);
+ const int icon = value ? ICON_CHECKBOX_HLT : ICON_CHECKBOX_DEHLT;
+ uiDefIconTextBut(params.block,
+ UI_BTYPE_LABEL,
+ 0,
+ icon,
+ "",
+ params.xmin,
+ params.ymin,
+ params.width,
+ params.height,
+ nullptr,
+ 0,
+ 0,
+ 0,
+ 0,
+ nullptr);
+ }
+};
+
static void gather_spreadsheet_data(const bContext *C,
SpreadsheetLayout &spreadsheet_layout,
ResourceCollector &resources,
@@ -674,6 +705,22 @@ static void gather_spreadsheet_data(const bContext *C,
spreadsheet_layout.columns.append({100, &header_drawer, &cell_drawer});
break;
}
+ case CD_PROP_BOOL: {
+ ColumnHeaderDrawer &header_drawer = resources.construct<TextColumnHeaderDrawer>(
+ "attribute header drawer", attribute_name);
+
+ auto get_value = [attribute](int index) {
+ bool value;
+ attribute->get(index, &value);
+ return value;
+ };
+
+ CellDrawer &cell_drawer = resources.construct<BoolCellDrawer<decltype(get_value)>>(
+ "bool cell drawer", get_value);
+
+ spreadsheet_layout.columns.append({100, &header_drawer, &cell_drawer});
+ break;
+ }
default:
break;
}
More information about the Bf-blender-cvs
mailing list