diff --git a/data/io.gitlab.nekocwd.pipetap.gschema.xml b/data/io.gitlab.nekocwd.pipetap.gschema.xml
index d6a0618..2fbc587 100644
--- a/data/io.gitlab.nekocwd.pipetap.gschema.xml
+++ b/data/io.gitlab.nekocwd.pipetap.gschema.xml
@@ -1,25 +1,28 @@
-
+
0
-
- 0
+
+ -1
-
- 0
+
+ 10
-
- 0
+
+ 80
-
- false
+
+ 110
+
+ true
+
\ No newline at end of file
diff --git a/src/application.vala b/src/application.vala
index 05e928c..8984737 100644
--- a/src/application.vala
+++ b/src/application.vala
@@ -20,7 +20,6 @@
public class PipeTap.Application : Adw.Application {
public Settings settings;
- public bool adjust_overlay_visible { get; set; }
public Ui.SliderOverlay exposure;
public Ui.SliderOverlay focus;
public Ui.MainBar main_bar;
@@ -38,11 +37,12 @@ public class PipeTap.Application : Adw.Application {
{ "about", this.on_about_action },
{ "preferences", this.on_preferences_action },
{ "quit", this.quit },
- { "adjust-overlays", () => { adjust_overlay_visible = !adjust_overlay_visible; } }
};
this.add_action_entries (action_entries, this);
this.set_accels_for_action ("app.quit", { "q" });
settings = new Settings ("io.gitlab.nekocwd.pipetap");
+ if (settings.get_boolean ("is-uninitialised"))
+ reset_settings ();
}
public override void activate () {
@@ -84,6 +84,32 @@ public class PipeTap.Application : Adw.Application {
}
private void on_preferences_action () {
- message ("app.preferences action activated");
+ new Ui.Settings ().present (null);
+ }
+
+ public void reset_settings () {
+ settings.set_boolean ("is-uninitialised", false);
+ var settings = this.settings.get_child ("main-controls-pos");
+ settings.set_int ("orientation", 1);
+ settings.set_int ("margin-right", 80);
+ settings.set_int ("margin-left", 80);
+ settings.set_int ("margin-top", 65);
+ settings.set_int ("margin-bottom", -1);
+ settings.apply ();
+ settings = this.settings.get_child ("exp-pos");
+ settings.set_int ("orientation", 0);
+ settings.set_int ("margin-right", -1);
+ settings.set_int ("margin-left", 10);
+ settings.set_int ("margin-top", 65);
+ settings.set_int ("margin-bottom", 110);
+ settings.apply ();
+ settings = this.settings.get_child ("focus-pos");
+ settings.set_int ("orientation", 0);
+ settings.set_int ("margin-right", 10);
+ settings.set_int ("margin-left", -1);
+ settings.set_int ("margin-top", 65);
+ settings.set_int ("margin-bottom", 110);
+ settings.apply ();
+ this.settings.apply ();
}
}
\ No newline at end of file
diff --git a/src/gui/main_bar.blp b/src/gui/main_bar.blp
index b5e1d4b..bb0b16e 100644
--- a/src/gui/main_bar.blp
+++ b/src/gui/main_bar.blp
@@ -14,18 +14,18 @@ template $PipeTapUiMainBar: $PipeTapUiFloatingWindow {
"linked",
]
- Gtk.ToggleButton exposure {
- icon-name: "camera-iso-symbolic";
- tooltip-text: _("Exposure");
+ Gtk.ToggleButton focus {
+ icon-name: "camera-focus-symbolic";
+ tooltip-text: _("Focus");
styles [
"flat",
]
}
- Gtk.ToggleButton focus {
- icon-name: "camera-focus-symbolic";
- tooltip-text: _("Focus");
+ Gtk.ToggleButton exposure {
+ icon-name: "camera-iso-symbolic";
+ tooltip-text: _("Exposure");
styles [
"flat",
@@ -47,11 +47,6 @@ template $PipeTapUiMainBar: $PipeTapUiFloatingWindow {
menu primary_menu {
section {
- item {
- label: _("_Adjust overlays");
- action: "app.adjust-overlays";
- }
-
item {
label: _("_Preferences");
action: "app.preferences";
diff --git a/src/gui/settings.vala b/src/gui/settings.vala
new file mode 100644
index 0000000..f8910c2
--- /dev/null
+++ b/src/gui/settings.vala
@@ -0,0 +1,44 @@
+public class PipeTap.Ui.Settings : Adw.PreferencesDialog {
+
+ public Settings() {
+ var overlays = new Adw.PreferencesPage();
+ overlays.title = _("Overlays");
+ overlays.add(make_group_for("Main bar", "main-controls-pos"));
+ overlays.add(make_group_for("Exposure bar", "exp-pos"));
+ overlays.add(make_group_for("Focus bar", "focus-pos"));
+ add(overlays);
+ }
+
+ Adw.PreferencesGroup make_group_for(string name, string child_name) {
+ var group = new Adw.PreferencesGroup();
+ group.title = _(name);
+ group.description = _("Set -1 to not anchor to side");
+ var orientation = new Adw.ComboRow();
+ orientation.title = _("Orientation");
+ orientation.model = new Gtk.StringList({ _("Vertical"), _("Horizontal") });
+ var top = new Adw.SpinRow.with_range(-1, double.MAX, 1);
+ top.title = _("Top spacing");
+ var bottom = new Adw.SpinRow.with_range(-1, double.MAX, 1);
+ bottom.title = _("Bottom spacing");
+ var right = new Adw.SpinRow.with_range(-1, double.MAX, 1);
+ right.title = _("Right spacing");
+ var left = new Adw.SpinRow.with_range(-1, double.MAX, 1);
+ left.title = _("Left spacing");
+ group.add(orientation);
+ group.add(top);
+ group.add(bottom);
+ group.add(left);
+ group.add(right);
+
+
+
+ var settings = Logic.app.settings.get_child(child_name);
+ settings.bind("margin-top", top, "value", SettingsBindFlags.DEFAULT);
+ settings.bind("margin-bottom", bottom, "value", SettingsBindFlags.DEFAULT);
+ settings.bind("margin-right", right, "value", SettingsBindFlags.DEFAULT);
+ settings.bind("margin-left", left, "value", SettingsBindFlags.DEFAULT);
+ settings.bind("orientation", orientation, "selected", SettingsBindFlags.DEFAULT);
+
+ return group;
+ }
+}
\ No newline at end of file
diff --git a/src/gui/window.blp b/src/gui/window.blp
index 399ae36..d47af22 100644
--- a/src/gui/window.blp
+++ b/src/gui/window.blp
@@ -11,40 +11,10 @@ template $PipeTapUiFloatingWindow: Gtk.Window {
"osd",
]
- Box {
- orientation: bind template.orientation;
-
- Button resize {
- visible: bind template.resize-visible;
-
- styles [
- "flat",
- ]
- }
-
- Adw.Bin content_bin {
- valign: fill;
- halign: fill;
- hexpand: true;
- vexpand: true;
- }
-
- Button rotate {
- visible: bind template.rotate-visible;
- icon-name: "angled-arrows-symbolic";
-
- styles [
- "flat",
- ]
- }
-
- Button move {
- visible: bind template.move-visible;
- icon-name: "move-tool-symbolic";
-
- styles [
- "flat",
- ]
- }
+ Adw.Bin content_bin {
+ valign: fill;
+ halign: fill;
+ hexpand: true;
+ vexpand: true;
}
}
diff --git a/src/gui/window.vala b/src/gui/window.vala
index 16be825..bcd1812 100644
--- a/src/gui/window.vala
+++ b/src/gui/window.vala
@@ -25,27 +25,13 @@
[GtkTemplate (ui = "/io/gitlab/nekocwd/pipetap/gui/window.ui")]
public class PipeTap.Ui.FloatingWindow : Gtk.Window, Gtk.Orientable {
- [GtkChild]
- private unowned Gtk.Button move;
- [GtkChild]
- private unowned Gtk.Button resize;
- [GtkChild]
- private unowned Gtk.Button rotate;
[GtkChild]
private unowned Adw.Bin content_bin;
public Gtk.Orientation orientation { get; set; default = Gtk.Orientation.HORIZONTAL; }
- public bool resize_visible { get; set; }
- public bool rotate_visible { get; set; }
- public bool move_visible { get; set; }
-
public string window_name { get; set; default = ""; }
- protected double pos_sy { get; set; }
- protected double pos_sx { get; set; }
- protected double pos_ex { get; set; }
- protected double pos_ey { get; set; }
public Gtk.Widget content { get { return content_bin.get_child (); } set { content_bin.set_child (value); } }
@@ -54,69 +40,30 @@ public class PipeTap.Ui.FloatingWindow : Gtk.Window, Gtk.Orientable {
_window_name = name;
GtkLayerShell.init_for_window (this);
- var move_controller = new Gtk.GestureDrag ();
- move_controller.drag_update.connect ((ox, oy) => {
- pos_sy += (int) oy;
- pos_sx -= (int) ox;
- });
- move_controller.end.connect (move_controller.reset);
- move.add_controller (move_controller);
-
- var resize_controller = new Gtk.GestureDrag ();
- resize_controller.drag_update.connect ((ox, oy) => {
- pos_ex += (int) ox;
- pos_ey += (int) oy;
- });
- resize_controller.end.connect (resize_controller.reset);
- resize.add_controller (resize_controller);
-
- bind_property ("orientation", resize, "icon_name", GLib.BindingFlags.SYNC_CREATE, (binding, src, ref dst) => {
- dst.set_string (orientation == Gtk.Orientation.VERTICAL ? "double-ended-arrows-vertical-symbolic" : "double-ended-arrows-horizontal-symbolic");
- return true;
- });
-
- rotate.clicked.connect (() => {
- orientation = orientation == Gtk.Orientation.HORIZONTAL ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL;
- });
var positions = ((PipeTap.Application) app).settings.get_child (window_name + "-pos");
positions.bind_with_mapping ("orientation", this, "orientation", GLib.SettingsBindFlags.DEFAULT,
(value, variant) =>
- { value = variant.get_boolean () ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL; return true; },
+ { message ("%s", variant.get_type_string ()); value = variant.get_int32 () == 0 ? Gtk.Orientation.VERTICAL : Gtk.Orientation.HORIZONTAL; return true; },
(value) =>
- { return ((Gtk.Orientation) value) == Gtk.Orientation.VERTICAL; },
+ { return ((Gtk.Orientation) value) == Gtk.Orientation.VERTICAL ? 1 : 0; },
null, null
);
- positions.bind ("start-x", this, "pos-sx", GLib.SettingsBindFlags.DEFAULT);
- positions.bind ("start-y", this, "pos-sy", GLib.SettingsBindFlags.DEFAULT);
- positions.bind ("end-x", this, "pos-ex", GLib.SettingsBindFlags.DEFAULT);
- positions.bind ("end-y", this, "pos-ey", GLib.SettingsBindFlags.DEFAULT);
-
- notify["pos-sx"].connect (set_position);
- notify["pos-sy"].connect (set_position);
- notify["pos-ex"].connect (set_position);
- notify["pos-ey"].connect (set_position);
- notify["orientation"].connect (set_position);
+ positions.changed.connect (set_position);
set_position ();
-
- app.bind_property ("adjust-overlay-visible", this, "move-visible", GLib.BindingFlags.SYNC_CREATE);
- app.bind_property ("adjust-overlay-visible", this, "resize-visible", GLib.BindingFlags.SYNC_CREATE);
- app.bind_property ("adjust-overlay-visible", this, "rotate-visible", GLib.BindingFlags.SYNC_CREATE);
}
void set_position () {
- var vertical = orientation == Gtk.Orientation.VERTICAL;
- GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.TOP, true);
- GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.BOTTOM, vertical);
- GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.RIGHT, true);
- GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.LEFT, !vertical);
- var y = pos_sy;
- if (vertical)
- y = pos_ey + pos_sy;
+ var settings = Logic.app.settings.get_child (window_name + "-pos");
- GtkLayerShell.set_margin (this, GtkLayerShell.Edge.TOP, int.max ((int) y, 0));
- GtkLayerShell.set_margin (this, GtkLayerShell.Edge.RIGHT, int.max ((int) pos_sx, 0));
- GtkLayerShell.set_margin (this, GtkLayerShell.Edge.LEFT, int.max ((int) (pos_ex - pos_sx), 0));
- GtkLayerShell.set_margin (this, GtkLayerShell.Edge.BOTTOM, int.max ((int) (-pos_sy), 0));
+ GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.TOP, settings.get_int ("margin-top") != -1);
+ GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.BOTTOM, settings.get_int ("margin-bottom") != -1);
+ GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.LEFT, settings.get_int ("margin-left") != -1);
+ GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.RIGHT, settings.get_int ("margin-right") != -1);
+
+ GtkLayerShell.set_margin (this, GtkLayerShell.Edge.TOP, settings.get_int ("margin-top"));
+ GtkLayerShell.set_margin (this, GtkLayerShell.Edge.BOTTOM, settings.get_int ("margin-bottom"));
+ GtkLayerShell.set_margin (this, GtkLayerShell.Edge.LEFT, settings.get_int ("margin-left"));
+ GtkLayerShell.set_margin (this, GtkLayerShell.Edge.RIGHT, settings.get_int ("margin-right"));
}
}
\ No newline at end of file
diff --git a/src/meson.build b/src/meson.build
index 1d65c77..5eaff01 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -4,6 +4,7 @@ pipetap_sources = [
'gui/window.vala',
'gui/main_bar.vala',
'gui/slider_overlay.vala',
+ 'gui/settings.vala',
'logic/ctrl.vala',
'logic/wireplumber.vala',
]