Skip to content

Commit c2da2a8

Browse files
committed
Add more keybinds
1 parent 50bb5b3 commit c2da2a8

File tree

2 files changed

+45
-11
lines changed

2 files changed

+45
-11
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ See the settings panel in the UI for a list of configuration.
2424

2525
Binding | Action
2626
-:|:-
27-
Right Arrow | Go to next
28-
Left Arrow | Go to previous
29-
Ctrl-Shift-I | Toggle internal state window
27+
Right Arrow, n | Go to next
28+
Left Arrow, p, Shift-n | Go to previous
29+
Ctrl-Shift-i | Toggle internal state window
30+
c | Toggle settings
31+
f | Toggle fullscreen
32+
i | Toggle info panel
33+
s | Toggle slideshow
34+
35+
The bindings that move between images normally respect slideshows, i.e., if there is an active slideshow and shuffle is enabled, the keys will move with the same randomness. To override this, use Alt.
3036

3137
## License
3238

src/app/mod.rs

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,28 @@ impl SlideshowState {
6161
*self = Self::Inactive;
6262
}
6363

64+
fn set_active(&mut self, active: bool, config: &Config) {
65+
if active {
66+
self.start(config);
67+
} else {
68+
self.stop();
69+
}
70+
}
71+
72+
fn toggle(&mut self, config: &Config) {
73+
self.set_active(!self.is_active(), config);
74+
}
75+
6476
fn show_toggle(&mut self, ui: &mut egui::Ui, config: &Config) {
6577
let mut slideshow_active = self.is_active();
6678
let icon = if slideshow_active { "⏸" } else { "▶" };
67-
let changed = ui.toggle_value(&mut slideshow_active, icon).changed();
79+
let changed = ui
80+
.toggle_value(&mut slideshow_active, icon)
81+
.on_hover_text("Toggle slideshow (s)")
82+
.changed();
6883

6984
if changed {
70-
if slideshow_active {
71-
self.start(config);
72-
} else {
73-
self.stop();
74-
}
85+
self.set_active(slideshow_active, config);
7586
}
7687
}
7788
}
@@ -201,7 +212,7 @@ fn show_fullscreen_toggle(ui: &mut egui::Ui, frame: &mut eframe::Frame) {
201212
let mut fullscreen = frame.info().window_info.fullscreen;
202213
if ui
203214
.toggle_value(&mut fullscreen, "⛶")
204-
.on_hover_text("Toggle fullscreen")
215+
.on_hover_text("Toggle fullscreen (f)")
205216
.changed()
206217
{
207218
frame.set_fullscreen(fullscreen);
@@ -572,7 +583,7 @@ impl App {
572583
}
573584
}
574585

575-
fn handle_global_keys(&mut self, ctx: &Context, _frame: &mut eframe::Frame) {
586+
fn handle_global_keys(&mut self, ctx: &Context, frame: &mut eframe::Frame) {
576587
use egui::Key;
577588

578589
const KEYS: &[(Key, Modifiers, Direction)] = &[
@@ -603,6 +614,23 @@ impl App {
603614
self.internal_open = !self.internal_open;
604615
}
605616

617+
let key = |key| ctx.input_mut(|input| input.consume_key(Modifiers::NONE, key));
618+
619+
if key(Key::S) {
620+
self.slideshow.toggle(&self.config);
621+
}
622+
623+
if key(Key::F) {
624+
frame.set_fullscreen(!frame.info().window_info.fullscreen);
625+
}
626+
627+
if key(Key::I) {
628+
self.config.show_sidebar ^= true;
629+
}
630+
631+
if key(Key::C) {
632+
self.settings_open ^= true;
633+
}
606634
}
607635

608636
fn handle_actor_responses(&mut self) {

0 commit comments

Comments
 (0)