Skip to content

Commit

Permalink
Merge pull request #140 from feagi/new_window_sizing
Browse files Browse the repository at this point in the history
new scaling system
  • Loading branch information
Kakcalu13 committed Mar 5, 2024
2 parents 85917a3 + a12ed78 commit 5ede780
Show file tree
Hide file tree
Showing 140 changed files with 1,671 additions and 750 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,25 @@ var _fancyText: RichTextLabel
var _timer: Timer
var _move_timer: Timer
var _gap: int
var _default_font_size: int
var _default_text_section_size: Vector2
var _left_side_offset: int


func _ready():
_fancyText = $Notification/RichTextLabel
_timer = $Notification/notification_timer
_move_timer = $Notification/move_timer
_left_side_offset = position.x - size.x
_default_font_size = _fancyText.get_theme_font_size(&"normal_font_size")
_default_text_section_size = _fancyText.custom_minimum_size
_timer.one_shot = true
_timer.timeout.connect(_closing)
mouse_entered.connect(_pause_timer_on_mouse_over)
mouse_exited.connect(_unpause_timer_on_mouse_off)
_update_size(VisConfig.UI_manager.UI_scale)
VisConfig.UI_manager.UI_scale_changed.connect(_update_size)


func set_notification(message: StringName, y_gap: int, time_seconds, notification_type: NOTIFICATION_TYPE) -> void:
_fancyText.text = message
Expand All @@ -52,3 +62,9 @@ func _pause_timer_on_mouse_over() -> void:

func _unpause_timer_on_mouse_off() -> void:
_timer.paused = false

func _update_size(multiplier: float) -> void:
_fancyText.add_theme_font_size_override(&"normal_font_size", int(float(_default_font_size) * multiplier))
_fancyText.custom_minimum_size = _default_text_section_size * multiplier
position.x = _left_side_offset# + size.x
size = Vector2(0,0)
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[gd_scene load_steps=9 format=3 uid="uid://deakdqregtx4w"]

