Skip to content
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
14 changes: 7 additions & 7 deletions src/autoload/HandlerGUI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,11 @@ func _move_popup_under_rect_center(popup: Control, rect: Rect2, vp: Viewport) ->
popup.position = popup_clamp_pos(popup, popup_pos, vp)

# Should usually be the global position of the mouse.
func popup_under_pos(popup: Control, pos: Vector2, vp: Viewport) -> void:
func popup_under_position(popup: Control, position: Vector2, viewport: Viewport) -> void:
var top_popup := add_popup(popup)
var screen_transform := vp.get_screen_transform()
pos += screen_transform.get_origin() / screen_transform.get_scale()
top_popup.position = popup_clamp_pos(top_popup, pos + Vector2(1, 1), vp)
var screen_transform := viewport.get_screen_transform()
position += screen_transform.get_origin() / screen_transform.get_scale()
top_popup.position = popup_clamp_pos(top_popup, position + Vector2(1, 1), viewport)

# Should usually be the global rect of a control.
func popup_submenu_to_right_or_left_side(submenu: Control, source: Control) -> void:
Expand Down Expand Up @@ -390,12 +390,12 @@ func clear_submenu() -> void:


# Helper.
func popup_clamp_pos(popup: Control, attempt_pos: Vector2, vp: Viewport) -> Vector2:
func popup_clamp_pos(popup: Control, attempt_position: Vector2, vp: Viewport) -> Vector2:
var screen_transform := vp.get_screen_transform()
var vp_pos := screen_transform.get_origin() / screen_transform.get_scale()
for axis in 2:
attempt_pos[axis] = clampf(attempt_pos[axis], vp_pos[axis], vp_pos[axis] + vp.get_visible_rect().size[axis] - popup.size[axis])
return attempt_pos
attempt_position[axis] = clampf(attempt_position[axis], vp_pos[axis], vp_pos[axis] + vp.get_visible_rect().size[axis] - popup.size[axis])
return attempt_position


func _parse_popup_overlay_event(event: InputEvent) -> void:
Expand Down
89 changes: 44 additions & 45 deletions src/autoload/State.gd
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ signal hover_changed
signal selection_changed

# Locked scroll puts the object at a specific place on the screen, otherwise it's clamped.
signal requested_scroll_to_selection(xid: PackedInt32Array, inner_idx: int, locked: bool)
signal requested_scroll_to_selection(xid: PackedInt32Array, inner_index: int, locked: bool)

# The viewport listens for this signal to put you in handle-placing mode.
signal handle_added
Expand Down Expand Up @@ -193,12 +193,12 @@ func clear_proposed_drop_xid() -> void:


# Override the selected elements with a single new selected element.
# If inner_idx is given, this will be an inner selection.
func normal_select(xid: PackedInt32Array, inner_idx := -1, scroll := false) -> void:
# If inner_index is given, this will be an inner selection.
func normal_select(xid: PackedInt32Array, inner_index := -1, scroll := false) -> void:
if xid.is_empty():
return

if inner_idx == -1:
if inner_index == -1:
var old_selected_xids := selected_xids.duplicate()
if not semi_selected_xid.is_empty():
_clear_inner_selection_no_signal()
Expand All @@ -214,26 +214,26 @@ func normal_select(xid: PackedInt32Array, inner_idx := -1, scroll := false) -> v
xid = xid.duplicate()
_clear_selection_no_signal()

if semi_selected_xid == xid and inner_selections.size() == 1 and inner_selections[0] == inner_idx:
if semi_selected_xid == xid and inner_selections.size() == 1 and inner_selections[0] == inner_index:
return

semi_selected_xid = xid.duplicate()
inner_selection_pivot = inner_idx
inner_selections = [inner_idx]
inner_selection_pivot = inner_index
inner_selections = [inner_index]
if inner_selections == old_inner_selections and old_semi_selected_xid == xid:
return

selection_changed.emit()
if scroll:
requested_scroll_to_selection.emit(xid, inner_idx, false)
requested_scroll_to_selection.emit(xid, inner_index, false)

# If the element was selected, unselect it. If it was unselected, select it.
# If inner_idx is given, this will be an inner selection.
func ctrl_select(xid: PackedInt32Array, inner_idx := -1) -> void:
# If inner_index is given, this will be an inner selection.
func ctrl_select(xid: PackedInt32Array, inner_index := -1) -> void:
if xid.is_empty():
return

