Skip to content

Commit

Permalink
make active_button public
Browse files Browse the repository at this point in the history
  • Loading branch information
Variable-ind committed Nov 26, 2024
1 parent dcf2608 commit dc000f7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/Autoload/Palettes.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
34 changes: 17 additions & 17 deletions src/Autoload/Tools.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
7 changes: 7 additions & 0 deletions src/Classes/ImageExtended.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit dc000f7

Please sign in to comment.