diff --git a/addons/resources_speadsheet_view/editor_view.gd b/addons/resources_speadsheet_view/editor_view.gd index 9284134..ebf0ae3 100644 --- a/addons/resources_speadsheet_view/editor_view.gd +++ b/addons/resources_speadsheet_view/editor_view.gd @@ -560,6 +560,18 @@ func _update_resources(update_rows : Array, update_cells : Array, update_column # Set cell values, but only when undoing/redoing (set_cell() normally fills these in) column_editors[update_column].set_value(update_cells[i], values[i]) + if column_types[update_column] == TYPE_COLOR: + for j in columns.size() - update_column: + if j != 0 and column_types[j + update_column] == TYPE_COLOR: + break + + column_editors[j + update_column].set_color( + update_cells[i].get_parent().get_child( + (_get_cell_row(update_cells[i]) + 1) * columns.size() + update_column + j + ), + values[i] + ) + func _get_edited_cells_resources() -> Array: var arr := edited_cells.duplicate() diff --git a/addons/resources_speadsheet_view/typed_cells/cell_editor_color.gd b/addons/resources_speadsheet_view/typed_cells/cell_editor_color.gd index 8de3dcb..4184ee7 100644 --- a/addons/resources_speadsheet_view/typed_cells/cell_editor_color.gd +++ b/addons/resources_speadsheet_view/typed_cells/cell_editor_color.gd @@ -3,6 +3,18 @@ extends CellEditor var _cached_color := Color.white +func create_cell() -> Control: + var node = load(CELL_SCENE_DIR + "basic.tscn").instance() + var color = ColorRect.new() + node.align = Label.ALIGN_RIGHT + node.rect_min_size.x = 56 + node.add_child(color) + color.name = "Color" + color.anchor_bottom = 1.0 + color.rect_size = Vector2(8, 0) + return node + + func can_edit_value(value, type, property_hint) -> bool: return type == TYPE_COLOR @@ -23,3 +35,8 @@ func set_value(node : Control, value): else: node.text = value.to_html(true) _cached_color = value + + +func set_color(node : Control, color : Color): + .set_color(node, color) + node.get_node("Color").color = color