[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Notifications/SingleNotification.gd" id="1_ib5cw"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/Texture_Element.gd" id="2_ybmk1"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/UIScaling/ScalingTextureButton.gd" id="2_4t5b2"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/UIScaling/ScalingControl.gd" id="2_31i85"]
[ext_resource type="Texture2D" uid="uid://b3ummhoiswkb7" path="res://Feagi-Godot-Interface/UI/Resources/Icons/close_S.png" id="3_ypn32"]
[ext_resource type="Texture2D" uid="uid://cdk46tfku3rbg" path="res://Feagi-Godot-Interface/UI/Resources/Icons/close_C.png" id="4_s0s1r"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/Buttons/TextureButton_Element.gd" id="4_t35d1"]
[ext_resource type="Texture2D" uid="uid://f3assbibvj8x" path="res://Feagi-Godot-Interface/UI/Resources/Icons/close_H.png" id="5_jjahx"]
[ext_resource type="Texture2D" uid="uid://d13jijnc01gm4" path="res://Feagi-Godot-Interface/UI/Resources/Icons/close_D.png" id="6_53bey"]

Expand All @@ -15,7 +15,7 @@ bg_color = Color(0.321569, 0.321569, 0.321569, 0.65098)
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -204.0
offset_left = -250.0
offset_bottom = 50.0
grow_horizontal = 0
theme_override_styles/panel = SubResource("StyleBoxFlat_hjnie")
Expand All @@ -27,11 +27,12 @@ layout_mode = 2
[node name="gap2" type="Control" parent="Notification"]
custom_minimum_size = Vector2(5, 0)
layout_mode = 2
script = ExtResource("2_31i85")

[node name="Texture_Element" type="TextureRect" parent="Notification"]
layout_mode = 2
mouse_filter = 2
script = ExtResource("2_ybmk1")
script = ExtResource("2_31i85")

[node name="RichTextLabel" type="RichTextLabel" parent="Notification"]
clip_contents = false
Expand All @@ -50,8 +51,10 @@ layout_mode = 2
[node name="Control" type="Control" parent="Notification/VBoxContainer"]
custom_minimum_size = Vector2(0, 3)
layout_mode = 2
script = ExtResource("2_31i85")

[node name="CloseButton" type="TextureButton" parent="Notification/VBoxContainer"]
custom_minimum_size = Vector2(24, 24)
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 4
Expand All @@ -62,12 +65,12 @@ texture_hover = ExtResource("5_jjahx")
texture_disabled = ExtResource("6_53bey")
ignore_texture_size = true
stretch_mode = 0
script = ExtResource("4_t35d1")
scale_multiplier = 0.5
script = ExtResource("2_4t5b2")

[node name="gap" type="Control" parent="Notification"]
custom_minimum_size = Vector2(5, 0)
layout_mode = 2
script = ExtResource("2_31i85")

[node name="notification_timer" type="Timer" parent="Notification"]
wait_time = 5.0
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 18 additions & 3 deletions godot_source/Feagi-Godot-Interface/UI/Universal/UIManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ signal user_changed_typing_status(is_typing: bool) ## Emits whenever a user star
signal user_changed_window_drag_status(is_dragging_a_window: bool) ## Emits whenever a user starts / stops dragging a window
signal mode_changed(new_mode: MODE)
signal UI_scale_changed(multiplier: float)
signal UI_scale_changed_spinbox(new_theme: Theme)

@export var enable_developer_options: bool = false
@export var developer_options_key: Key = KEY_BACKSLASH
Expand Down Expand Up @@ -49,18 +50,23 @@ var is_user_dragging_a_window: bool:
_is_user_dragging_a_window = v
user_changed_window_drag_status.emit(v)

var UI_scale: float:
var UI_scale: float:
get: return _UI_scale
set(v):
if v == _UI_scale:
return
_UI_scale = v
UI_scale_changed.emit(v)
UI_scale_changed_spinbox.emit(_generate_theme_for_spinbox(v))

var circuit_builder: CorticalNodeGraph:
get: return $temp_split/NodeGraph

var rosetta: Rosetta:
get: return _rosetta

var temp_spinbox_theme: Theme #TODO this is bad, migrate away once spinbox supports theme overrides

var _window_manager_ref: WindowManager
var _notification_system_ref: NotificationSystem
var _rosetta: Rosetta
Expand All @@ -70,6 +76,7 @@ var _is_user_typing: bool = false
var _is_user_dragging_a_window: bool = false
var _current_mode: MODE = MODE.VISUALIZER_3D
var _UI_scale: float = 1.0
var _global_theme: Theme

func _init():
_rosetta = Rosetta.new()
Expand All @@ -81,6 +88,8 @@ func _ready():
_notification_system_ref = $NotificationSystem
VisConfig.UI_manager = self
_update_screen_size()
_global_theme = load(ProjectSettings.get_setting("gui/theme/custom")) #cursed
temp_spinbox_theme = _generate_theme_for_spinbox(1.0)

func _input(event: InputEvent) -> void:
if !enable_developer_options:
Expand Down Expand Up @@ -126,14 +135,20 @@ func make_error_notification(key: StringName, replacements: Dictionary, notifica
push_error("Posting error to user: %s" % string_to_post)
_notification_system_ref.add_notification(string_to_post, notification_type, time)



#TODO TEMP
## Tell BV to create a new singular cortical area preview
func spawn_BV_single_preview(preview_dimensions: Vector3, preview_position: Vector3, color: Color = BrainMonitorSinglePreview.DEFAULT_COLOR, is_rendering: bool = true) -> BrainMonitorSinglePreview:
var preview: BrainMonitorSinglePreview = $Brain_Visualizer.generate_single_preview(preview_dimensions, preview_position, color, is_rendering)
return preview

## Utterly cursed workaround to generate a custom theme for spinboxes since thye cannot set overrides
func _generate_theme_for_spinbox(multiplier: float) -> Theme:
var new_theme: Theme = _global_theme.duplicate()
var original_font_size: float = new_theme.get_font_size("font_size", "LineEdit")
var new_font_size: int = int(multiplier * original_font_size)
new_theme.set_font_size("font_size", "LineEdit", int(multiplier * original_font_size))
return new_theme

func snap_camera_to_cortical_area(cortical_area: BaseCorticalArea) -> void:
#TODO change behavior depending on BV / CB
$Brain_Visualizer.snap_camera_to_cortical_area(cortical_area)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends BaseWindowPanel
extends BaseDraggableWindow
class_name WindowAmalgamationRequest

signal null_dimchange_signal(val: Vector3i) # Not technically utilized, but needed as a placeholder as a required arg
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[gd_scene load_steps=8 format=3 uid="uid://b4ksbionxkwg"]
[gd_scene load_steps=9 format=3 uid="uid://b4ksbionxkwg"]

[ext_resource type="Theme" uid="uid://cjrivk0518jvv" path="res://Feagi-Godot-Interface/UI/Resources/theme/main_theme.tres" id="1_i42xn"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Draggable_Windows/Amalgamation_Request/WindowAmalgamationRequest.gd" id="2_wg6iy"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/ContainerShrinker.gd" id="3_71xpo"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/UIScaling/ContainerShrinker.gd" id="3_7786q"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/TextBoxes/TextInput.gd" id="4_1iehj"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/UIScaling/ScalingLabel.gd" id="4_2b1uf"]
[ext_resource type="PackedScene" uid="uid://ci8uvawjvxfax" path="res://Feagi-Godot-Interface/UI/Windows/Elements/Vectors/Vector3iSpinBoxField.tscn" id="5_2iifs"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/Buttons/TextButton_Element.gd" id="7_ikphh"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/UIScaling/ScalingTextButton.gd" id="6_73b4d"]
[ext_resource type="PackedScene" uid="uid://c10sw6pgpfy48" path="res://Feagi-Godot-Interface/UI/Windows/Elements/TitleBar/TitleBar.tscn" id="8_gn5it"]

[node name="WindowAmalgamationRequest" type="Panel"]
Expand All @@ -20,7 +21,7 @@ layout_mode = 0
offset_right = 440.0
offset_bottom = 127.0
vertical = true
script = ExtResource("3_71xpo")
script = ExtResource("3_7786q")

[node name="gap1" type="Control" parent="Container"]
custom_minimum_size = Vector2(0, 5)
Expand All @@ -33,6 +34,7 @@ layout_mode = 2
layout_mode = 2
size_flags_horizontal = 3
text = "Title"
script = ExtResource("4_2b1uf")

[node name="AmalgamationTitle" type="LineEdit" parent="Container/HBoxContainer"]
custom_minimum_size = Vector2(200, 0)
Expand All @@ -52,6 +54,7 @@ layout_mode = 2
layout_mode = 2
size_flags_horizontal = 3
text = "3D Coordinates"
script = ExtResource("4_2b1uf")

[node name="Coordinates_3D" parent="Container/HBoxContainer2" instance=ExtResource("5_2iifs")]
layout_mode = 2
Expand All @@ -67,13 +70,13 @@ layout_mode = 2
layout_mode = 2
size_flags_horizontal = 3
text = "Cancel"
script = ExtResource("7_ikphh")
script = ExtResource("6_73b4d")

[node name="import" type="Button" parent="Container/HBoxContainer3"]
layout_mode = 2
size_flags_horizontal = 3
text = "Import"
script = ExtResource("7_ikphh")
script = ExtResource("6_73b4d")

[node name="TitleBar" parent="." instance=ExtResource("8_gn5it")]
layout_mode = 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends BaseWindowPanel
extends BaseDraggableWindow
class_name WindowCloneCorticalArea

signal null_dimensions_signal(vector: Vector3i) #not utilized but required as an empty input for a func
Expand All @@ -14,10 +14,10 @@ var _cloning_cortical_area: BaseCorticalArea
var _preview_holder: GenericSinglePreviewHandler

func _ready() -> void:
var _create_button: TextButton_Element = $Container/Create_button
_field_cortical_name = $Container/HBoxContainer/Cortical_Name
_field_3d_location = $Container/HBoxContainer2/Coordinates_3D
_field_2d_location = $Container/HBoxContainer3/Coordinates_2D
super()
_field_cortical_name = _window_internals.get_node('HBoxContainer/Cortical_Name')
_field_3d_location = _window_internals.get_node('HBoxContainer2/Coordinates_3D')
_field_2d_location = _window_internals.get_node('HBoxContainer3/Coordinates_2D')
_preview_holder = GenericSinglePreviewHandler.new()

func setup(cloning_cortical_area: BaseCorticalArea) -> void:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@
[gd_scene load_steps=9 format=3 uid="uid://b2knwu28hl12b"]
[gd_scene load_steps=8 format=3 uid="uid://b2knwu28hl12b"]

[ext_resource type="Theme" uid="uid://cjrivk0518jvv" path="res://Feagi-Godot-Interface/UI/Resources/theme/main_theme.tres" id="1_reqsy"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Draggable_Windows/Clone_Cortical_Area/WindowCloneCorticalArea.gd" id="2_8fxof"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/ContainerShrinker.gd" id="3_nsng2"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/UIScaling/ScalingLabel.gd" id="4_dpe0j"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/TextBoxes/TextInput.gd" id="5_6v723"]
[ext_resource type="PackedScene" uid="uid://brwx50pyfywb7" path="res://Feagi-Godot-Interface/UI/Windows/Elements/Vectors/Vector2iSpinBoxField.tscn" id="6_sl08t"]
[ext_resource type="PackedScene" uid="uid://ci8uvawjvxfax" path="res://Feagi-Godot-Interface/UI/Windows/Elements/Vectors/Vector3iSpinBoxField.tscn" id="6_t2gp1"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/Buttons/TextButton_Element.gd" id="9_4iuqj"]
[ext_resource type="Script" path="res://Feagi-Godot-Interface/UI/Windows/Elements/UIScaling/ScalingTextButton.gd" id="7_flsw2"]
[ext_resource type="PackedScene" uid="uid://c10sw6pgpfy48" path="res://Feagi-Godot-Interface/UI/Windows/Elements/TitleBar/TitleBar.tscn" id="10_smykg"]

[node name="WindowCloneCorticalArea" type="Panel"]
offset_top = 40.0
[node name="WindowCloneCorticalArea" type="VBoxContainer"]
offset_right = 126.0
offset_bottom = 40.0
size_flags_horizontal = 0
theme = ExtResource("1_reqsy")
size_flags_vertical = 0
theme_override_constants/separation = 0
script = ExtResource("2_8fxof")

[node name="Container" type="BoxContainer" parent="."]
layout_mode = 0
offset_right = 440.0
offset_bottom = 127.0
vertical = true
script = ExtResource("3_nsng2")
[node name="TitleBar" parent="." instance=ExtResource("10_smykg")]
layout_mode = 2
title = "Clone Cortical Area"

[node name="WindowPanel" type="PanelContainer" parent="."]
layout_mode = 2

[node name="WindowMargin" type="MarginContainer" parent="WindowPanel"]
layout_mode = 2

[node name="gap1" type="Control" parent="Container"]
[node name="WindowInternals" type="VBoxContainer" parent="WindowPanel/WindowMargin"]
layout_mode = 2

[node name="gap1" type="Control" parent="WindowPanel/WindowMargin/WindowInternals"]
custom_minimum_size = Vector2(0, 5)
layout_mode = 2

[node name="HBoxContainer" type="HBoxContainer" parent="Container"]
[node name="HBoxContainer" type="HBoxContainer" parent="WindowPanel/WindowMargin/WindowInternals"]
layout_mode = 2

[node name="Label" type="Label" parent="Container/HBoxContainer"]
[node name="Label" type="Label" parent="WindowPanel/WindowMargin/WindowInternals/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "Cortical Name"
script = ExtResource("4_dpe0j")

[node name="Cortical_Name" type="LineEdit" parent="Container/HBoxContainer"]
[node name="Cortical_Name" type="LineEdit" parent="WindowPanel/WindowMargin/WindowInternals/HBoxContainer"]
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
placeholder_text = "Friendly Name"
max_length = 16
script = ExtResource("5_6v723")

[node name="gap2" type="Control" parent="Container"]
[node name="gap2" type="Control" parent="WindowPanel/WindowMargin/WindowInternals"]
custom_minimum_size = Vector2(0, 3)
layout_mode = 2

[node name="HBoxContainer2" type="HBoxContainer" parent="Container"]
[node name="HBoxContainer2" type="HBoxContainer" parent="WindowPanel/WindowMargin/WindowInternals"]
layout_mode = 2

[node name="Label" type="Label" parent="Container/HBoxContainer2"]
[node name="Label" type="Label" parent="WindowPanel/WindowMargin/WindowInternals/HBoxContainer2"]
layout_mode = 2
size_flags_horizontal = 3
text = "3D Coordinates"
script = ExtResource("4_dpe0j")

[node name="Coordinates_3D" parent="Container/HBoxContainer2" instance=ExtResource("6_t2gp1")]
[node name="Coordinates_3D" parent="WindowPanel/WindowMargin/WindowInternals/HBoxContainer2" instance=ExtResource("6_t2gp1")]
layout_mode = 2

[node name="HBoxContainer3" type="HBoxContainer" parent="Container"]
[node name="HBoxContainer3" type="HBoxContainer" parent="WindowPanel/WindowMargin/WindowInternals"]
layout_mode = 2

[node name="Label" type="Label" parent="Container/HBoxContainer3"]
[node name="Label" type="Label" parent="WindowPanel/WindowMargin/WindowInternals/HBoxContainer3"]
layout_mode = 2
size_flags_horizontal = 3
text = "2D Coordinates"
script = ExtResource("4_dpe0j")

[node name="Coordinates_2D" parent="Container/HBoxContainer3" instance=ExtResource("6_sl08t")]
[node name="Coordinates_2D" parent="WindowPanel/WindowMargin/WindowInternals/HBoxContainer3" instance=ExtResource("6_sl08t")]
layout_mode = 2

[node name="gap" type="Control" parent="Container"]
[node name="gap" type="Control" parent="WindowPanel/WindowMargin/WindowInternals"]
custom_minimum_size = Vector2(0, 3)
layout_mode = 2

[node name="Clone_button" type="Button" parent="Container"]
[node name="Clone_button" type="Button" parent="WindowPanel/WindowMargin/WindowInternals"]
layout_mode = 2
text = "Clone Cortical Area"
script = ExtResource("9_4iuqj")

[node name="TitleBar" parent="." instance=ExtResource("10_smykg")]
layout_mode = 0
offset_top = -40.0
offset_right = 391.0
offset_bottom = 0.0
title = "Clone Cortical Area"

[connection signal="pressed" from="Container/Clone_button" to="." method="_clone_pressed"]
script = ExtResource("7_flsw2")
Loading

0 comments on commit 5ede780

Please sign in to comment.