if inner_idx == -1:
if inner_index == -1:
_clear_inner_selection_no_signal()
var xid_idx := selected_xids.find(xid)
if xid_idx == -1:
Expand All @@ -245,14 +245,14 @@ func ctrl_select(xid: PackedInt32Array, inner_idx := -1) -> void:
selected_xids.remove_at(xid_idx)
else:
if semi_selected_xid != xid:
normal_select(xid, inner_idx)
normal_select(xid, inner_index)
else:
_clear_selection_no_signal()

var idx_idx := inner_selections.find(inner_idx)
var idx_idx := inner_selections.find(inner_index)
if idx_idx == -1:
inner_selection_pivot = inner_idx
inner_selections.append(inner_idx)
inner_selection_pivot = inner_index
inner_selections.append(inner_index)
else:
inner_selections.remove_at(idx_idx)
if inner_selections.is_empty():
Expand All @@ -261,20 +261,20 @@ func ctrl_select(xid: PackedInt32Array, inner_idx := -1) -> void:
selection_changed.emit()

# Select all elements between the element and the last selected element (pivot).
# Similarly for inner selections if inner_idx is given, but without tree logic.
func shift_select(xid: PackedInt32Array, inner_idx := -1) -> void:
# Similarly for inner selections if inner_index is given, but without tree logic.
func shift_select(xid: PackedInt32Array, inner_index := -1) -> void:
if xid.is_empty():
return

if inner_idx == -1:
if inner_index == -1:
if xid == selection_pivot_xid:
return

if selection_pivot_xid.is_empty():
if xid in selected_xids:
selection_pivot_xid = xid
else:
ctrl_select(xid, inner_idx)
ctrl_select(xid, inner_index)
return

var old_selected_xids := selected_xids.duplicate()
Expand Down Expand Up @@ -303,12 +303,12 @@ func shift_select(xid: PackedInt32Array, inner_idx := -1) -> void:

else:
if inner_selection_pivot == -1 or xid != semi_selected_xid:
normal_select(xid, inner_idx)
normal_select(xid, inner_index)
return

var old_inner_selections := inner_selections.duplicate()
var first_idx := mini(inner_selection_pivot, inner_idx)
var last_idx := maxi(inner_selection_pivot, inner_idx)
var first_idx := mini(inner_selection_pivot, inner_index)
var last_idx := maxi(inner_selection_pivot, inner_index)
for i in range(first_idx, last_idx + 1):
if not i in inner_selections:
inner_selections.append(i)
Expand Down Expand Up @@ -377,8 +377,8 @@ func clear_all_selections() -> void:


# Set the hovered element.
func set_hovered(xid: PackedInt32Array, inner_idx := -1) -> void:
if inner_idx == -1:
func set_hovered(xid: PackedInt32Array, inner_index := -1) -> void:
if inner_index == -1:
if hovered_xid != xid:
hovered_xid = xid.duplicate()
if not xid.is_empty():
Expand All @@ -388,24 +388,24 @@ func set_hovered(xid: PackedInt32Array, inner_idx := -1) -> void:
else:
if semi_hovered_xid != xid:
semi_hovered_xid = xid.duplicate()
inner_hovered = inner_idx
inner_hovered = inner_index
if not xid.is_empty():
hovered_xid.clear()
hover_changed.emit()
elif inner_hovered != inner_idx:
inner_hovered = inner_idx
elif inner_hovered != inner_index:
inner_hovered = inner_index
if not xid.is_empty():
hovered_xid.clear()
hover_changed.emit()

# If the element is hovered, make it not hovered.
func remove_hovered(xid: PackedInt32Array, inner_idx := -1) -> void:
if inner_idx == -1:
func remove_hovered(xid: PackedInt32Array, inner_index := -1) -> void:
if inner_index == -1:
if hovered_xid == xid:
hovered_xid.clear()
hover_changed.emit()
else:
if semi_hovered_xid == xid and inner_hovered == inner_idx:
if semi_hovered_xid == xid and inner_hovered == inner_index:
semi_hovered_xid.clear()
inner_hovered = -1
hover_changed.emit()
Expand All @@ -431,29 +431,29 @@ func clear_all_hovered() -> void:
hover_changed.emit()

# Returns whether the given element or inner editor is hovered.
func is_hovered(xid: PackedInt32Array, inner_idx := -1, propagate := false) -> bool:
func is_hovered(xid: PackedInt32Array, inner_index := -1, propagate := false) -> bool:
if propagate:
if XIDUtils.is_ancestor_or_self(hovered_xid, xid):
return true
if inner_idx == -1:
if inner_index == -1:
return false
return inner_hovered == inner_idx and semi_hovered_xid == xid
if inner_idx == -1:
return inner_hovered == inner_index and semi_hovered_xid == xid
if inner_index == -1:
return hovered_xid == xid
return inner_hovered == inner_idx and semi_hovered_xid == xid
return inner_hovered == inner_index and semi_hovered_xid == xid

