diff --git a/README.md b/README.md index 544ce2a..506bccd 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,17 @@ # GadgetClockBar -- [ ] refactor main clock bar code - process method - - [ ] pick time for the clock to end, and how long before that it should start (in duration - ie 2 hours) +- [x] refactor main clock bar code - process method + - [x] pick time for the clock to end, and how long before that it should start (in duration - ie 2 hours) - [x] support for varied monitor size - [x] app / toolbar icons - [x] app name - Sleepyclock - [x] toolbar menu - [x] customisation/settings -- [ ] scale on high resolution displays +- [x] scale on high resolution displays - [ ] remove leftover files from focus and payphone watcher - [ ] fade/flash when time rouns out - [x] options save and load - [ ] select display style (which side) - [ ] hide clock outside active hours +- [ ] configurable bar/text(?) size diff --git a/clock.gd b/clock.gd index e092a22..c12c389 100644 --- a/clock.gd +++ b/clock.gd @@ -1,6 +1,7 @@ extends Control var taskbar_height : int = 50 +var bar_size : int = 10 @export var bar: TextureProgressBar @export var label: Label @export var options_window: Window @@ -21,19 +22,30 @@ func _ready() -> void: func setup_window(): + var screen_size : Vector2i = DisplayServer.screen_get_size() # get current screen size var screen_pos : Vector2i = DisplayServer.screen_get_position(DisplayServer.SCREEN_OF_MAIN_WINDOW) # get the posiiton of the window on the virtual display get_window().min_size = Vector2i(1,1) # weird godot bug where the min screen size is 64x64 unless set in code if bar_position == Position.Bottom: - get_window().size = Vector2i(screen_size.x, 10) # set window size to be 10 high and screen width wide - DisplayServer.window_set_position(screen_pos + Vector2i(0,screen_size.y-10-taskbar_height)) # set position of window to be just above the taskbar + if screen_size.x > 2560: + bar_size = 20 + + get_window().size = Vector2i(screen_size.x, bar_size) # set window size to be 10 high and screen width wide + size = Vector2i(screen_size.x, bar_size) + DisplayServer.window_set_position(screen_pos + Vector2i(0,screen_size.y-bar_size-taskbar_height)) # set position of window to be just above the taskbar position.y = 0 # set position of bar to be where it should be (moves when we change the window size) + label.label_settings.font_size = (bar_size/10)*10 if bar_position == Position.Right: - get_window().size = Vector2i(10, screen_size.y) # set window size to be 10 high and screen width wide + if screen_size.y > 1440: + bar_size = 20 + + get_window().size = Vector2i(bar_size, screen_size.y) # set window size to be 10 high and screen width wide size.x = screen_size.y - taskbar_height - DisplayServer.window_set_position(screen_pos + Vector2i(screen_size.x-10,0)) # set position of window to be just above the taskbar + size.y = bar_size + label.label_settings.font_size = (bar_size/10)*10 + DisplayServer.window_set_position(screen_pos + Vector2i(screen_size.x-bar_size,0)) # set position of window to be just above the taskbar position.y = 0 # set position of bar to be where it should be (moves when we change the window size) - position.x = 10 + position.x = bar_size rotation_degrees = 90 # Called every frame. 'delta' is the elapsed time since the previous frame. diff --git a/main.tscn b/main.tscn index 1de927d..1c468db 100644 --- a/main.tscn +++ b/main.tscn @@ -112,9 +112,8 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -min_value = 100.0 step = 0.0 -value = 100.0 +value = 50.0 nine_patch_stretch = true texture_progress = SubResource("GradientTexture1D_1bvp3") @@ -133,7 +132,6 @@ oversampling_override = 1.0 title = "SleepClock Options" initial_position = 1 size = Vector2i(450, 300) -visible = false unresizable = true always_on_top = true minimize_disabled = true @@ -213,13 +211,45 @@ max_value = 59.0 suffix = "m" select_all_on_focus = true -[node name="Label2" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=201796106] +[node name="Label4" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1856476808] layout_mode = 2 -text = "Things that will go here: -- bar end time -- bar duration -- text to display inside bar -- where to display bar" +text = "Bar Position" + +[node name="OptionButton" type="OptionButton" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1955200779] +layout_mode = 2 +selected = 0 +item_count = 2 +popup/item_0/text = "Bottom" +popup/item_0/id = 0 +popup/item_1/text = "Right" +popup/item_1/id = 1 + +[node name="Label2" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1597493397] +layout_mode = 2 +text = "Bar Size" + +[node name="HBoxContainer3" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer/GridContainer" unique_id=1274134494] +layout_mode = 2 + +[node name="Label" type="Label" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer3" unique_id=531473775] +layout_mode = 2 +text = "10px" + +[node name="HSlider" type="HSlider" parent="Options Window/MarginContainer/VBoxContainer/GridContainer/HBoxContainer3" unique_id=271540690] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 4 +min_value = 10.0 +max_value = 50.0 +step = 10.0 +value = 10.0 +tick_count = 5 +ticks_on_borders = true + +[node name="Label2" type="Label" parent="Options Window/MarginContainer/VBoxContainer" unique_id=201796106] +layout_mode = 2 +text = "todo: +- text to display inside bar" label_settings = SubResource("LabelSettings_1bvp3") [node name="HBoxContainer" type="HBoxContainer" parent="Options Window/MarginContainer/VBoxContainer" unique_id=2066769118]