summaryrefslogtreecommitdiff
path: root/src/window_controller.rs
diff options
context:
space:
mode:
authorBen Bridle <bridle.benjamin@gmail.com>2023-10-11 08:21:10 +1300
committerBen Bridle <bridle.benjamin@gmail.com>2023-10-11 08:21:10 +1300
commit8e08d723ff7a853f2b10dc0f1408911d5801cea8 (patch)
tree50efd2967e93f8bc1009f242a405ec18335f0aa6 /src/window_controller.rs
parenta6e97019bd53e4478c846f8f636c18ecb53bece2 (diff)
downloadphosphor-8e08d723ff7a853f2b10dc0f1408911d5801cea8.zip
Rewrite phosphor
This has been a long-awaited task, the code has been accumulating small changes for a while now. This commit consolidates all these changes in order to make the code more readable and maintainable for the future. Notable changes: - Remove the concept of a ProgramController - Remove all of the dead OpenGL stub code - Update winit to version 28.1, from 27.4 - Use softbuffer for writing pixels to the native display server
Diffstat (limited to 'src/window_controller.rs')
-rw-r--r--src/window_controller.rs56
1 files changed, 29 insertions, 27 deletions
diff --git a/src/window_controller.rs b/src/window_controller.rs
index d088b99..34f9fd4 100644
--- a/src/window_controller.rs
+++ b/src/window_controller.rs
@@ -1,42 +1,44 @@
use crate::*;
-// use raw_gl_context::GlContext;
-/// Controls a single window.
pub trait WindowController {
fn title(&self) -> String { String::from("Phosphor") }
- fn initial_dimensions(&self) -> Dimensions { Dimensions::new(800,600) }
- fn minimum_dimensions(&self) -> Option<Dimensions> { None }
- fn maximum_dimensions(&self) -> Option<Dimensions> { None }
- fn resizable(&self) -> bool { true }
-
- fn cursor_icon(&mut self) -> Option<CursorIcon> { None }
- fn cursor_visible(&mut self) -> bool { true }
-
- fn on_resize(&mut self, _dimensions: Dimensions) {}
+ fn cursor_icon(&self) -> Option<CursorIcon> { None }
+ fn initial_size(&self) -> Dimensions { Dimensions::new(800,600) }
+ fn minimum_size(&self) -> Option<Dimensions> { None }
+ fn maximum_size(&self) -> Option<Dimensions> { None }
+ fn pixel_scale(&self) -> u32 { 1 }
+ fn render_request(&self) -> RenderRequest { RenderRequest::None }
+
+ fn is_visible(&self) -> bool { true }
+ fn is_cursor_visible(&self) -> bool { true }
+ fn is_resizable(&self) -> bool { true }
+
+ fn on_init(&mut self) {}
+ fn on_resize(&mut self, _size: Dimensions) {}
fn on_move(&mut self, _position: Point) {}
- fn on_focus_change(&mut self, _focused: bool) {}
+ fn on_focus_change(&mut self, _is_focused: bool) {}
fn on_process(&mut self) {}
+ fn on_render(&mut self, _buffer: &mut Buffer, _hint: RenderHint) {}
+ fn on_close_request(&mut self) {}
+ fn on_close(&mut self) {}
- fn on_mouse_enter(&mut self) {}
- fn on_mouse_exit(&mut self) {}
- fn on_mouse_move(&mut self, _position: Point) {}
+ fn on_cursor_enter(&mut self) {}
+ fn on_cursor_exit(&mut self) {}
+ fn on_cursor_move(&mut self, _position: Point) {}
- fn on_left_mouse_button(&mut self, _pressed: PressState) {}
- fn on_middle_mouse_button(&mut self, _pressed: PressState) {}
- fn on_right_mouse_button(&mut self, _pressed: PressState) {}
-
- fn on_keyboard_input(&mut self, _input: KeyboardInput) {}
- fn on_keyboard_modifier_change(&mut self, _modifiers: ModifiersState) {}
- fn on_character_received(&mut self, _character: char) {}
- fn on_file_hovered(&mut self, _path: std::path::PathBuf) {}
- fn on_file_dropped(&mut self, _path: std::path::PathBuf) {}
+ fn on_left_mouse_button(&mut self, _action: Action) {}
+ fn on_middle_mouse_button(&mut self, _action: Action) {}
+ fn on_right_mouse_button(&mut self, _action: Action) {}
fn on_line_scroll_horizontal(&mut self, _delta: f64) {}
fn on_line_scroll_vertical(&mut self, _delta: f64) {}
fn on_pixel_scroll_horizontal(&mut self, _delta: f64) {}
fn on_pixel_scroll_vertical(&mut self, _delta: f64) {}
- fn render_request(&mut self) -> RenderRequest { RenderRequest::None }
- fn render(&mut self, _buffer: &mut Buffer, _hint: RenderHint) {}
- // fn render_gl(&mut self, _context: &mut GlContext) {}
+ fn on_keyboard_input(&mut self, _input: KeyboardInput) {}
+ fn on_keyboard_modifier_change(&mut self, _modifiers: ModifiersState) {}
+ fn on_character_input(&mut self, _character: char) {}
+ fn on_file_hover(&mut self, _path: std::path::PathBuf) {}
+ fn on_file_hover_cancel(&mut self) {}
+ fn on_file_drop(&mut self, _path: std::path::PathBuf) {}
}