diff --git a/ui/rsc/pref/dropdown.ui b/ui/rsc/pref/dropdown.ui
index bce91aa..a3b38c7 100644
--- a/ui/rsc/pref/dropdown.ui
+++ b/ui/rsc/pref/dropdown.ui
@@ -11,7 +11,7 @@
8
8
-
-
+
8
8
-
+
start
@@ -19,7 +19,7 @@
-
+
+
+
+
+
+ horizontal
+ 16
+ center
+ 12
+ 12
+ 8
+ 8
+
+
+
+ start
+ true
+
+
+
+
+ 0
+ 1
+ true
+ 2
+
+
+ 1
+ 20
+ 1
+ 1
+ 2
+
+
+
+
+
+
+
+
diff --git a/ui/rsc/pref/slider.ui b/ui/rsc/pref/slider.ui
new file mode 100644
index 0000000..eb833db
--- /dev/null
+++ b/ui/rsc/pref/slider.ui
@@ -0,0 +1,41 @@
+
+
+
+
+
+ horizontal
+ 16
+ center
+ 12
+ 12
+ 8
+ 8
+
+
+
+ start
+ true
+
+
+
+
+ 0
+ true
+ right
+ true
+
+
+ 25
+ 100
+ 5
+ 10
+ 100
+
+
+
+
+
+
+
+
diff --git a/ui/rsc/pref/switch.ui b/ui/rsc/pref/switch.ui
index e9ecbde..e167001 100644
--- a/ui/rsc/pref/switch.ui
+++ b/ui/rsc/pref/switch.ui
@@ -11,7 +11,7 @@
8
8
-
+
start
@@ -19,7 +19,7 @@
-
+
compact
diff --git a/ui/rsc/resources.gresource.xml b/ui/rsc/resources.gresource.xml
index d9e189c..47fcd0e 100644
--- a/ui/rsc/resources.gresource.xml
+++ b/ui/rsc/resources.gresource.xml
@@ -3,7 +3,9 @@
window.ui
pref/dropdown.ui
+ pref/number.ui
pref/entry.ui
+ pref/slider.ui
pref/switch.ui
diff --git a/ui/rsc/window.ui b/ui/rsc/window.ui
index 2c4c35a..8eb1025 100644
--- a/ui/rsc/window.ui
+++ b/ui/rsc/window.ui
@@ -1,6 +1,5 @@
-
lsfg-vk Configuration Window
800
@@ -45,9 +44,9 @@
-
-
-
+
+
+
@@ -82,32 +81,20 @@
Frame Generation
-
-
+
+
Multiplier
- 0
-
-
-
- - 2x
- - 3x
- - 4x
-
-
-
-
-
+
+
Flow Scale
- Enter a number between 0.25 and 1.00
- 0.7
-
+
Performance Mode
false
@@ -120,14 +107,14 @@
Frame Generation
-
+
HDR Mode
false
-
+
Experimental Present Mode
0
diff --git a/ui/src/main.rs b/ui/src/main.rs
index 6b8099c..51af8fb 100644
--- a/ui/src/main.rs
+++ b/ui/src/main.rs
@@ -1,26 +1,9 @@
-use adw;
-use gtk::{gio, prelude::*};
-
-pub mod wrapper {
- pub mod ui;
- pub mod pref;
-}
+mod ui;
const APP_ID: &str = "gay.pancake.lsfg-vk.ConfigurationUi";
fn main() {
- gio::resources_register_include!("ui.gresource")
- .expect("Failed to register resources");
-
- let app = adw::Application::builder()
- .application_id(APP_ID)
- .build();
- app.connect_activate(build_ui);
- app.run();
-}
-
-fn build_ui(app: &adw::Application) {
- let window = wrapper::ui::Window::new(app);
- window.set_application(Some(app));
- window.present();
+ let app = ui::App::new(APP_ID)
+ .expect("Failed to create application");
+ app.run()
}
diff --git a/ui/src/ui.rs b/ui/src/ui.rs
new file mode 100644
index 0000000..e11d734
--- /dev/null
+++ b/ui/src/ui.rs
@@ -0,0 +1,36 @@
+use std::sync::Arc;
+
+use adw;
+use gtk::{gio, glib, prelude::*};
+
+pub mod ui;
+pub mod pref;
+
+pub struct App {
+ app: Arc,
+}
+
+impl App {
+ pub fn new(appid: &str) -> Result {
+ gio::resources_register_include!("ui.gresource")?;
+
+ let app = adw::Application::builder()
+ .application_id(appid)
+ .build();
+ app.connect_activate(Self::build_ui);
+
+ Ok(App {
+ app: Arc::new(app)
+ })
+ }
+
+ fn build_ui(app: &adw::Application) {
+ let window = ui::Window::new(app);
+ window.set_application(Some(app));
+ window.present();
+ }
+
+ pub fn run(self){
+ self.app.run();
+ }
+}
diff --git a/ui/src/wrapper/pref.rs b/ui/src/ui/pref.rs
similarity index 60%
rename from ui/src/wrapper/pref.rs
rename to ui/src/ui/pref.rs
index 34a6b7b..7541955 100644
--- a/ui/src/wrapper/pref.rs
+++ b/ui/src/ui/pref.rs
@@ -4,6 +4,8 @@ use adw;
pub mod dropdown;
pub mod entry;
+pub mod number;
+pub mod slider;
pub mod switch;
glib::wrapper! {
@@ -22,6 +24,22 @@ glib::wrapper! {
gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget;
}
+glib::wrapper! {
+ pub struct PrefNumber(ObjectSubclass)
+ @extends
+ adw::PreferencesRow, gtk::ListBoxRow, gtk::Widget,
+ @implements
+ gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget;
+}
+
+glib::wrapper! {
+ pub struct PrefSlider(ObjectSubclass)
+ @extends
+ adw::PreferencesRow, gtk::ListBoxRow, gtk::Widget,
+ @implements
+ gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget;
+}
+
glib::wrapper! {
pub struct PrefEntry(ObjectSubclass)
@extends
@@ -42,6 +60,18 @@ impl PrefSwitch {
}
}
+impl PrefNumber {
+ pub fn new() -> Self {
+ glib::Object::new()
+ }
+}
+
+impl PrefSlider {
+ pub fn new() -> Self {
+ glib::Object::new()
+ }
+}
+
impl PrefEntry {
pub fn new() -> Self {
glib::Object::new()
diff --git a/ui/src/wrapper/pref/dropdown.rs b/ui/src/ui/pref/dropdown.rs
similarity index 94%
rename from ui/src/wrapper/pref/dropdown.rs
rename to ui/src/ui/pref/dropdown.rs
index 3d87371..0895a76 100644
--- a/ui/src/wrapper/pref/dropdown.rs
+++ b/ui/src/ui/pref/dropdown.rs
@@ -15,6 +15,9 @@ pub struct PrefDropdown {
default_selection: RefCell,
#[property(get, set)]
options: RefCell,
+
+ #[template_child]
+ pub dropdown: TemplateChild,
}
#[glib::object_subclass]
diff --git a/ui/src/wrapper/pref/entry.rs b/ui/src/ui/pref/entry.rs
similarity index 91%
rename from ui/src/wrapper/pref/entry.rs
rename to ui/src/ui/pref/entry.rs
index e60dcd4..a6a5b38 100644
--- a/ui/src/wrapper/pref/entry.rs
+++ b/ui/src/ui/pref/entry.rs
@@ -14,7 +14,10 @@ pub struct PrefEntry {
#[property(get, set)]
default_text: RefCell,
#[property(get, set)]
- tooltip_text: RefCell
+ tooltip_text: RefCell,
+
+ #[template_child]
+ pub entry: TemplateChild,
}
#[glib::object_subclass]
diff --git a/ui/src/ui/pref/number.rs b/ui/src/ui/pref/number.rs
new file mode 100644
index 0000000..5d96c96
--- /dev/null
+++ b/ui/src/ui/pref/number.rs
@@ -0,0 +1,43 @@
+use std::cell::RefCell;
+
+use gtk::glib;
+use gtk::subclass::prelude::*;
+use adw::subclass::prelude::*;
+use adw::prelude::*;
+
+#[derive(gtk::CompositeTemplate, glib::Properties, Default)]
+#[properties(wrapper_type = super::PrefNumber)]
+#[template(resource = "/gay/pancake/lsfg-vk/pref/number.ui")]
+pub struct PrefNumber {
+ #[property(get, set)]
+ opt_name: RefCell,
+
+ #[template_child]
+ pub number: TemplateChild,
+}
+
+#[glib::object_subclass]
+impl ObjectSubclass for PrefNumber {
+ const NAME: &'static str = "LSPrefNumber";
+ type Type = super::PrefNumber;
+ type ParentType = adw::PreferencesRow;
+
+ fn class_init(klass: &mut Self::Class) {
+ klass.bind_template();
+ }
+
+ fn instance_init(obj: &glib::subclass::InitializingObject) {
+ obj.init_template();
+ }
+}
+
+#[glib::derived_properties]
+impl ObjectImpl for PrefNumber {
+ fn constructed(&self) {
+ self.parent_constructed();
+ }
+}
+
+impl WidgetImpl for PrefNumber {}
+impl ListBoxRowImpl for PrefNumber {}
+impl PreferencesRowImpl for PrefNumber {}
diff --git a/ui/src/ui/pref/slider.rs b/ui/src/ui/pref/slider.rs
new file mode 100644
index 0000000..7cd7edd
--- /dev/null
+++ b/ui/src/ui/pref/slider.rs
@@ -0,0 +1,43 @@
+use std::cell::RefCell;
+
+use gtk::glib;
+use gtk::subclass::prelude::*;
+use adw::subclass::prelude::*;
+use adw::prelude::*;
+
+#[derive(gtk::CompositeTemplate, glib::Properties, Default)]
+#[properties(wrapper_type = super::PrefSlider)]
+#[template(resource = "/gay/pancake/lsfg-vk/pref/slider.ui")]
+pub struct PrefSlider {
+ #[property(get, set)]
+ opt_name: RefCell,
+
+ #[template_child]
+ pub slider: TemplateChild,
+}
+
+#[glib::object_subclass]
+impl ObjectSubclass for PrefSlider {
+ const NAME: &'static str = "LSPrefSlider";
+ type Type = super::PrefSlider;
+ type ParentType = adw::PreferencesRow;
+
+ fn class_init(klass: &mut Self::Class) {
+ klass.bind_template();
+ }
+
+ fn instance_init(obj: &glib::subclass::InitializingObject) {
+ obj.init_template();
+ }
+}
+
+#[glib::derived_properties]
+impl ObjectImpl for PrefSlider {
+ fn constructed(&self) {
+ self.parent_constructed();
+ }
+}
+
+impl WidgetImpl for PrefSlider {}
+impl ListBoxRowImpl for PrefSlider {}
+impl PreferencesRowImpl for PrefSlider {}
diff --git a/ui/src/wrapper/pref/switch.rs b/ui/src/ui/pref/switch.rs
similarity index 94%
rename from ui/src/wrapper/pref/switch.rs
rename to ui/src/ui/pref/switch.rs
index 222b2ad..e438546 100644
--- a/ui/src/wrapper/pref/switch.rs
+++ b/ui/src/ui/pref/switch.rs
@@ -13,6 +13,9 @@ pub struct PrefSwitch {
opt_name: RefCell,
#[property(get, set)]
default_state: RefCell,
+
+ #[template_child]
+ pub switch: TemplateChild,
}
#[glib::object_subclass]
diff --git a/ui/src/wrapper/ui.rs b/ui/src/ui/ui.rs
similarity index 100%
rename from ui/src/wrapper/ui.rs
rename to ui/src/ui/ui.rs
diff --git a/ui/src/ui/ui/window.rs b/ui/src/ui/ui/window.rs
new file mode 100644
index 0000000..24b680b
--- /dev/null
+++ b/ui/src/ui/ui/window.rs
@@ -0,0 +1,73 @@
+use gtk::{prelude::RangeExt, subclass::prelude::*};
+use adw::subclass::prelude::*;
+use crate::ui::pref::*;
+use gtk::{glib, CompositeTemplate};
+
+#[derive(CompositeTemplate, Default)]
+#[template(resource = "/gay/pancake/lsfg-vk/window.ui")]
+pub struct Window {
+ // main config elements
+ #[template_child]
+ pref_multiplier: TemplateChild,
+ #[template_child]
+ pref_flow_scale: TemplateChild,
+ #[template_child]
+ pref_performance_mode: TemplateChild,
+ #[template_child]
+ pref_hdr_mode: TemplateChild,
+ #[template_child]
+ pref_experimental_present_mode: TemplateChild,
+}
+
+#[glib::object_subclass]
+impl ObjectSubclass for Window {
+ const NAME: &'static str = "LSApplicationWindow";
+ type Type = super::Window;
+ type ParentType = adw::ApplicationWindow;
+
+ fn class_init(klass: &mut Self::Class) {
+ klass.bind_template();
+ }
+
+ fn instance_init(obj: &glib::subclass::InitializingObject) {
+ obj.init_template();
+ }
+}
+
+impl ObjectImpl for Window {
+ fn constructed(&self) {
+ self.parent_constructed();
+
+ self.pref_multiplier.get()
+ .imp().number.get().connect_value_changed(|dropdown| {
+ let selected = dropdown.value();
+ println!("Multiplier changed: {}", selected);
+ });
+ self.pref_flow_scale.get()
+ .imp().slider.get().connect_value_changed(|slider| {
+ let value = slider.value();
+ println!("Flow scale changed: {}", value);
+ });
+ self.pref_performance_mode.get()
+ .imp().switch.get().connect_state_notify(|switch| {
+ let state = switch.state();
+ println!("Performance mode changed: {}", state);
+ });
+ self.pref_hdr_mode.get()
+ .imp().switch.get().connect_state_notify(|switch| {
+ let state = switch.state();
+ println!("HDR mode changed: {}", state);
+ });
+ self.pref_experimental_present_mode.get()
+ .imp().dropdown.get().connect_selected_notify(|dropdown| {
+ let selected = dropdown.selected();
+ println!("Experimental present mode changed: {}", selected);
+ });
+ }
+}
+
+impl WidgetImpl for Window {}
+impl WindowImpl for Window {}
+impl ApplicationWindowImpl for Window {}
+impl AdwWindowImpl for Window {}
+impl AdwApplicationWindowImpl for Window {}
diff --git a/ui/src/wrapper/ui/window.rs b/ui/src/wrapper/ui/window.rs
deleted file mode 100644
index 975961d..0000000
--- a/ui/src/wrapper/ui/window.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-use gtk::subclass::prelude::*;
-use adw::subclass::prelude::*;
-use gtk::{glib, CompositeTemplate};
-
-#[derive(CompositeTemplate, Default)]
-#[template(resource = "/gay/pancake/lsfg-vk/window.ui")]
-pub struct Window {
-
-}
-
-#[glib::object_subclass]
-impl ObjectSubclass for Window {
- const NAME: &'static str = "LSApplicationWindow";
- type Type = super::Window;
- type ParentType = adw::ApplicationWindow;
-
- fn class_init(klass: &mut Self::Class) {
- klass.bind_template();
- }
-
- fn instance_init(obj: &glib::subclass::InitializingObject) {
- obj.init_template();
- }
-}
-
-impl ObjectImpl for Window {
- fn constructed(&self) {
- self.parent_constructed();
- }
-}
-
-impl WidgetImpl for Window {}
-impl WindowImpl for Window {}
-impl ApplicationWindowImpl for Window {}
-impl AdwWindowImpl for Window {}
-impl AdwApplicationWindowImpl for Window {}