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
8 changes: 4 additions & 4 deletions src/autoload/HandlerGUI.gd
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ func register_focus_sequence(focus_master: Control, sequence: Array[Control], fo
for control in sequence:
control.visibility_changed.connect(
func() -> void:
if not control.visible and control.has_focus():
if not control.is_visible_in_tree() and control.has_focus():
for control2 in sequence:
if control2.visible:
if is_instance_valid(control2) and control2.is_visible_in_tree():
control2.grab_focus(true)
return
)
Expand All @@ -140,7 +140,7 @@ func _find_first_focusable_control_in_sequence(sequence: Array[Control]) -> Cont
for control in sequence:
if not is_instance_valid(control):
continue
if control.visible and control.focus_mode != Control.FocusMode.FOCUS_NONE:
if control.is_visible_in_tree() and control.focus_mode != Control.FocusMode.FOCUS_NONE:
return control
if control in focus_sequences:
var nested := _find_first_focusable_control_in_sequence(focus_sequences[control])
Expand Down Expand Up @@ -480,7 +480,7 @@ func _react_to_action(event: InputEvent) -> void:

for behavior in ShortcutsRegistration.BEHAVIOR_PRIORITY:
for node in shortcut_registrations:
if node is CanvasItem and not node.visible:
if node is CanvasItem and not node.is_visible_in_tree():
continue

var registrations := shortcut_registrations[node]
Expand Down
4 changes: 3 additions & 1 deletion src/autoload/State.gd
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ func select_all() -> void:
_clear_inner_selection_no_signal()
var xnode_list: Array[XNode] = root_element.get_all_xnode_descendants()
var xid_list: Array = xnode_list.map(
func(xnode: XNode) -> PackedInt32Array: return xnode.xid)
func(xnode: XNode) -> PackedInt32Array:
return xnode.xid
)
# The order might not be the same, so ensure like this.
if XIDUtils.are_xid_lists_same(xid_list, selected_xids):
return
Expand Down
3 changes: 1 addition & 2 deletions src/config_classes/SaveData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,7 @@ const MAX_SELECTION_RECTANGLE_SPEED = 600.0
if is_nan(new_value):
new_value = get_setting_default("selection_rectangle_speed")
else:
new_value = clampf(new_value, -MAX_SELECTION_RECTANGLE_SPEED,
MAX_SELECTION_RECTANGLE_SPEED)
new_value = clampf(new_value, -MAX_SELECTION_RECTANGLE_SPEED, MAX_SELECTION_RECTANGLE_SPEED)
# Main part
if selection_rectangle_speed != new_value:
selection_rectangle_speed = new_value
Expand Down
5 changes: 2 additions & 3 deletions src/data_classes/ElementBaseGradient.gd
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ func get_config_warnings() -> PackedStringArray:
# Different color from the initial one (which, even at offset 0, still always
# has effect on the stroke). Mark it for having the potential to begin an
# effective transition if the next stop offset is greater.
has_effective_transition = not (ColorParser.are_colors_same(
initial_color, stop_color) and initial_opacity == stop_opacity) and\
(initial_opacity != 0 or stop_opacity > 0)
has_effective_transition = not (ColorParser.are_colors_same(initial_color, stop_color) and\
initial_opacity == stop_opacity) and (initial_opacity != 0 or stop_opacity > 0)

