Add AutoFocus trigger
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
b06537620d
commit
d15c1a4e14
4 changed files with 82 additions and 47 deletions
|
@ -64,7 +64,7 @@ public class PipeTap.Application : Adw.Application {
|
|||
if (exposure == null)
|
||||
exposure = new Ui.SliderOverlay (this, Logic.Ctrl.CtrlType.Exposure, Logic.Ctrl.CtrlType.ExposureEnable, "exp", "camera-iso-symbolic");
|
||||
if (focus == null)
|
||||
focus = new Ui.SliderOverlay (this, Logic.Ctrl.CtrlType.Focus, Logic.Ctrl.CtrlType.AutoFocusEnable, "focus", "camera-focus-symbolic");
|
||||
focus = new Ui.SliderOverlay (this, Logic.Ctrl.CtrlType.Focus, Logic.Ctrl.CtrlType.AutoFocusEnable, "focus", "camera-focus-symbolic", false);
|
||||
if (contrast == null)
|
||||
contrast = new Ui.SliderOverlay (this, Logic.Ctrl.CtrlType.Contrast, Logic.Ctrl.CtrlType.ContrastEnable, "contrast", "color-symbolic");
|
||||
if (main_bar == null)
|
||||
|
|
|
@ -1,46 +1,58 @@
|
|||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $PipeTapUiSliderOverlay: $PipeTapUiFloatingWindow {
|
||||
title: _("PipeTap Slider");
|
||||
title: _("PipeTap Slider");
|
||||
|
||||
content: Gtk.Box content_box {
|
||||
orientation: bind template.orientation;
|
||||
halign: fill;
|
||||
spacing: 10;
|
||||
content: Gtk.Box content_box {
|
||||
orientation: bind template.orientation;
|
||||
halign: fill;
|
||||
spacing: 10;
|
||||
|
||||
Separator spacer {
|
||||
styles [
|
||||
"spacer",
|
||||
]
|
||||
}
|
||||
Separator spacer {
|
||||
styles [
|
||||
"spacer",
|
||||
]
|
||||
}
|
||||
|
||||
Scale scale {
|
||||
orientation: bind template.orientation;
|
||||
vexpand: true;
|
||||
hexpand: true;
|
||||
halign: fill;
|
||||
valign: fill;
|
||||
Scale scale {
|
||||
orientation: bind template.orientation;
|
||||
vexpand: true;
|
||||
hexpand: true;
|
||||
halign: fill;
|
||||
valign: fill;
|
||||
|
||||
adjustment: Adjustment {
|
||||
lower: 0;
|
||||
upper: 1000;
|
||||
step-increment: 1;
|
||||
value: 500;
|
||||
};
|
||||
adjustment: Adjustment {
|
||||
lower: 0;
|
||||
upper: 1000;
|
||||
step-increment: 1;
|
||||
value: 500;
|
||||
};
|
||||
|
||||
styles [
|
||||
"pt-slider",
|
||||
]
|
||||
}
|
||||
styles [
|
||||
"pt-slider",
|
||||
]
|
||||
}
|
||||
|
||||
Gtk.ToggleButton lock_btn {
|
||||
icon-name: "camera-iso-symbolic";
|
||||
tooltip-text: _("Lock");
|
||||
Gtk.ToggleButton toggle_btn {
|
||||
icon-name: bind template.icon;
|
||||
tooltip-text: _("Lock");
|
||||
visible: bind template.is_toggle;
|
||||
sensitive: bind template.is_btn_available;
|
||||
|
||||
styles [
|
||||
"flat",
|
||||
]
|
||||
}
|
||||
};
|
||||
styles [
|
||||
"flat",
|
||||
]
|
||||
}
|
||||
|
||||
Gtk.ToggleButton press_btn {
|
||||
icon-name: bind template.icon;
|
||||
tooltip-text: _("Start");
|
||||
visible: bind template.is_toggle inverted;
|
||||
sensitive: bind template.is_btn_available;
|
||||
|
||||
styles [
|
||||
"flat",
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,21 +3,27 @@ public class PipeTap.Ui.SliderOverlay : PipeTap.Ui.FloatingWindow {
|
|||
[GtkChild]
|
||||
private unowned Gtk.Scale scale;
|
||||
[GtkChild]
|
||||
private unowned Gtk.ToggleButton lock_btn;
|
||||
|
||||
private unowned Gtk.ToggleButton toggle_btn;
|
||||
[GtkChild]
|
||||
private unowned Gtk.Button press_btn;
|
||||
|
||||
public Logic.Ctrl.CtrlType slider_type { get; set; }
|
||||
public Logic.Ctrl.CtrlType? toggle_type { get; set; }
|
||||
public bool is_available { get; protected set; }
|
||||
public bool is_toggle { get; protected set; }
|
||||
public string icon { get; set; }
|
||||
public bool is_btn_available { get; protected set; }
|
||||
|
||||
public SliderOverlay(PipeTap.Application app, Logic.Ctrl.CtrlType slider_type, Logic.Ctrl.CtrlType toggle_type, string name, string icon_name) {
|
||||
public SliderOverlay(PipeTap.Application app, Logic.Ctrl.CtrlType slider_type, Logic.Ctrl.CtrlType toggle_type, string name, string icon_name, bool is_toggle = true) {
|
||||
base(app, name);
|
||||
this.slider_type = slider_type;
|
||||
this.toggle_type = toggle_type;
|
||||
this.is_toggle = is_toggle;
|
||||
scale.value_changed.connect(value_changed);
|
||||
lock_btn.toggled.connect(lock_changed);
|
||||
toggle_btn.toggled.connect(lock_changed);
|
||||
press_btn.clicked.connect(lock_changed);
|
||||
app.notify["device"].connect(set_ctrls);
|
||||
lock_btn.icon_name = icon_name;
|
||||
this.icon = icon_name;
|
||||
set_ctrls();
|
||||
}
|
||||
|
||||
|
@ -25,12 +31,12 @@ public class PipeTap.Ui.SliderOverlay : PipeTap.Ui.FloatingWindow {
|
|||
var slider_ctrl = Logic.find_ctrl(slider_type);
|
||||
var lock_ctrl = Logic.find_ctrl(toggle_type);
|
||||
scale.sensitive = slider_ctrl != null;
|
||||
lock_btn.sensitive = lock_ctrl != null;
|
||||
is_btn_available = lock_ctrl != null;
|
||||
is_available = slider_ctrl != null || lock_ctrl != null;
|
||||
if (slider_ctrl != null)
|
||||
scale.set_value(slider_ctrl.value);
|
||||
if (lock_ctrl != null)
|
||||
lock_btn.active = lock_ctrl.value == 1;
|
||||
toggle_btn.active = lock_ctrl.value == 1;
|
||||
}
|
||||
|
||||
void value_changed() {
|
||||
|
@ -44,12 +50,15 @@ public class PipeTap.Ui.SliderOverlay : PipeTap.Ui.FloatingWindow {
|
|||
}
|
||||
|
||||
void lock_changed() {
|
||||
message("Lock %s", lock_btn.active ? "on" : "off");
|
||||
var ctrl = Logic.find_ctrl(toggle_type);
|
||||
if (ctrl == null) {
|
||||
message("Toggle ctrl not found");
|
||||
return;
|
||||
}
|
||||
ctrl.value = (int) lock_btn.active;
|
||||
if (!is_toggle) {
|
||||
ctrl.value = 1;
|
||||
return;
|
||||
}
|
||||
ctrl.value = (int) toggle_btn.active;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,11 @@ namespace PipeTap.Logic.WirePlumber {
|
|||
message("Sending bool %s", adjusted ? "true" : "false");
|
||||
pb.add_boolean(adjusted);
|
||||
break;
|
||||
case "int":
|
||||
var adjusted = value;
|
||||
message("Sending int %f", (int) adjusted);
|
||||
pb.add_int((int) adjusted);
|
||||
break;
|
||||
default:
|
||||
message("Unknown type %s", wp_type);
|
||||
break;
|
||||
|
@ -154,6 +159,15 @@ namespace PipeTap.Logic.WirePlumber {
|
|||
var ctrl = new Ctrl(Logic.Ctrl.CtrlType.Contrast, node, id, type, 0, 2, 1);
|
||||
found_ctrls.append(ctrl);
|
||||
break;
|
||||
case "AfTrigger":
|
||||
if (type != "int") {
|
||||
warning("Wrong type");
|
||||
break;
|
||||
}
|
||||
message("Found AF Trigger");
|
||||
var ctrl = new Ctrl(Logic.Ctrl.CtrlType.AutoFocusEnable, node, id, type, 0, 1, 0);
|
||||
found_ctrls.append(ctrl);
|
||||
break;
|
||||
default:
|
||||
message("Unknown ctrl %s of %s", description, type);
|
||||
break;
|
||||
|
@ -177,4 +191,4 @@ namespace PipeTap.Logic.WirePlumber {
|
|||
core = new Wp.Core(null, null, null);
|
||||
core.activate.begin(Wp.CoreFeatures.CONNECTED, null, init_manager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue