Make it possible to set Glium windows as not resizable. (#69)

This commit is contained in:
Patrik Höglund 2020-12-22 15:20:38 +01:00 committed by GitHub
parent dbab277658
commit bb469bf52f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View file

@ -38,6 +38,11 @@ pub trait App {
/// Optional. /// Optional.
fn setup(&mut self, _ctx: &crate::CtxRef) {} fn setup(&mut self, _ctx: &crate::CtxRef) {}
/// Returns true if this app window should be resizable.
fn is_resizable(&self) -> bool {
true
}
/// Called each time the UI needs repainting, which may be many times per second. /// Called each time the UI needs repainting, which may be many times per second.
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`. /// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
fn ui(&mut self, ctx: &crate::CtxRef, integration_context: &mut IntegrationContext<'_>); fn ui(&mut self, ctx: &crate::CtxRef, integration_context: &mut IntegrationContext<'_>);

View file

@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added ### Added
* `egui_glium` will auto-save your app state every 30 seconds. * `egui_glium` will auto-save your app state every 30 seconds.
* `egui_glium` can now set windows as fixed size (e.g. the user can't resize the window). See `egui::App::is_resizable()`.
### Changed ### Changed

View file

@ -42,11 +42,12 @@ impl egui::app::RepaintSignal for GliumRepaintSignal {
fn create_display( fn create_display(
title: &str, title: &str,
window_settings: Option<WindowSettings>, window_settings: Option<WindowSettings>,
is_resizable: bool,
event_loop: &glutin::event_loop::EventLoop<RequestRepaintEvent>, event_loop: &glutin::event_loop::EventLoop<RequestRepaintEvent>,
) -> glium::Display { ) -> glium::Display {
let mut window_builder = glutin::window::WindowBuilder::new() let mut window_builder = glutin::window::WindowBuilder::new()
.with_decorations(true) .with_decorations(true)
.with_resizable(true) .with_resizable(is_resizable)
.with_title(title) .with_title(title)
.with_transparent(false); .with_transparent(false);
@ -102,7 +103,7 @@ pub fn run(mut app: Box<dyn App>) -> ! {
.as_mut() .as_mut()
.and_then(|storage| egui::app::get_value(storage.as_ref(), WINDOW_KEY)); .and_then(|storage| egui::app::get_value(storage.as_ref(), WINDOW_KEY));
let event_loop = glutin::event_loop::EventLoop::with_user_event(); let event_loop = glutin::event_loop::EventLoop::with_user_event();
let display = create_display(app.name(), window_settings, &event_loop); let display = create_display(app.name(), window_settings, app.is_resizable(), &event_loop);
let repaint_signal = std::sync::Arc::new(GliumRepaintSignal(event_loop.create_proxy())); let repaint_signal = std::sync::Arc::new(GliumRepaintSignal(event_loop.create_proxy()));