window: Prefer wide window over properties overlay
This commit is contained in:
parent
e61b3357ea
commit
8ddaf34e87
4 changed files with 29 additions and 6 deletions
|
|
@ -0,0 +1 @@
|
||||||
|
Make the window wider when it would open with a bottom-sheet overlay for properties. That way, the properties can be shown in a sidebar.
|
||||||
|
|
@ -25,8 +25,7 @@ mod file;
|
||||||
mod gps;
|
mod gps;
|
||||||
|
|
||||||
pub use file::FileInfo;
|
pub use file::FileInfo;
|
||||||
use glycin::{Frame, MemoryFormat};
|
use glycin::{Frame, FrameDetails, ImageInfoDetails, MemoryFormat};
|
||||||
use glycin::{FrameDetails, ImageInfoDetails};
|
|
||||||
pub use gps::GPSLocation;
|
pub use gps::GPSLocation;
|
||||||
|
|
||||||
use crate::deps::*;
|
use crate::deps::*;
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,6 @@ impl LpImage {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn reload(&self) {
|
pub async fn reload(&self) {
|
||||||
dbg!("reloadking");
|
|
||||||
if let Some(file) = self.file() {
|
if let Some(file) = self.file() {
|
||||||
self.load(&file).await;
|
self.load(&file).await;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -780,7 +780,8 @@ impl LpWindow {
|
||||||
self.action_set_enabled(&Action::ZoomInCursor, can_zoom_in && enabled_shown);
|
self.action_set_enabled(&Action::ZoomInCursor, can_zoom_in && enabled_shown);
|
||||||
self.action_set_enabled(&Action::ZoomInCenter, can_zoom_in && enabled_shown);
|
self.action_set_enabled(&Action::ZoomInCenter, can_zoom_in && enabled_shown);
|
||||||
|
|
||||||
// Actions that are available if there is an current image, even if it's not shown
|
// Actions that are available if there is an current image, even if it's not
|
||||||
|
// shown
|
||||||
const ACTIONS_CURRENT: &[Action] = &[
|
const ACTIONS_CURRENT: &[Action] = &[
|
||||||
Action::OpenWith,
|
Action::OpenWith,
|
||||||
Action::CopyImage,
|
Action::CopyImage,
|
||||||
|
|
@ -894,13 +895,36 @@ impl LpWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resize_default(&self) {
|
pub fn resize_default(&self) {
|
||||||
|
let imp = self.imp();
|
||||||
|
|
||||||
if self
|
if self
|
||||||
.image_view()
|
.image_view()
|
||||||
.current_image()
|
.current_image()
|
||||||
.is_some_and(|img| img.image_size_available())
|
.is_some_and(|img| img.image_size_available())
|
||||||
{
|
{
|
||||||
// this let's the window determine the default size from LpImage's natural size
|
let shows_properties = imp.properties_button.is_active();
|
||||||
self.set_default_size(-1, -1);
|
|
||||||
|
let (_, window_natural_width, _, _) = self.measure(gtk::Orientation::Horizontal, -1);
|
||||||
|
let (_, window_natural_height, _, _) = self.measure(gtk::Orientation::Vertical, -1);
|
||||||
|
|
||||||
|
// These have to be in sync with the "conditions" for the "overlay-properties"
|
||||||
|
// breakpoint
|
||||||
|
let min_width_for_overlay = adw::LengthUnit::Sp.to_px(590., None).ceil() as i32;
|
||||||
|
let min_height_for_overlay = adw::LengthUnit::Sp.to_px(550., None).ceil() as i32;
|
||||||
|
|
||||||
|
let (width, height) = if shows_properties
|
||||||
|
&& window_natural_width < min_width_for_overlay
|
||||||
|
&& window_natural_height < min_height_for_overlay
|
||||||
|
{
|
||||||
|
// Avoid overlaying bottom sheet being triggered for the image properties by
|
||||||
|
// using a window wide enough to allow for a sidebar
|
||||||
|
(min_width_for_overlay.saturating_add(1), -1)
|
||||||
|
} else {
|
||||||
|
// this lets the window determine the default size from LpImage's natural size
|
||||||
|
(-1, -1)
|
||||||
|
};
|
||||||
|
|
||||||
|
self.set_default_size(width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue