Skip to content

Commit

Permalink
Window::occluded + Window::outer_size
Browse files Browse the repository at this point in the history
  • Loading branch information
ecton committed Sep 7, 2024
1 parent e85fba8 commit e725838
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
`appit::App`. The previously exported type wasn't able to be used beyond
passing it as a parameter for opening additional windows. This new type
exposes additional winit information including monitor configurations.
- `Window::ocluded` has had its spelling fixed and is now `Window::occluded`.

### Fixed

Expand All @@ -28,6 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
about the monitor configurations available to the application. This
information can be retrieved from an `App` or `ExecutingApp`.
- `WindowBehavior::moved` is invoked when the window is repositioned.
- `Window::outer_size` is a new function that returns the window's size
including decorations.

## v0.10.0 (2024-08-20)

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 25 additions & 19 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ where
self.window.set_inner_size(inner_size.into());
}

/// Returns the size of the window, including decorations.
#[must_use]
pub fn outer_size(&self) -> Size<UPx> {
self.window.outer_size().into()
}

/// Returns true if the window is currently focused for keyboard input.
#[must_use]
pub const fn focused(&self) -> bool {
Expand All @@ -317,7 +323,7 @@ where
/// Returns true if the window is currenly not visible because it is
/// completely hidden behind other windows, offcreen, or minimized.
#[must_use]
pub const fn ocluded(&self) -> bool {
pub const fn occluded(&self) -> bool {
self.window.occluded()
}

Expand Down Expand Up @@ -576,8 +582,8 @@ where
///
/// # Errors
///
/// The only errors this funciton can return arise from
/// [`winit::window::WindowBuilder::build`].
/// The only errors this funciton can return arise from winit's
/// `create_window`.
fn open<App>(app: &mut App) -> Result<Option<WindowHandle<WindowEvent>>, OsError>
where
App: AsApplication<AppEvent<WindowEvent>> + ?Sized,
Expand All @@ -596,8 +602,8 @@ where
///
/// # Errors
///
/// The only errors this funciton can return arise from
/// [`winit::window::WindowBuilder::build`].
/// The only errors this funciton can return arise from winit's
/// `create_window`.
fn open_with<App>(
app: &mut App,
context: Self::Context,
Expand All @@ -624,33 +630,33 @@ where
true
}

/// The window has gained or lost keyboard focus.
/// [`RunningWindow::focused()`] returns the current state.
/// The window has gained or lost keyboard focus. [`Window::focused()`]
/// returns the current state.
#[allow(unused_variables)]
fn focus_changed(&mut self, window: Window<'_, WindowEvent>, kludgine: &mut Kludgine) {}

/// The window has been occluded or revealed. [`RunningWindow::occluded()`]
/// returns the current state.
/// The window has been occluded or revealed. [`Window::occluded()`] returns
/// the current state.
#[allow(unused_variables)]
fn occlusion_changed(&mut self, window: Window<'_, WindowEvent>, kludgine: &mut Kludgine) {}

/// The window's scale factor has changed. [`RunningWindow::scale()`]
/// returns the current scale.
/// The window's scale factor has changed. [`Window::scale()`] returns the
/// current scale.
#[allow(unused_variables)]
fn scale_factor_changed(&mut self, window: Window<'_, WindowEvent>, kludgine: &mut Kludgine) {}

/// The window has been resized. [`RunningWindow::inner_size()`]
/// returns the current size.
/// The window has been resized. [`Window::inner_size()`] returns the
/// current size.
#[allow(unused_variables)]
fn resized(&mut self, window: Window<'_, WindowEvent>, kludgine: &mut Kludgine) {}

/// The window has been moved. [`RunningWindow::position()`] returns the
/// current position.
/// The window has been moved. [`Window::position()`] returns the current
/// position.
#[allow(unused_variables)]
fn moved(&mut self, window: Window<'_, WindowEvent>, kludgine: &mut Kludgine) {}

/// The window's theme has been updated. [`RunningWindow::theme()`]
/// returns the current theme.
/// The window's theme has been updated. [`Window::theme()`] returns the
/// current theme.
#[allow(unused_variables)]
fn theme_changed(&mut self, window: Window<'_, WindowEvent>, kludgine: &mut Kludgine) {}

Expand Down Expand Up @@ -701,8 +707,8 @@ where
) {
}

/// The keyboard modifier keys have changed. [`RunningWindow::modifiers()`]
/// returns the current modifier keys state.
/// The keyboard modifier keys have changed. [`Window::modifiers()`] returns
/// the current modifier keys state.
#[allow(unused_variables)]
fn modifiers_changed(&mut self, window: Window<'_, WindowEvent>, kludgine: &mut Kludgine) {}

Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl Frame<'_> {
/// - [`Texture::prepare`]
/// - [`Texture::prepare_partial`]
/// - [`CollectedTexture::prepare`]
/// - [`Drawing::new_frame`](render::Drawing::new_frame)
/// - [`Drawing::new_frame`](drawing::Drawing::new_frame)
///
/// The returned graphics provides access to the various types to update
/// their representation on the GPU so that they can be rendered later.
Expand All @@ -324,7 +324,7 @@ impl Frame<'_> {
///
/// - [`PreparedGraphic`]
/// - [`PreparedText`](text::PreparedText)
/// - [`Drawing`](render::Drawing)
/// - [`Drawing`](drawing::Drawing)
#[must_use]
pub fn render<'gfx, 'pass>(
&'pass mut self,
Expand Down Expand Up @@ -353,7 +353,7 @@ impl Frame<'_> {
///
/// - [`PreparedGraphic`]
/// - [`PreparedText`](text::PreparedText)
/// - [`Drawing`](render::Drawing)
/// - [`Drawing`](drawing::Drawing)
pub fn render_into<'gfx, 'pass>(
&'pass mut self,
texture: &'pass Texture,
Expand Down Expand Up @@ -544,7 +544,7 @@ impl ClipStack {
/// - [`Texture::prepare`]
/// - [`Texture::prepare_partial`]
/// - [`CollectedTexture::prepare`]
/// - [`Drawing::new_frame`](render::Drawing::new_frame)
/// - [`Drawing::new_frame`](drawing::Drawing::new_frame)
#[derive(Debug)]
pub struct Graphics<'gfx> {
kludgine: &'gfx mut Kludgine,
Expand Down Expand Up @@ -658,7 +658,7 @@ impl sealed::Clipped for Graphics<'_> {}
///
/// - [`PreparedGraphic`]
/// - [`PreparedText`](text::PreparedText)
/// - [`Drawing`](render::Drawing)
/// - [`Drawing`](drawing::Drawing)
pub struct RenderingGraphics<'gfx, 'pass> {
pass: wgpu::RenderPass<'pass>,
kludgine: &'pass Kludgine,
Expand Down

0 comments on commit e725838

Please sign in to comment.