parent
0d74083cf8
commit
4eb8b939b3
5 changed files with 92 additions and 2 deletions
|
|
@ -195,6 +195,12 @@ impl LpApplication {
|
|||
"win.zoom-out",
|
||||
&["<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><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 {
|
||||
if let Some(adj) = self.imp().hadjustment.borrow().as_ref() {
|
||||
adj.clone()
|
||||
|
|
@ -1109,7 +1138,7 @@ impl LpImage {
|
|||
0.,
|
||||
// upper
|
||||
content_width,
|
||||
// arrow button step (probably irrelevant)
|
||||
// arrow button and shortcut step
|
||||
widget_width * 0.1,
|
||||
// page up/down step
|
||||
widget_width * 0.9,
|
||||
|
|
@ -1128,7 +1157,7 @@ impl LpImage {
|
|||
0.,
|
||||
// upper
|
||||
content_height,
|
||||
// arrow button step (probably irrelevant)
|
||||
// arrow button and shortcut step
|
||||
widget_height * 0.1,
|
||||
// page up/down step
|
||||
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> {
|
||||
self.imp().sliding_view.current_page()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,6 +125,22 @@ mod imp {
|
|||
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, _, _| {
|
||||
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) {
|
||||
let filter_store = gio::ListStore::new(gtk::FileFilter::static_type());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue