parent
0d74083cf8
commit
4eb8b939b3
5 changed files with 92 additions and 2 deletions
|
|
@ -156,6 +156,35 @@
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkShortcutsGroup">
|
||||||
|
<property name="title" translatable="yes" context="shortcut window">Pan View</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkShortcutsShortcut">
|
||||||
|
<property name="title" translatable="yes" context="shortcut window">Pan Left</property>
|
||||||
|
<property name="action-name">win.pan-left</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkShortcutsShortcut">
|
||||||
|
<property name="title" translatable="yes" context="shortcut window">Pan Right</property>
|
||||||
|
<property name="action-name">win.pan-right</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkShortcutsShortcut">
|
||||||
|
<property name="title" translatable="yes" context="shortcut window">Pan Up</property>
|
||||||
|
<property name="action-name">win.pan-up</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkShortcutsShortcut">
|
||||||
|
<property name="title" translatable="yes" context="shortcut window">Pan Down</property>
|
||||||
|
<property name="action-name">win.pan-down</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkShortcutsGroup">
|
<object class="GtkShortcutsGroup">
|
||||||
<property name="title" translatable="yes" context="shortcut window">Gestures</property>
|
<property name="title" translatable="yes" context="shortcut window">Gestures</property>
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,12 @@ impl LpApplication {
|
||||||
"win.zoom-out",
|
"win.zoom-out",
|
||||||
&["<Ctrl>minus", "minus", "<Ctrl>KP_Subtract", "KP_Subtract"],
|
&["<Ctrl>minus", "minus", "<Ctrl>KP_Subtract", "KP_Subtract"],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
self.set_accels_for_action("win.pan-left", &["<Ctrl>Left"]);
|
||||||
|
self.set_accels_for_action("win.pan-right", &["<Ctrl>Right"]);
|
||||||
|
self.set_accels_for_action("win.pan-up", &["<Ctrl>Up"]);
|
||||||
|
self.set_accels_for_action("win.pan-down", &["<Ctrl>Down"]);
|
||||||
|
|
||||||
self.set_accels_for_action("win.rotate(90.0)", &["<Ctrl>R"]);
|
self.set_accels_for_action("win.rotate(90.0)", &["<Ctrl>R"]);
|
||||||
self.set_accels_for_action("win.rotate(-90.0)", &["<Ctrl><Shift>R"]);
|
self.set_accels_for_action("win.rotate(-90.0)", &["<Ctrl><Shift>R"]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1053,6 +1053,35 @@ impl LpImage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stepwise scrolls inside an image when zoomed in
|
||||||
|
pub fn pan(&self, direction: >k::PanDirection) {
|
||||||
|
let sign = match direction {
|
||||||
|
gtk::PanDirection::Left | gtk::PanDirection::Up => -1.,
|
||||||
|
gtk::PanDirection::Right | gtk::PanDirection::Down => 1.,
|
||||||
|
_ => {
|
||||||
|
log::error!("Unkown pan direction {direction:?}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let (adjustment, max) = match direction {
|
||||||
|
gtk::PanDirection::Left | gtk::PanDirection::Right => {
|
||||||
|
(self.hadjustment(), self.max_hadjustment_value())
|
||||||
|
}
|
||||||
|
gtk::PanDirection::Up | gtk::PanDirection::Down => {
|
||||||
|
(self.vadjustment(), self.max_vadjustment_value())
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
log::error!("Unkown pan direction {direction:?}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let value = (adjustment.value() + sign * adjustment.step_increment()).clamp(0., max);
|
||||||
|
|
||||||
|
adjustment.set_value(value);
|
||||||
|
}
|
||||||
|
|
||||||
fn hadjustment(&self) -> gtk::Adjustment {
|
fn hadjustment(&self) -> gtk::Adjustment {
|
||||||
if let Some(adj) = self.imp().hadjustment.borrow().as_ref() {
|
if let Some(adj) = self.imp().hadjustment.borrow().as_ref() {
|
||||||
adj.clone()
|
adj.clone()
|
||||||
|
|
@ -1109,7 +1138,7 @@ impl LpImage {
|
||||||
0.,
|
0.,
|
||||||
// upper
|
// upper
|
||||||
content_width,
|
content_width,
|
||||||
// arrow button step (probably irrelevant)
|
// arrow button and shortcut step
|
||||||
widget_width * 0.1,
|
widget_width * 0.1,
|
||||||
// page up/down step
|
// page up/down step
|
||||||
widget_width * 0.9,
|
widget_width * 0.9,
|
||||||
|
|
@ -1128,7 +1157,7 @@ impl LpImage {
|
||||||
0.,
|
0.,
|
||||||
// upper
|
// upper
|
||||||
content_height,
|
content_height,
|
||||||
// arrow button step (probably irrelevant)
|
// arrow button and shortcut step
|
||||||
widget_height * 0.1,
|
widget_height * 0.1,
|
||||||
// page up/down step
|
// page up/down step
|
||||||
widget_height * 0.9,
|
widget_height * 0.9,
|
||||||
|
|
|
||||||
|
|
@ -408,6 +408,10 @@ impl LpImageView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn current_image(&self) -> Option<LpImage> {
|
||||||
|
self.imp().sliding_view.current_page().map(|x| x.image())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn current_page(&self) -> Option<LpImagePage> {
|
pub fn current_page(&self) -> Option<LpImagePage> {
|
||||||
self.imp().sliding_view.current_page()
|
self.imp().sliding_view.current_page()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,22 @@ mod imp {
|
||||||
win.zoom_best_fit();
|
win.zoom_best_fit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
klass.install_action("win.pan-up", None, move |win, _, _| {
|
||||||
|
win.pan(>k::PanDirection::Up);
|
||||||
|
});
|
||||||
|
|
||||||
|
klass.install_action("win.pan-down", None, move |win, _, _| {
|
||||||
|
win.pan(>k::PanDirection::Down);
|
||||||
|
});
|
||||||
|
|
||||||
|
klass.install_action("win.pan-left", None, move |win, _, _| {
|
||||||
|
win.pan(>k::PanDirection::Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
klass.install_action("win.pan-right", None, move |win, _, _| {
|
||||||
|
win.pan(>k::PanDirection::Right);
|
||||||
|
});
|
||||||
|
|
||||||
klass.install_action("win.leave-fullscreen", None, move |win, _, _| {
|
klass.install_action("win.leave-fullscreen", None, move |win, _, _| {
|
||||||
win.toggle_fullscreen(false);
|
win.toggle_fullscreen(false);
|
||||||
});
|
});
|
||||||
|
|
@ -367,6 +383,12 @@ impl LpWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn pan(&self, direction: >k::PanDirection) {
|
||||||
|
if let Some(image) = self.imp().image_view.current_image() {
|
||||||
|
image.pan(direction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async fn pick_file(&self) {
|
async fn pick_file(&self) {
|
||||||
let filter_store = gio::ListStore::new(gtk::FileFilter::static_type());
|
let filter_store = gio::ListStore::new(gtk::FileFilter::static_type());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue