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)
|
if (exposure == null)
|
||||||
exposure = new Ui.SliderOverlay (this, Logic.Ctrl.CtrlType.Exposure, Logic.Ctrl.CtrlType.ExposureEnable, "exp", "camera-iso-symbolic");
|
exposure = new Ui.SliderOverlay (this, Logic.Ctrl.CtrlType.Exposure, Logic.Ctrl.CtrlType.ExposureEnable, "exp", "camera-iso-symbolic");
|
||||||
if (focus == null)
|
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)
|
if (contrast == null)
|
||||||
contrast = new Ui.SliderOverlay (this, Logic.Ctrl.CtrlType.Contrast, Logic.Ctrl.CtrlType.ContrastEnable, "contrast", "color-symbolic");
|
contrast = new Ui.SliderOverlay (this, Logic.Ctrl.CtrlType.Contrast, Logic.Ctrl.CtrlType.ContrastEnable, "contrast", "color-symbolic");
|
||||||
if (main_bar == null)
|
if (main_bar == null)
|
||||||
|
|
|
@ -1,46 +1,58 @@
|
||||||
using Gtk 4.0;
|
using Gtk 4.0;
|
||||||
using Adw 1;
|
|
||||||
|
|
||||||
template $PipeTapUiSliderOverlay: $PipeTapUiFloatingWindow {
|
template $PipeTapUiSliderOverlay: $PipeTapUiFloatingWindow {
|
||||||
title: _("PipeTap Slider");
|
title: _("PipeTap Slider");
|
||||||
|
|
||||||
content: Gtk.Box content_box {
|
content: Gtk.Box content_box {
|
||||||
orientation: bind template.orientation;
|
orientation: bind template.orientation;
|
||||||
halign: fill;
|
halign: fill;
|
||||||
spacing: 10;
|
spacing: 10;
|
||||||
|
|
||||||
Separator spacer {
|
Separator spacer {
|
||||||
styles [
|
styles [
|
||||||
"spacer",
|
"spacer",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
Scale scale {
|
Scale scale {
|
||||||
orientation: bind template.orientation;
|
orientation: bind template.orientation;
|
||||||
vexpand: true;
|
vexpand: true;
|
||||||
hexpand: true;
|
hexpand: true;
|
||||||
halign: fill;
|
halign: fill;
|
||||||
valign: fill;
|
valign: fill;
|
||||||
|
|
||||||
adjustment: Adjustment {
|
adjustment: Adjustment {
|
||||||
lower: 0;
|
lower: 0;
|
||||||
upper: 1000;
|
upper: 1000;
|
||||||
step-increment: 1;
|
step-increment: 1;
|
||||||
value: 500;
|
value: 500;
|
||||||
};
|
};
|
||||||
|
|
||||||
styles [
|
styles [
|
||||||
"pt-slider",
|
"pt-slider",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk.ToggleButton lock_btn {
|
Gtk.ToggleButton toggle_btn {
|
||||||
icon-name: "camera-iso-symbolic";
|
icon-name: bind template.icon;
|
||||||
tooltip-text: _("Lock");
|
tooltip-text: _("Lock");
|
||||||
|
visible: bind template.is_toggle;
|
||||||
|
sensitive: bind template.is_btn_available;
|
||||||
|
|
||||||
styles [
|
styles [
|
||||||
"flat",
|
"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]
|
[GtkChild]
|
||||||
private unowned Gtk.Scale scale;
|
private unowned Gtk.Scale scale;
|
||||||
[GtkChild]
|
[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 slider_type { get; set; }
|
||||||
public Logic.Ctrl.CtrlType? toggle_type { get; set; }
|
public Logic.Ctrl.CtrlType? toggle_type { get; set; }
|
||||||
public bool is_available { get; protected 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);
|
base(app, name);
|
||||||
this.slider_type = slider_type;
|
this.slider_type = slider_type;
|
||||||
this.toggle_type = toggle_type;
|
this.toggle_type = toggle_type;
|
||||||
|
this.is_toggle = is_toggle;
|
||||||
scale.value_changed.connect(value_changed);
|
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);
|
app.notify["device"].connect(set_ctrls);
|
||||||
lock_btn.icon_name = icon_name;
|
this.icon = icon_name;
|
||||||
set_ctrls();
|
set_ctrls();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,12 +31,12 @@ public class PipeTap.Ui.SliderOverlay : PipeTap.Ui.FloatingWindow {
|
||||||
var slider_ctrl = Logic.find_ctrl(slider_type);
|
var slider_ctrl = Logic.find_ctrl(slider_type);
|
||||||
var lock_ctrl = Logic.find_ctrl(toggle_type);
|
var lock_ctrl = Logic.find_ctrl(toggle_type);
|
||||||
scale.sensitive = slider_ctrl != null;
|
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;
|
is_available = slider_ctrl != null || lock_ctrl != null;
|
||||||
if (slider_ctrl != null)
|
if (slider_ctrl != null)
|
||||||
scale.set_value(slider_ctrl.value);
|
scale.set_value(slider_ctrl.value);
|
||||||
if (lock_ctrl != null)
|
if (lock_ctrl != null)
|
||||||
lock_btn.active = lock_ctrl.value == 1;
|
toggle_btn.active = lock_ctrl.value == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void value_changed() {
|
void value_changed() {
|
||||||
|
@ -44,12 +50,15 @@ public class PipeTap.Ui.SliderOverlay : PipeTap.Ui.FloatingWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
void lock_changed() {
|
void lock_changed() {
|
||||||
message("Lock %s", lock_btn.active ? "on" : "off");
|
|
||||||
var ctrl = Logic.find_ctrl(toggle_type);
|
var ctrl = Logic.find_ctrl(toggle_type);
|
||||||
if (ctrl == null) {
|
if (ctrl == null) {
|
||||||
message("Toggle ctrl not found");
|
message("Toggle ctrl not found");
|
||||||
return;
|
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");
|
message("Sending bool %s", adjusted ? "true" : "false");
|
||||||
pb.add_boolean(adjusted);
|
pb.add_boolean(adjusted);
|
||||||
break;
|
break;
|
||||||
|
case "int":
|
||||||
|
var adjusted = value;
|
||||||
|
message("Sending int %f", (int) adjusted);
|
||||||
|
pb.add_int((int) adjusted);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
message("Unknown type %s", wp_type);
|
message("Unknown type %s", wp_type);
|
||||||
break;
|
break;
|
||||||
|
@ -154,6 +159,15 @@ namespace PipeTap.Logic.WirePlumber {
|
||||||
var ctrl = new Ctrl(Logic.Ctrl.CtrlType.Contrast, node, id, type, 0, 2, 1);
|
var ctrl = new Ctrl(Logic.Ctrl.CtrlType.Contrast, node, id, type, 0, 2, 1);
|
||||||
found_ctrls.append(ctrl);
|
found_ctrls.append(ctrl);
|
||||||
break;
|
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:
|
default:
|
||||||
message("Unknown ctrl %s of %s", description, type);
|
message("Unknown ctrl %s of %s", description, type);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue