mirror of
https://github.com/Relintai/godot-resources-as-sheets-plugin.git
synced 2024-11-10 10:12:08 +01:00
Improve color cell editing
This commit is contained in:
parent
9e83296a51
commit
48bfd7ebd3
@ -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()
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user