Fixes for resizing
This commit is contained in:
parent
2425c7eb49
commit
c393cca602
4 changed files with 348 additions and 706 deletions
1038
Cargo.lock
generated
1038
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -19,7 +19,9 @@ features = ["syntect"]
|
||||||
git = "https://github.com/pop-os/libcosmic"
|
git = "https://github.com/pop-os/libcosmic"
|
||||||
branch = "theme-dark-light-switching"
|
branch = "theme-dark-light-switching"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["winit"]
|
features = ["wayland"]
|
||||||
|
#TODO: winit does not support size limits, resizing
|
||||||
|
#features = ["winit"]
|
||||||
#path = "../libcosmic"
|
#path = "../libcosmic"
|
||||||
|
|
||||||
[dependencies.rfd]
|
[dependencies.rfd]
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use cosmic::{
|
||||||
executor,
|
executor,
|
||||||
iced::{
|
iced::{
|
||||||
widget::{column, row, text},
|
widget::{column, row, text},
|
||||||
Alignment, Length,
|
Alignment, Length, Limits,
|
||||||
},
|
},
|
||||||
widget::{icon, segmented_button, view_switcher},
|
widget::{icon, segmented_button, view_switcher},
|
||||||
ApplicationExt, Element,
|
ApplicationExt, Element,
|
||||||
|
|
@ -36,8 +36,8 @@ static FONT_SIZES: &'static [Metrics] = &[
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
|
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
|
||||||
|
|
||||||
let settings = Settings::default();
|
let settings = Settings::default()
|
||||||
//TODO: settings.window.min_size = Some((400, 100));
|
.size_limits(Limits::NONE.min_width(400.0).min_height(200.0));
|
||||||
let flags = ();
|
let flags = ();
|
||||||
cosmic::app::run::<App>(settings, flags)?;
|
cosmic::app::run::<App>(settings, flags)?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,6 @@ where
|
||||||
|
|
||||||
let height = layout_lines as f32 * editor.buffer().metrics().line_height;
|
let height = layout_lines as f32 * editor.buffer().metrics().line_height;
|
||||||
let size = Size::new(limits.max().width, height);
|
let size = Size::new(limits.max().width, height);
|
||||||
log::info!("size {:?}", size);
|
|
||||||
|
|
||||||
layout::Node::new(limits.resolve(size))
|
layout::Node::new(limits.resolve(size))
|
||||||
}
|
}
|
||||||
|
|
@ -245,6 +244,11 @@ where
|
||||||
let image_w = (view_w as f64 * scale_factor) as i32;
|
let image_w = (view_w as f64 * scale_factor) as i32;
|
||||||
let image_h = (view_h 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 font_system = FONT_SYSTEM.lock().unwrap();
|
||||||
let mut editor = editor.borrow_with(&mut font_system);
|
let mut editor = editor.borrow_with(&mut font_system);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue