1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +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:
Variable 2022-09-12 04:03:14 +05:00 committed by GitHub
parent a6a1c36cc6
commit 4b4b0773ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -319,6 +319,8 @@ func assign_color(color: Color, button: int, change_alpha := true) -> void:
_slots[button].color = color
Global.config_cache.set_value(_slots[button].kname, "color", color)
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:

View file

@ -98,6 +98,19 @@ func clear_swatches() -> void:
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
func select_swatch(mouse_button: int, palette_index: int, old_palette_index: int) -> void:
var index = convert_palette_index_to_grid_index(palette_index)