Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix alpha slider always fallback to opaque #32

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ func _draw() -> void:
func _gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed():
if Time.get_unix_time_from_system() - _double_click_t < 0.5 and _first_click_coor.is_equal_approx(get_local_mouse_position()):
if Time.get_unix_time_from_system() - _double_click_t < 0.5 and _first_click_coor.is_equal_approx(event.position):
double_click.emit()
else:
(PixelPen.state.current_project as PixelPenProject).create_undo_palette("Change palette color", func ():
PixelPen.state.palette_changed.emit()
)
_double_click_t = Time.get_unix_time_from_system()
_first_click_coor = get_local_mouse_position()
_first_click_coor = event.position
_pressed = true
pick()
pick(event)

if _pressed and event is InputEventMouseMotion:
pick()
pick(event)
alpha_changed.emit(color.a)


func pick() -> void:
color.a = get_local_mouse_position().x / size.x
func pick(event: InputEvent) -> void:
color.a = event.position.x / size.x
color.a = clampf(color.a, 0.0, 1.0)
queue_redraw()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ func _on_double_click() -> void:


func _on_sv_slider_sv_changed(s: Variant, v: Variant) -> void:
color = Color.from_hsv(hue_slider.hue, s, v)
color = Color.from_hsv(hue_slider.hue, s, v, alpha_slider.color.a)
color_changed.emit(color)


func _on_hue_slider_hue_changed(hue: Variant) -> void:
color = Color.from_hsv(hue, sv_slider.saturation, sv_slider.value)
color = Color.from_hsv(hue, sv_slider.saturation, sv_slider.value, alpha_slider.color.a)
sv_slider.hue = hue
sv_slider.queue_redraw()
color_changed.emit(color)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ func _draw() -> void:
func _gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed():
if Time.get_unix_time_from_system() - _double_click_t < 0.5 and _first_click_coor.is_equal_approx(get_local_mouse_position()):
if Time.get_unix_time_from_system() - _double_click_t < 0.5 and _first_click_coor.is_equal_approx(event.position):
double_click.emit()
else:
(PixelPen.state.current_project as PixelPenProject).create_undo_palette("Change palette color", func ():
PixelPen.state.palette_changed.emit()
)
_double_click_t = Time.get_unix_time_from_system()
_first_click_coor = get_local_mouse_position()
_first_click_coor = event.position
_pressed = true
pick()
pick(event)

if _pressed and event is InputEventMouseMotion:
pick()
pick(event)
hue_changed.emit(hue)


func pick() -> void:
hue = get_local_mouse_position().x / size.x
func pick(event: InputEvent) -> void:
hue = event.position.x / size.x
hue = clampf(hue, 0.0, 1.0)
queue_redraw()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ func _draw() -> void:
func _gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed():
if Time.get_unix_time_from_system() - _double_click_t < 0.5 and _first_click_coor.is_equal_approx(get_local_mouse_position()):
if Time.get_unix_time_from_system() - _double_click_t < 0.5 and _first_click_coor.is_equal_approx(event.position):
double_click.emit()
else:
(PixelPen.state.current_project as PixelPenProject).create_undo_palette("Change palette color", func ():
PixelPen.state.palette_changed.emit()
)
_double_click_t = Time.get_unix_time_from_system()
_first_click_coor = get_local_mouse_position()
_first_click_coor = event.position
_pressed = true
pick()
pick(event)

if _pressed and event is InputEventMouseMotion:
pick()
pick(event)
sv_changed.emit(saturation, value)


func pick() -> void:
var coordinate = get_local_mouse_position() / size
func pick(event: InputEvent) -> void:
var coordinate = event.position / size
coordinate.x = clampf(coordinate.x, 0.0, 1.0)
coordinate.y = clampf(coordinate.y, 0.0, 1.0)
saturation = coordinate.x
Expand Down