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
22 changes: 22 additions & 0 deletions globals/globals.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
extends Node

func _ready() -> void:
get_tree().root.set_layout_direction(Window.LAYOUT_DIRECTION_LTR)

# ------------
# Logging tags
# ------------
Expand Down Expand Up @@ -128,3 +132,21 @@ const INF: float = 1e18
# EDGE LINE EDIT
# ------------
var active_weight_editor: LineEdit = null

# ------------
# Mobile Layout
# ------------
func is_mobile_layout(viewport: Viewport) -> bool:
var w := float(DisplayServer.window_get_size().x)
var vp_w := viewport.get_visible_rect().size.x
if w <= 0.0:
w = vp_w
else:
w = minf(w, vp_w)
if OS.has_feature("web"):
var inner: Variant = JavaScriptBridge.eval("window.innerWidth", true)
if inner != null:
var iw := float(inner)
if iw > 0.0:
w = minf(w, iw)
return w <= 768.0
20 changes: 7 additions & 13 deletions scenes/algorithm_controls/algorithm_controls.gd
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,14 @@ func _resolve_progress_fill() -> ProgressBar:

func _snap_to_bottom_center() -> void:
await get_tree().process_frame

set_anchors_preset(Control.PRESET_CENTER_BOTTOM)
grow_horizontal = Control.GROW_DIRECTION_BOTH
grow_vertical = Control.GROW_DIRECTION_BEGIN

var margin_y: float = 90.0 if Globals.is_mobile_layout(get_viewport()) else 24.0
var vp := get_viewport().get_visible_rect().size
if _is_mobile_web:
position = Vector2(
roundf(vp.x / 2.0 - size.x / 2.0),
vp.y - size.y - 150
)
else:
position = Vector2(
roundf(vp.x / 2.0 - size.x / 2.0),
vp.y - size.y - 24.0
)

func _is_mobile_web() -> bool:
return OS.has_feature("web_android") or OS.has_feature("web_ios")
position = Vector2(roundf(vp.x / 2.0 - size.x / 2.0), vp.y - size.y - margin_y)


# ──────────────────────────────────────────────────────────
Expand Down
8 changes: 4 additions & 4 deletions scenes/algorithm_controls/algorithm_controls.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ modulate = Color(0.25, 0.25, 0.28, 1)
texture_filter = 6
custom_minimum_size = Vector2(15, 15)
layout_mode = 0
offset_left = -6.0
offset_top = -3.0
offset_right = 14.0
offset_bottom = 21.0
offset_left = 6.0
offset_top = 4.0
offset_right = 26.0
offset_bottom = 28.0
size_flags_vertical = 4
tooltip_text = "Stop algorithm"
texture_normal = ExtResource("20_cld")
Expand Down
8 changes: 3 additions & 5 deletions scenes/algorithm_player/algorithm_player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -284,20 +284,18 @@ func _expose_visualizer() -> void:
func _place_visualizer_bottom_left() -> void:
var viewport_size: Vector2 = get_viewport().get_visible_rect().size
var panel_size: Vector2 = pseudo_visualizer.size
if _is_mobile_web():
if Globals.is_mobile_layout(get_viewport()):
var controls_margin := 90.0 + algorithm_controls.size.y + 12.0
pseudo_visualizer.position = Vector2(
PSEUDO_MARGIN,
viewport_size.y - panel_size.y - PSEUDO_MARGIN - 150
viewport_size.y - panel_size.y - controls_margin
)
else:
pseudo_visualizer.position = Vector2(
PSEUDO_MARGIN,
viewport_size.y - panel_size.y - PSEUDO_MARGIN
)

func _is_mobile_web() -> bool:
return OS.has_feature("web_android") or OS.has_feature("web_ios")

# Animation to show player controls.
func _expose_controls() -> void:
algorithm_controls.visible = true
Expand Down
23 changes: 1 addition & 22 deletions scenes/tool_bar/tool_bar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,10 @@ func _cache_desktop_layout() -> void:
_desktop_modifier_font = directed_btn.get_theme_font_size("font_size", "Button")


## Width used for the mobile breakpoint. With stretch/canvas_items the logical
## viewport stays at the project base width; window size and (on web) innerWidth
## reflect the actual layout width.
func _layout_width_for_breakpoint() -> float:
var w := float(DisplayServer.window_get_size().x)
var vp_w := get_viewport().get_visible_rect().size.x
if w <= 0.0:
w = vp_w
else:
w = minf(w, vp_w)
if OS.has_feature("web"):
var inner: Variant = JavaScriptBridge.eval("window.innerWidth", true)
if inner != null:
var iw := float(inner)
if iw > 0.0:
w = minf(w, iw)
return w


func _is_mobile_viewport() -> bool:
return _layout_width_for_breakpoint() <= MOBILE_VIEWPORT_MAX_WIDTH


func _apply_responsive_layout() -> void:
var mobile := _is_mobile_viewport()
var mobile := Globals.is_mobile_layout(get_viewport())
if mobile != _mobile_layout_active:
if mobile:
_enter_mobile_layout()
Expand Down
Loading