1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-12 16:53:07 +00:00

make active_button public

This commit is contained in:
Variable 2024-11-26 16:13:14 +05:00
parent dcf26084df
commit dc000f7267
3 changed files with 24 additions and 18 deletions

View file

@ -305,7 +305,6 @@ func current_palette_select_color(mouse_button: int, index: int) -> void:
Tools.assign_color(color, mouse_button)
func _select_color(mouse_button: int, index: int) -> void:
match mouse_button:
MOUSE_BUTTON_LEFT:

View file

@ -12,6 +12,7 @@ enum Dynamics { NONE, PRESSURE, VELOCITY }
const XY_LINE := Vector2(-0.707107, 0.707107)
const X_MINUS_Y_LINE := Vector2(0.707107, 0.707107)
var active_button := -1
var picking_color_for := MOUSE_BUTTON_LEFT
var horizontal_mirror := false
var vertical_mirror := false
@ -238,7 +239,6 @@ var _right_tools_per_layer_type := {
Global.LayerTypes.THREE_D: "Pan",
}
var _tool_buttons: Node
var _active_button := -1
var _last_position := Vector2i(Vector2.INF)
@ -627,32 +627,32 @@ func handle_draw(position: Vector2i, event: InputEvent) -> void:
change_layer_automatically(draw_pos)
return
if event.is_action_pressed(&"activate_left_tool") and _active_button == -1 and not pen_inverted:
_active_button = MOUSE_BUTTON_LEFT
_slots[_active_button].tool_node.draw_start(draw_pos)
elif event.is_action_released(&"activate_left_tool") and _active_button == MOUSE_BUTTON_LEFT:
_slots[_active_button].tool_node.draw_end(draw_pos)
_active_button = -1
if event.is_action_pressed(&"activate_left_tool") and active_button == -1 and not pen_inverted:
active_button = MOUSE_BUTTON_LEFT
_slots[active_button].tool_node.draw_start(draw_pos)
elif event.is_action_released(&"activate_left_tool") and active_button == MOUSE_BUTTON_LEFT:
_slots[active_button].tool_node.draw_end(draw_pos)
active_button = -1
elif (
(
event.is_action_pressed(&"activate_right_tool")
and _active_button == -1
and active_button == -1
and not pen_inverted
)
or (
event.is_action_pressed(&"activate_left_tool") and _active_button == -1 and pen_inverted
event.is_action_pressed(&"activate_left_tool") and active_button == -1 and pen_inverted
)
):
_active_button = MOUSE_BUTTON_RIGHT
_slots[_active_button].tool_node.draw_start(draw_pos)
active_button = MOUSE_BUTTON_RIGHT
_slots[active_button].tool_node.draw_start(draw_pos)
elif (
(event.is_action_released(&"activate_right_tool") and _active_button == MOUSE_BUTTON_RIGHT)
(event.is_action_released(&"activate_right_tool") and active_button == MOUSE_BUTTON_RIGHT)
or (
event.is_action_released(&"activate_left_tool") and _active_button == MOUSE_BUTTON_RIGHT
event.is_action_released(&"activate_left_tool") and active_button == MOUSE_BUTTON_RIGHT
)
):
_slots[_active_button].tool_node.draw_end(draw_pos)
_active_button = -1
_slots[active_button].tool_node.draw_end(draw_pos)
active_button = -1
if event is InputEventMouseMotion:
pen_pressure = event.pressure
@ -683,8 +683,8 @@ func handle_draw(position: Vector2i, event: InputEvent) -> void:
_last_position = position
_slots[MOUSE_BUTTON_LEFT].tool_node.cursor_move(position)
_slots[MOUSE_BUTTON_RIGHT].tool_node.cursor_move(position)
if _active_button != -1:
_slots[_active_button].tool_node.draw_move(draw_pos)
if active_button != -1:
_slots[active_button].tool_node.draw_move(draw_pos)
var project := Global.current_project
var text := "[%s×%s]" % [project.size.x, project.size.y]

View file

@ -142,6 +142,13 @@ func set_pixelv_custom(point: Vector2i, color: Color) -> void:
if not color.is_equal_approx(TRANSPARENT):
if palette.has(color):
color_index = palette.find(color)
## If the color selected in the palette is the same then it should take prioity.
#var selected_index = Palettes.current_palette_get_selected_color_index(
#Tools.active_button
#)
#if selected_index != -1:
#if Palettes.current_palette_get_color(selected_index) == color:
#color_index = selected_index
else: # Find the most similar color
var smaller_distance := color_distance(color, palette[0])
for i in palette.size():