if has_effective_transition and stop_offset > prev_offset:
break
Expand Down
12 changes: 6 additions & 6 deletions src/ui_parts/code_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func sync_theming() -> void:
# Set up the code edit.
code_edit.begin_bulk_theme_override()
const CONST_ARR_1: PackedStringArray = ["normal", "focus", "hover"]
for theme_type in CONST_ARR_1:
var stylebox := get_theme_stylebox(theme_type, "TextEdit").duplicate()
for theme_item in CONST_ARR_1:
var stylebox := get_theme_stylebox(theme_item, "TextEdit").duplicate()
stylebox.corner_radius_top_right = 0
stylebox.corner_radius_top_left = 0
stylebox.border_width_top = 2
Expand All @@ -65,18 +65,18 @@ func sync_theming() -> void:
stylebox.corner_radius_bottom_right = 0
stylebox.corner_radius_bottom_left = 0
stylebox.border_width_bottom = 1
code_edit.add_theme_stylebox_override(theme_type, stylebox)
code_edit.add_theme_stylebox_override(theme_item, stylebox)
code_edit.end_bulk_theme_override()
# Make it so the scrollbar doesn't overlap with the code editor's border.
var scrollbar := code_edit.get_v_scroll_bar()
scrollbar.begin_bulk_theme_override()
const CONST_ARR_2: PackedStringArray = ["grabber", "grabber_highlight", "grabber_pressed"]
for theme_type in CONST_ARR_2:
var stylebox := get_theme_stylebox(theme_type, "VScrollBar").duplicate()
for theme_item in CONST_ARR_2:
var stylebox := get_theme_stylebox(theme_item, "VScrollBar").duplicate()
# TODO No idea why I need to adjust it for the TextEdit, maybe a Godot issue.
stylebox.expand_margin_right = -2.0
stylebox.expand_margin_bottom = 2.0
scrollbar.add_theme_stylebox_override(theme_type, stylebox)
scrollbar.add_theme_stylebox_override(theme_item, stylebox)
var bg_stylebox := get_theme_stylebox("scroll", "VScrollBar").duplicate()
bg_stylebox.expand_margin_right = -2.0
bg_stylebox.expand_margin_bottom = 2.0
Expand Down
3 changes: 1 addition & 2 deletions src/ui_parts/element_container.gd
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ func _gui_input(event: InputEvent) -> void:
HandlerGUI.popup_under_pos(add_popup, vp.get_mouse_position(), vp)

func add_element(element_name: String, element_idx: int) -> void:
State.root_element.add_xnode(DB.element_with_setup(element_name, []),
PackedInt32Array([element_idx]))
State.root_element.add_xnode(DB.element_with_setup(element_name, []), PackedInt32Array([element_idx]))
State.save_svg()


Expand Down
12 changes: 5 additions & 7 deletions src/ui_parts/global_actions.gd
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ func _ready() -> void:
func sync_theming() -> void:
size_button.begin_bulk_theme_override()
const CONST_ARR: PackedStringArray = ["normal", "focus", "hover", "disabled"]
for theme_type in CONST_ARR:
size_button.remove_theme_stylebox_override(theme_type)
var stylebox := size_button.get_theme_stylebox(theme_type).duplicate()
for theme_item in CONST_ARR:
var stylebox := size_button.get_theme_stylebox(theme_item).duplicate()
stylebox.content_margin_bottom = 0.0
stylebox.content_margin_top = 0.0
size_button.add_theme_stylebox_override(theme_type, stylebox)
size_button.add_theme_stylebox_override(theme_item, stylebox)
size_button.end_bulk_theme_override()
update_size_button_colors()

Expand Down Expand Up @@ -97,9 +96,8 @@ func update_size_button() -> void:
func update_size_button_colors() -> void:
size_button.begin_bulk_theme_override()
const CONST_ARR: PackedStringArray = ["font_color", "font_hover_color", "font_focus_color", "font_pressed_color"]
for theme_type in CONST_ARR:
size_button.add_theme_color_override(theme_type,
Configs.savedata.basic_color_warning.lerp(ThemeUtils.max_contrast_color, 0.4))
for theme_item in CONST_ARR:
size_button.add_theme_color_override(theme_item, Configs.savedata.basic_color_warning.lerp(ThemeUtils.max_contrast_color, 0.4))
size_button.end_bulk_theme_override()

func _on_layout_button_pressed() -> void:
Expand Down
2 changes: 2 additions & 0 deletions src/ui_parts/good_file_dialog.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ layout_mode = 2
mouse_default_cursor_shape = 2
theme_type_variation = &"IconButton"
toggle_mode = true
action_mode = 0
icon = ExtResource("5_2ggtv")

