mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Fix the palette swatch white border not being shown when selecting a color that exists in the active palette
This commit is contained in:
parent
0b96e3aa6f
commit
8c073dbe63
|
@ -88,16 +88,32 @@ func scroll_palette(origin: Vector2i) -> void:
|
|||
## Called when the color changes, either the left or the right, determined by [param mouse_button].
|
||||
## If current palette has [param target_color] as a [Color], then select it.
|
||||
func find_and_select_color(target_color: Color, mouse_button: int) -> void:
|
||||
var found_color := false
|
||||
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):
|
||||
if (
|
||||
target_color.is_equal_approx(swatches[color_ind].color)
|
||||
or target_color.to_html() == swatches[color_ind].color.to_html()
|
||||
):
|
||||
select_swatch(mouse_button, color_ind, old_index)
|
||||
match mouse_button:
|
||||
MOUSE_BUTTON_LEFT:
|
||||
Palettes.left_selected_color = color_ind
|
||||
MOUSE_BUTTON_RIGHT:
|
||||
Palettes.right_selected_color = color_ind
|
||||
found_color = true
|
||||
break
|
||||
if not found_color:
|
||||
# Unselect swatches when tools color is changed
|
||||
var swatch_to_unselect := -1
|
||||
if mouse_button == MOUSE_BUTTON_LEFT:
|
||||
swatch_to_unselect = Palettes.left_selected_color
|
||||
Palettes.left_selected_color = -1
|
||||
elif mouse_button == MOUSE_BUTTON_RIGHT:
|
||||
swatch_to_unselect = Palettes.right_selected_color
|
||||
Palettes.right_selected_color = -1
|
||||
|
||||
unselect_swatch(mouse_button, swatch_to_unselect)
|
||||
|
||||
|
||||
## Displays a left/right highlight over a swatch
|
||||
|
|
|
@ -56,7 +56,6 @@ func _ready() -> void:
|
|||
Palettes.palette_selected.connect(select_palette)
|
||||
Palettes.new_palette_created.connect(_new_palette_created)
|
||||
Palettes.new_palette_imported.connect(setup_palettes_selector)
|
||||
Tools.color_changed.connect(_color_changed)
|
||||
sort_button_popup.id_pressed.connect(sort_pressed)
|
||||
|
||||
setup_palettes_selector()
|
||||
|
@ -269,20 +268,6 @@ func _new_palette_created() -> void:
|
|||
redraw_current_palette()
|
||||
|
||||
|
||||
func _color_changed(_color: Color, button: int) -> void:
|
||||
if not hidden_color_picker.get_popup().visible and is_instance_valid(Palettes.current_palette):
|
||||
# Unselect swatches when tools color is changed
|
||||
var swatch_to_unselect := -1
|
||||
if button == MOUSE_BUTTON_LEFT:
|
||||
swatch_to_unselect = Palettes.left_selected_color
|
||||
Palettes.left_selected_color = -1
|
||||
elif button == MOUSE_BUTTON_RIGHT:
|
||||
swatch_to_unselect = Palettes.right_selected_color
|
||||
Palettes.right_selected_color = -1
|
||||
|
||||
palette_grid.unselect_swatch(button, swatch_to_unselect)
|
||||
|
||||
|
||||
func _on_edit_palette_dialog_exported(path := "") -> void:
|
||||
var image := Palettes.current_palette.convert_to_image()
|
||||
if OS.has_feature("web"):
|
||||
|
|
Loading…
Reference in a new issue