diff --git a/plugin.gd b/plugin.gd index 8230598..53758f0 100644 --- a/plugin.gd +++ b/plugin.gd @@ -1,3 +1,19 @@ +# STAROPENSOURCE UI SOURCE FILE +# Copyright (c) 2024 The StarOpenSource Project & Contributors +# Licensed under the GNU Affero General Public License v3 +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . @tool extends EditorPlugin diff --git a/scenesrc/SuiProgressBar.tscn b/scenesrc/SuiProgressBar.tscn new file mode 100644 index 0000000..743451c --- /dev/null +++ b/scenesrc/SuiProgressBar.tscn @@ -0,0 +1,25 @@ +[gd_scene load_steps=3 format=3 uid="uid://7v3lokrljsjw"] + +[ext_resource type="Script" path="res://addons/SUI/src/SuiProgressBar.gd" id="1_t211g"] +[ext_resource type="Theme" uid="uid://bfln8p0ov8enx" path="res://addons/SUI/themes/ProgressBar.tres" id="2_rvtjx"] + +[node name="SuiProgressBar" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = -1063.0 +offset_bottom = -762.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_t211g") +editor_process = true +runtime_process = true + +[node name="Bar" type="ProgressBar" parent="."] +layout_mode = 0 +offset_right = 377.0 +offset_bottom = 48.0 +theme = ExtResource("2_rvtjx") +theme_override_font_sizes/font_size = 25 +value = 50.0 diff --git a/src/SuiBaseClass.gd b/src/SuiBaseClass.gd index 9f74d32..4fb47ef 100644 --- a/src/SuiBaseClass.gd +++ b/src/SuiBaseClass.gd @@ -1,3 +1,19 @@ +# STAROPENSOURCE UI SOURCE FILE +# Copyright (c) 2024 The StarOpenSource Project & Contributors +# Licensed under the GNU Affero General Public License v3 +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . @tool extends Control class_name SuiBaseClass diff --git a/src/SuiHeader.gd b/src/SuiHeader.gd index 6830651..82134d7 100644 --- a/src/SuiHeader.gd +++ b/src/SuiHeader.gd @@ -1,3 +1,19 @@ +# STAROPENSOURCE UI SOURCE FILE +# Copyright (c) 2024 The StarOpenSource Project & Contributors +# Licensed under the GNU Affero General Public License v3 +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . @tool extends SuiBaseClass diff --git a/src/SuiIconButton.gd b/src/SuiIconButton.gd index 2649443..aaa682f 100644 --- a/src/SuiIconButton.gd +++ b/src/SuiIconButton.gd @@ -1,3 +1,19 @@ +# STAROPENSOURCE UI SOURCE FILE +# Copyright (c) 2024 The StarOpenSource Project & Contributors +# Licensed under the GNU Affero General Public License v3 +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . @tool extends SuiBaseClass @@ -85,5 +101,5 @@ func update_element() -> void: $Icon.axis_stretch_horizontal = as_horizontal $Icon.axis_stretch_vertical = as_vertical -func update_pressed_state(is_pressed: bool) -> void: +func update_pressed(is_pressed: bool) -> void: $Button.button_pressed = is_pressed diff --git a/src/SuiProgressBar.gd b/src/SuiProgressBar.gd new file mode 100644 index 0000000..9fbf8b1 --- /dev/null +++ b/src/SuiProgressBar.gd @@ -0,0 +1,53 @@ +# STAROPENSOURCE UI SOURCE FILE +# Copyright (c) 2024 The StarOpenSource Project & Contributors +# Licensed under the GNU Affero General Public License v3 +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +@tool +extends SuiBaseClass + +@export_category("Base Configuration") +## The size the percentage text should have. +@export var font_size: int = 25 +@export_subgroup("ProgressBar") +## The minimum value this progress bar can display. +@export var minimum_value: float = 0.0 +## The maximum value this progress bar can display. +@export var maximum_value: float = 100.0 +## Forwarded from the internal [ProgressBar]. Will be overriden with the internal bar's value, any changes to this variable will not be reflected (except during [method _ready]). +@export var value: float = 50.0 +## Determines if [code]value[/code] should be rounded to the nearest integer. +@export var rounded: bool = false +## See [member Range.exp_edit]. +@export var exponential: bool = false + +func _ready() -> void: + super() + if !in_editor(): $Bar.value = value + +func update_element() -> void: + # Update sizes + $Bar.size = size + + # Update ProgressBar stuff + $Bar.min_value = minimum_value + $Bar.max_value = maximum_value + $Bar.rounded = rounded + $Bar.exp_edit = exponential + if in_editor(): $Bar.value = value + else: value = $Bar.value + $Bar.add_theme_font_size_override("font_size", font_size) + +func update_value(value_new: float) -> void: + $Bar.value = value_new diff --git a/src/SuiScroller.gd b/src/SuiScroller.gd index c3f786b..f2a4a08 100644 --- a/src/SuiScroller.gd +++ b/src/SuiScroller.gd @@ -1,3 +1,19 @@ +# STAROPENSOURCE UI SOURCE FILE +# Copyright (c) 2024 The StarOpenSource Project & Contributors +# Licensed under the GNU Affero General Public License v3 +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . @tool extends SuiBaseClass diff --git a/src/SuiText.gd b/src/SuiText.gd index 91bcda4..703dd19 100644 --- a/src/SuiText.gd +++ b/src/SuiText.gd @@ -1,3 +1,19 @@ +# STAROPENSOURCE UI SOURCE FILE +# Copyright (c) 2024 The StarOpenSource Project & Contributors +# Licensed under the GNU Affero General Public License v3 +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . @tool extends SuiBaseClass diff --git a/src/SuiTextButton.gd b/src/SuiTextButton.gd index 2022c81..746c767 100644 --- a/src/SuiTextButton.gd +++ b/src/SuiTextButton.gd @@ -1,3 +1,19 @@ +# STAROPENSOURCE UI SOURCE FILE +# Copyright (c) 2024 The StarOpenSource Project & Contributors +# Licensed under the GNU Affero General Public License v3 +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . @tool extends SuiBaseClass @@ -53,5 +69,5 @@ func update_element() -> void: $Text.add_theme_font_size_override("bold_italics_font_size", font_size) $Text.add_theme_font_size_override("mono_font_size", font_size) -func update_pressed_state(is_pressed: bool) -> void: +func update_pressed(is_pressed: bool) -> void: $Button.button_pressed = is_pressed diff --git a/src/SuiTypes.gd b/src/SuiTypes.gd index 7642980..a0f01c2 100644 --- a/src/SuiTypes.gd +++ b/src/SuiTypes.gd @@ -1,3 +1,19 @@ +# STAROPENSOURCE UI SOURCE FILE +# Copyright (c) 2024 The StarOpenSource Project & Contributors +# Licensed under the GNU Affero General Public License v3 +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . extends Node class_name SuiTypes diff --git a/themes/ProgressBar.tres b/themes/ProgressBar.tres new file mode 100644 index 0000000..cc22ff9 --- /dev/null +++ b/themes/ProgressBar.tres @@ -0,0 +1,23 @@ +[gd_resource type="Theme" load_steps=4 format=3 uid="uid://bfln8p0ov8enx"] + +[ext_resource type="FontFile" uid="uid://d3cdnrnmplqa2" path="res://addons/SUI/fonts/Jost/Jost-Medium.ttf" id="1_5nv4j"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nesmb"] +bg_color = Color(0.997878, 0.337467, 0.369875, 1) +corner_radius_top_left = 8 +corner_radius_top_right = 8 +corner_radius_bottom_right = 8 +corner_radius_bottom_left = 8 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1awnp"] +bg_color = Color(0.839216, 0.0196078, 0.196078, 1) +corner_radius_top_left = 8 +corner_radius_top_right = 8 +corner_radius_bottom_right = 8 +corner_radius_bottom_left = 8 + +[resource] +ProgressBar/colors/font_color = Color(1, 1, 1, 1) +ProgressBar/fonts/font = ExtResource("1_5nv4j") +ProgressBar/styles/background = SubResource("StyleBoxFlat_nesmb") +ProgressBar/styles/fill = SubResource("StyleBoxFlat_1awnp")