[node name="SearchButton" type="Button" parent="VBoxContainer/TopBar" unique_id=2048350652]
Expand All @@ -97,6 +98,7 @@ focus_previous = NodePath("../ShowHiddenButton")
mouse_default_cursor_shape = 2
theme_type_variation = &"IconButton"
toggle_mode = true
action_mode = 0
icon = ExtResource("6_otods")
script = ExtResource("7_ejhg0")
action = "find"
Expand Down
3 changes: 1 addition & 2 deletions src/ui_parts/root_element_editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ func _on_height_button_toggled(toggled_on: bool) -> void:

func _on_viewbox_button_toggled(toggled_on: bool) -> void:
if toggled_on:
State.root_element.set_attribute("viewBox",
ListParser.rect_to_list(State.root_element.viewbox))
State.root_element.set_attribute("viewBox", ListParser.rect_to_list(State.root_element.viewbox))
State.save_svg()
else:
if State.root_element.has_attribute("width") and State.root_element.has_attribute("height"):
Expand Down
4 changes: 2 additions & 2 deletions src/ui_parts/shortcut_panel.gd
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ func update_layout() -> void:
var margin_container := MarginContainer.new()
margin_container.begin_bulk_theme_override()
const CONST_ARR: PackedStringArray = ["margin_left", "margin_right", "margin_top", "margin_bottom"]
for theme_type in CONST_ARR:
margin_container.add_theme_constant_override(theme_type, 4)
for theme_item in CONST_ARR:
margin_container.add_theme_constant_override(theme_item, 4)
margin_container.begin_bulk_theme_override()
main_container.add_child(margin_container)

Expand Down
11 changes: 5 additions & 6 deletions src/ui_widgets/basic_xnode_frame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ func _get_drag_data(_at_position: Vector2) -> Variant:
if State.selected_xids.is_empty():
return null

var data: Array[PackedInt32Array] = XIDUtils.filter_descendants(
State.selected_xids.duplicate(true))
var data: Array[PackedInt32Array] = XIDUtils.filter_descendants(State.selected_xids.duplicate(true))
set_drag_preview(XNodeChildrenBuilder.generate_drag_preview(data))
return data

Expand All @@ -49,8 +48,8 @@ func _on_title_button_pressed() -> void:
State.normal_select(xnode.xid)
var viewport := get_viewport()
var rect := title_bar.get_global_rect()
HandlerGUI.popup_under_rect_center(State.get_selection_context(HandlerGUI.popup_under_rect_center.bind(rect, viewport),
Utils.LayoutPart.INSPECTOR), rect, viewport)
HandlerGUI.popup_under_rect_center(State.get_selection_context(
HandlerGUI.popup_under_rect_center.bind(rect, viewport), Utils.LayoutPart.INSPECTOR), rect, viewport)


func _gui_input(event: InputEvent) -> void:
Expand All @@ -75,8 +74,8 @@ func _gui_input(event: InputEvent) -> void:
State.normal_select(xnode.xid)
var viewport := get_viewport()
var popup_pos := viewport.get_mouse_position()
HandlerGUI.popup_under_pos(State.get_selection_context(HandlerGUI.popup_under_pos.bind(popup_pos, viewport),
Utils.LayoutPart.INSPECTOR), popup_pos, viewport)
HandlerGUI.popup_under_pos(State.get_selection_context(
HandlerGUI.popup_under_pos.bind(popup_pos, viewport), Utils.LayoutPart.INSPECTOR), popup_pos, viewport)
accept_event()

