Skip to content

Commit

Permalink
#1256 Docs: Prepare automatic creation of screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Oct 18, 2024
1 parent 2a37c1a commit a5ff027
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
20 changes: 20 additions & 0 deletions swell-ui/src/units.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use reaper_low::raw;
use reaper_low::raw::RECT;
use std::ops::{Add, Mul, Sub};

/// An abstract unit used for dialog dimensions, independent of HiDPI and stuff.
Expand Down Expand Up @@ -232,3 +234,21 @@ pub struct DialogScaling {
pub width_scale: f64,
pub height_scale: f64,
}

pub struct Rect {
pub x: i32,
pub y: i32,
pub width: u32,
pub height: u32,
}

impl From<raw::RECT> for Rect {
fn from(value: RECT) -> Self {
Self {
x: value.left,
y: value.top,
width: (value.right - value.left) as _,
height: (value.bottom - value.top) as _,
}
}
}
10 changes: 9 additions & 1 deletion swell-ui/src/window.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
menu_tree, DialogUnits, Dimensions, FontDescriptor, Menu, MenuBar, Pixels, Point,
menu_tree, DialogUnits, Dimensions, FontDescriptor, Menu, MenuBar, Pixels, Point, Rect,
SwellStringArg, ViewManager,
};
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
Expand Down Expand Up @@ -770,6 +770,14 @@ impl Window {
}
}

pub fn window_rect(self) -> Rect {
let mut rect = RECT::default();
unsafe {
Swell::get().GetWindowRect(self.raw, &mut rect as *mut _);
}
rect.into()
}

pub fn move_to_pixels(self, point: Point<Pixels>) {
unsafe {
Swell::get().SetWindowPos(
Expand Down

0 comments on commit a5ff027

Please sign in to comment.