Skip to content

Commit

Permalink
Make it possible to set Glium windows as not resizable. (emilk#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
phoglund authored Dec 22, 2020
1 parent dbab277 commit bb469bf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions egui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ pub trait App {
/// Optional.
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.
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
fn ui(&mut self, ctx: &crate::CtxRef, integration_context: &mut IntegrationContext<'_>);
Expand Down
1 change: 1 addition & 0 deletions egui_glium/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added

* `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

Expand Down
5 changes: 3 additions & 2 deletions egui_glium/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ impl egui::app::RepaintSignal for GliumRepaintSignal {
fn create_display(
title: &str,
window_settings: Option<WindowSettings>,
is_resizable: bool,
event_loop: &glutin::event_loop::EventLoop<RequestRepaintEvent>,
) -> glium::Display {
let mut window_builder = glutin::window::WindowBuilder::new()
.with_decorations(true)
.with_resizable(true)
.with_resizable(is_resizable)
.with_title(title)
.with_transparent(false);

Expand Down Expand Up @@ -102,7 +103,7 @@ pub fn run(mut app: Box<dyn App>) -> ! {
.as_mut()
.and_then(|storage| egui::app::get_value(storage.as_ref(), WINDOW_KEY));
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()));

Expand Down

0 comments on commit bb469bf

Please sign in to comment.