# Returns whether the given element or inner editor is selected.
func is_selected(xid: PackedInt32Array, inner_idx := -1, propagate := false) -> bool:
func is_selected(xid: PackedInt32Array, inner_index := -1, propagate := false) -> bool:
if propagate:
for selected_xid in selected_xids:
if XIDUtils.is_ancestor_or_self(selected_xid, xid):
return true
if inner_idx == -1:
if inner_index == -1:
return false
return semi_selected_xid == xid and inner_idx in inner_selections
if inner_idx == -1:
return semi_selected_xid == xid and inner_index in inner_selections
if inner_index == -1:
return xid in selected_xids
return semi_selected_xid == xid and inner_idx in inner_selections
return semi_selected_xid == xid and inner_index in inner_selections


# Returns whether the selection represents one or more subpaths of a path.
Expand Down Expand Up @@ -645,20 +645,19 @@ func _move_selected(down: bool) -> void:
if start in inner_selections:
selected.append(i)

var order := range(pathdata.subpath_start_indices.size())
var order: Array[int] = range(pathdata.subpath_start_indices.size())
if down:
for i in range(selected.size() - 1, -1, -1):
var subpath := selected[i]
var pos := order.find(subpath)
var pos := order.find(selected[i])
if pos < order.size() - 1 and not selected.has(order[pos + 1]):
var tmp = order[pos]
var tmp := order[pos]
order[pos] = order[pos + 1]
order[pos + 1] = tmp
else:
for subpath in selected:
var pos := order.find(subpath)
if pos > 0 and not selected.has(order[pos - 1]):
var tmp = order[pos]
var tmp := order[pos]
order[pos] = order[pos - 1]
order[pos - 1] = tmp

Expand Down
48 changes: 24 additions & 24 deletions src/config_classes/Palette.gd
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ func get_colors() -> PackedStringArray:
func get_color_names() -> PackedStringArray:
return _color_names

func get_color(idx: int) -> String:
return _colors[idx]
func get_color(index: int) -> String:
return _colors[index]

func get_color_name(idx: int) -> String:
return _color_names[idx]
func get_color_name(index: int) -> String:
return _color_names[index]

func get_color_count() -> int:
return _colors.size()
Expand All @@ -62,9 +62,9 @@ func setup(new_colors: PackedStringArray, new_color_names: PackedStringArray) ->
_validate()
emit_changed()

func insert_color(idx: int, color: String, color_name: String) -> void:
_colors.insert(idx, color)
_color_names.insert(idx, color_name)
func insert_color(index: int, color: String, color_name: String) -> void:
_colors.insert(index, color)
_color_names.insert(index, color_name)
emit_changed()
layout_changed.emit()

Expand All @@ -74,34 +74,34 @@ func add_new_color() -> void:
emit_changed()
layout_changed.emit()

func remove_color(idx: int) -> void:
_colors.remove_at(idx)
_color_names.remove_at(idx)
func remove_color(index: int) -> void:
_colors.remove_at(index)
_color_names.remove_at(index)
emit_changed()
layout_changed.emit()

func move_color(old_idx: int, new_idx: int) -> void:
if old_idx == new_idx:
func move_color(old_index: int, new_index: int) -> void:
if old_index == new_index:
return

if old_idx < new_idx:
new_idx -= 1
if old_index < new_index:
new_index -= 1

var old_color := _colors[old_idx]
_colors.remove_at(old_idx)
_colors.insert(new_idx, old_color)
var old_name := _color_names[old_idx]
_color_names.remove_at(old_idx)
_color_names.insert(new_idx, old_name)
var old_color := _colors[old_index]
_colors.remove_at(old_index)
_colors.insert(new_index, old_color)
var old_name := _color_names[old_index]
_color_names.remove_at(old_index)
_color_names.insert(new_index, old_name)
emit_changed()
layout_changed.emit()

func modify_color(idx: int, new_color: String) -> void:
_colors[idx] = new_color
func modify_color(index: int, new_color: String) -> void:
_colors[index] = new_color
emit_changed()

func modify_color_name(idx: int, new_color_name: String) -> void:
_color_names[idx] = new_color_name
func modify_color_name(index: int, new_color_name: String) -> void:
_color_names[index] = new_color_name
emit_changed()

func apply_preset(new_preset: Preset) -> void:
Expand Down
Loading