mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-13 01:03:07 +00:00
Fixed more than one swatch selected if there is the same color available in an earlier swatch
This commit is contained in:
parent
adbeec12f8
commit
b8c04e83c9
|
@ -756,7 +756,7 @@ func _ready() -> void:
|
||||||
Global.use_native_file_dialogs = true
|
Global.use_native_file_dialogs = true
|
||||||
await get_tree().process_frame
|
await get_tree().process_frame
|
||||||
project_switched.emit()
|
project_switched.emit()
|
||||||
canvas.color_index.enabled = show_pixel_indices # Initialize color index preview
|
canvas.color_index.enabled = show_pixel_indices # Initialize color index preview
|
||||||
|
|
||||||
|
|
||||||
func update_grids(grids_data: Dictionary):
|
func update_grids(grids_data: Dictionary):
|
||||||
|
|
|
@ -296,13 +296,14 @@ func current_palette_select_color(mouse_button: int, index: int) -> void:
|
||||||
if color == null:
|
if color == null:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
_select_color(mouse_button, index)
|
||||||
|
|
||||||
match mouse_button:
|
match mouse_button:
|
||||||
MOUSE_BUTTON_LEFT:
|
MOUSE_BUTTON_LEFT:
|
||||||
Tools.assign_color(color, mouse_button)
|
Tools.assign_color(color, mouse_button)
|
||||||
MOUSE_BUTTON_RIGHT:
|
MOUSE_BUTTON_RIGHT:
|
||||||
Tools.assign_color(color, mouse_button)
|
Tools.assign_color(color, mouse_button)
|
||||||
|
|
||||||
_select_color(mouse_button, index)
|
|
||||||
|
|
||||||
|
|
||||||
func _select_color(mouse_button: int, index: int) -> void:
|
func _select_color(mouse_button: int, index: int) -> void:
|
||||||
|
|
|
@ -82,17 +82,20 @@ func scroll_palette(origin: Vector2i) -> void:
|
||||||
|
|
||||||
## Called when the color changes, either the left or the right, determined by [param mouse_button].
|
## 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.
|
## If current palette has [param target_color] as a [Color], then select it.
|
||||||
|
## This is helpful when we select color indirectly (e.g through colorpicker)
|
||||||
func find_and_select_color(target_color: Color, mouse_button: int) -> void:
|
func find_and_select_color(target_color: Color, mouse_button: int) -> void:
|
||||||
if not is_instance_valid(current_palette):
|
if not is_instance_valid(current_palette):
|
||||||
return
|
return
|
||||||
var old_index := Palettes.current_palette_get_selected_color_index(mouse_button)
|
var selected_index := Palettes.current_palette_get_selected_color_index(mouse_button)
|
||||||
|
if get_swatch_color(selected_index) == target_color: # Color already selected
|
||||||
|
return
|
||||||
for color_ind in swatches.size():
|
for color_ind in swatches.size():
|
||||||
if (
|
if (
|
||||||
target_color.is_equal_approx(swatches[color_ind].color)
|
target_color.is_equal_approx(swatches[color_ind].color)
|
||||||
or target_color.to_html() == swatches[color_ind].color.to_html()
|
or target_color.to_html() == swatches[color_ind].color.to_html()
|
||||||
):
|
):
|
||||||
var index := convert_grid_index_to_palette_index(color_ind)
|
var index := convert_grid_index_to_palette_index(color_ind)
|
||||||
select_swatch(mouse_button, index, old_index)
|
select_swatch(mouse_button, index, selected_index)
|
||||||
match mouse_button:
|
match mouse_button:
|
||||||
MOUSE_BUTTON_LEFT:
|
MOUSE_BUTTON_LEFT:
|
||||||
Palettes.left_selected_color = index
|
Palettes.left_selected_color = index
|
||||||
|
|
Loading…
Reference in a new issue