mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +00:00
Highlight color in palette if it's selected in color slots (#730)
* select pallete color (if present) * find and select color * [skip ci] Update CHANGELOG.md Co-authored-by: Emmanouil Papadeas <manoschool@yahoo.gr> Co-authored-by: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com>
This commit is contained in:
parent
a6a1c36cc6
commit
4b4b0773ff
|
@ -319,6 +319,8 @@ func assign_color(color: Color, button: int, change_alpha := true) -> void:
|
||||||
_slots[button].color = color
|
_slots[button].color = color
|
||||||
Global.config_cache.set_value(_slots[button].kname, "color", color)
|
Global.config_cache.set_value(_slots[button].kname, "color", color)
|
||||||
emit_signal("color_changed", color, button)
|
emit_signal("color_changed", color, button)
|
||||||
|
# If current palette has that color then select that color
|
||||||
|
Global.palette_panel.palette_grid.find_and_select_color(button, color)
|
||||||
|
|
||||||
|
|
||||||
func get_assigned_color(button: int) -> Color:
|
func get_assigned_color(button: int) -> Color:
|
||||||
|
|
|
@ -98,6 +98,19 @@ func clear_swatches() -> void:
|
||||||
swatch.queue_free()
|
swatch.queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func find_and_select_color(mouse_button: int, target_color: Color) -> void:
|
||||||
|
var old_index = Palettes.current_palette_get_selected_color_index(mouse_button)
|
||||||
|
for color_ind in swatches.size():
|
||||||
|
if target_color.is_equal_approx(swatches[color_ind].color):
|
||||||
|
select_swatch(mouse_button, color_ind, old_index)
|
||||||
|
match mouse_button:
|
||||||
|
BUTTON_LEFT:
|
||||||
|
Palettes.left_selected_color = color_ind
|
||||||
|
BUTTON_RIGHT:
|
||||||
|
Palettes.right_selected_color = color_ind
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
# Displays a left/right highlight over a swatch
|
# Displays a left/right highlight over a swatch
|
||||||
func select_swatch(mouse_button: int, palette_index: int, old_palette_index: int) -> void:
|
func select_swatch(mouse_button: int, palette_index: int, old_palette_index: int) -> void:
|
||||||
var index = convert_palette_index_to_grid_index(palette_index)
|
var index = convert_palette_index_to_grid_index(palette_index)
|
||||||
|
|
Loading…
Reference in a new issue