func _on_mouse_exited() -> void:
Expand Down
32 changes: 15 additions & 17 deletions src/ui_widgets/palette_config.gd
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func sync_theming() -> void:
warning_sign.modulate = ThemeUtils.warning_icon_color
palette_button.begin_bulk_theme_override()
const CONST_ARR: PackedStringArray = ["normal", "hover", "pressed"]
for theme_type in CONST_ARR:
var stylebox := palette_button.get_theme_stylebox(theme_type).duplicate()
for theme_item in CONST_ARR:
var stylebox := palette_button.get_theme_stylebox(theme_item).duplicate()
stylebox.content_margin_top -= 3.0
stylebox.content_margin_bottom -= 2.0
stylebox.content_margin_left += 1.0
palette_button.add_theme_stylebox_override(theme_type, stylebox)
palette_button.add_theme_stylebox_override(theme_item, stylebox)
var panel_stylebox := get_theme_stylebox("panel").duplicate()
panel_stylebox.content_margin_top = panel_stylebox.content_margin_bottom
add_theme_stylebox_override("panel", panel_stylebox)
Expand Down Expand Up @@ -77,10 +77,10 @@ func hide_name_edit() -> void:
func _on_name_edit_text_changed(new_text: String) -> void:
name_edit.begin_bulk_theme_override()
const CONST_ARR: PackedStringArray = ["font_color", "font_hover_color"]
for theme_type in CONST_ARR:
for theme_item in CONST_ARR:
# If the new text matches the current title, show warning color if the palette is currently invalid.
# If the new text is different, check if it's unused, i.e., would be a valid title.
name_edit.add_theme_color_override(theme_type,
name_edit.add_theme_color_override(theme_item,
Configs.savedata.get_validity_color(false, (new_text != palette.title and not Configs.savedata.is_palette_title_unused(new_text)) or\
(new_text == palette.title and Configs.savedata.is_palette_valid(palette))))
name_edit.end_bulk_theme_override()
Expand All @@ -105,17 +105,15 @@ func set_label_text(new_text: String) -> void:
palette_button.begin_bulk_theme_override()
const CONST_ARR: PackedStringArray = ["font_color", "font_hover_color", "font_pressed_color"]
if palette.title.is_empty():
for theme_type in CONST_ARR:
palette_button.add_theme_color_override(theme_type,
ThemeUtils.subtle_text_color)
for theme_item in CONST_ARR:
palette_button.add_theme_color_override(theme_item, ThemeUtils.subtle_text_color)
else:
if not Configs.savedata.is_palette_valid(palette):
for theme_type in CONST_ARR:
palette_button.add_theme_color_override(theme_type,
Configs.savedata.basic_color_error)
for theme_item in CONST_ARR:
palette_button.add_theme_color_override(theme_item, Configs.savedata.basic_color_error)
else:
for theme_type in CONST_ARR:
palette_button.remove_theme_color_override(theme_type)
for theme_item in CONST_ARR:
palette_button.remove_theme_color_override(theme_item)
palette_button.end_bulk_theme_override()

func delete() -> void:
Expand All @@ -130,11 +128,11 @@ func move_down() -> void:
Configs.savedata.move_palette_down(find_palette_index())
layout_changed.emit()

func copy_palette(palette_idx: int) -> void:
DisplayServer.clipboard_set(Configs.savedata.get_palette(palette_idx).get_as_markup())
func copy_palette(palette_index: int) -> void:
DisplayServer.clipboard_set(Configs.savedata.get_palette(palette_index).get_as_markup())

func save_palette(palette_idx: int) -> void:
var saved_palette := Configs.savedata.get_palette(palette_idx)
func save_palette(palette_index: int) -> void:
var saved_palette := Configs.savedata.get_palette(palette_index)
FileUtils.open_xml_export_dialog(saved_palette.get_as_markup(), saved_palette.title)

func open_palette_options() -> void:
Expand Down
16 changes: 4 additions & 12 deletions src/ui_widgets/presented_shortcut.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,9 @@ var action: String
func _ready() -> void:
Configs.language_changed.connect(sync_localization)
sync_localization()
Configs.language_changed.connect(sync)
Configs.shortcuts_changed.connect(check_shortcuts_validity)
sync()

func sync_localization() -> void:
label.text = TranslationUtils.get_action_description(action)

func sync() -> void:
# Set up shortcut buttons. Nothing on them needs to be localized.
var events := InputMap.action_get_events(action)
# Clear the existing buttons.
for button in shortcut_container.get_children():
shortcut_container.remove_child(button)
button.queue_free()
# Create new ones.
for i in events.size():
var new_btn := Button.new()
new_btn.custom_minimum_size = Vector2(160, 24)
Expand All @@ -33,6 +22,9 @@ func sync() -> void:
shortcut_container.add_child(new_btn)
check_shortcuts_validity()

func sync_localization() -> void:
label.text = TranslationUtils.get_action_description(action)

func check_shortcuts_validity() -> void:
var events := InputMap.action_get_events(action)
for i in events.size():
Expand Down
Loading