Fixes for resizing

This commit is contained in:
Jeremy Soller 2023-10-11 19:32:04 -06:00
parent 2425c7eb49
commit c393cca602
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
4 changed files with 348 additions and 706 deletions

1038
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,9 @@ features = ["syntect"]
git = "https://github.com/pop-os/libcosmic"
branch = "theme-dark-light-switching"
default-features = false
features = ["winit"]
features = ["wayland"]
#TODO: winit does not support size limits, resizing
#features = ["winit"]
#path = "../libcosmic"
[dependencies.rfd]

View file

@ -5,7 +5,7 @@ use cosmic::{
executor,
iced::{
widget::{column, row, text},
Alignment, Length,
Alignment, Length, Limits,
},
widget::{icon, segmented_button, view_switcher},
ApplicationExt, Element,
@ -36,8 +36,8 @@ static FONT_SIZES: &'static [Metrics] = &[
fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
let settings = Settings::default();
//TODO: settings.window.min_size = Some((400, 100));
let settings = Settings::default()
.size_limits(Limits::NONE.min_width(400.0).min_height(200.0));
let flags = ();
cosmic::app::run::<App>(settings, flags)?;

View file

@ -177,7 +177,6 @@ where
let height = layout_lines as f32 * editor.buffer().metrics().line_height;
let size = Size::new(limits.max().width, height);
log::info!("size {:?}", size);
layout::Node::new(limits.resolve(size))
}
@ -244,6 +243,11 @@ where
let image_w = (view_w as f64 * scale_factor) as i32;
let image_h = (view_h as f64 * scale_factor) as i32;
if image_w <= 0 || image_h <= 0 {
// Zero sized image
return;
}
let mut font_system = FONT_SYSTEM.lock().unwrap();
let mut editor = editor.borrow_with(&mut font_system);