image: Show window after 2 secs if dims unknown
Usually we want to wait for dimensions to show the window in correct apsect ration. But especially for large SVGs dimensions are only known pretty late. Show the image to give UI feedback instead of waiting for dimensions. Closes #146 Part-of: <https://gitlab.gnome.org/Incubator/loupe/-/merge_requests/209>
This commit is contained in:
parent
6db58463bf
commit
3d6940cd45
1 changed files with 13 additions and 5 deletions
|
|
@ -38,12 +38,15 @@ use crate::config;
|
|||
use crate::util::{self, Direction, Position};
|
||||
use crate::widgets::{LpImage, LpImageView, LpPropertiesView};
|
||||
|
||||
/// Show window after X milliseconds even if image dimensions are not known yet
|
||||
const SHOW_WINDOW_AFTER: u64 = 2000;
|
||||
|
||||
/// Animation duration for showing overlay buttons in milliseconds
|
||||
const SHOW_CONTROLS_ANIMATION_DURATION: u32 = 200;
|
||||
/// Animation duration for hiding overlay buttons in milliseconds
|
||||
const HIDE_CONTROLS_ANIMATION_DURATION: u32 = 1000;
|
||||
/// Time of inactivity after which controls will be hidden in seconds
|
||||
const HIDE_CONTROLS_IDLE_TIMEOUT: u32 = 3;
|
||||
/// Time of inactivity after which controls will be hidden in milliseconds
|
||||
const HIDE_CONTROLS_IDLE_TIMEOUT: u64 = 3000;
|
||||
|
||||
mod imp {
|
||||
use super::*;
|
||||
|
|
@ -241,6 +244,11 @@ mod imp {
|
|||
// and keeps the others usable
|
||||
gtk::WindowGroup::new().add_window(&*obj);
|
||||
|
||||
glib::timeout_add_local_once(
|
||||
std::time::Duration::from_millis(SHOW_WINDOW_AFTER),
|
||||
glib::clone!(@weak obj => move || if !obj.is_visible() { obj.present() }),
|
||||
);
|
||||
|
||||
obj.on_images_available();
|
||||
|
||||
let current_image_signals = self.image_view.current_image_signals();
|
||||
|
|
@ -726,12 +734,12 @@ impl LpWindow {
|
|||
})
|
||||
}
|
||||
|
||||
/// Queue a fade animation to play after `HIDE_CONTROLS_IDLE_TIMEOUT` seconds of inactivity
|
||||
/// Queue a fade animation to play after `HIDE_CONTROLS_IDLE_TIMEOUT` of inactivity
|
||||
fn queue_hide_controls(&self) {
|
||||
self.dequeue_hide_controls();
|
||||
|
||||
let new_timeout = glib::timeout_add_seconds_local_once(
|
||||
HIDE_CONTROLS_IDLE_TIMEOUT,
|
||||
let new_timeout = glib::timeout_add_local_once(
|
||||
std::time::Duration::from_millis(HIDE_CONTROLS_IDLE_TIMEOUT),
|
||||
glib::clone!(@weak self as win => move || {
|
||||
win.imp().hide_controls_timeout.take();
|
||||
win.hide_controls();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue