Expose position of ui elements
This commit is contained in:
parent
a50ef55ad4
commit
94d173e2bb
11 changed files with 48 additions and 0 deletions
|
@ -136,6 +136,10 @@ impl Gridable for GuiSnippet {
|
|||
fn set_layer(&self, layer: i32) -> Result<()> {
|
||||
self.grid.set_layer(layer)
|
||||
}
|
||||
|
||||
fn position_extent(&self) -> (i32, i32, u32, u32) {
|
||||
self.grid.position_extent()
|
||||
}
|
||||
}
|
||||
|
||||
impl Functionality for GuiSnippet {
|
||||
|
|
|
@ -501,6 +501,10 @@ impl Gridable for Button {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn position_extent(&self) -> (i32, i32, u32, u32) {
|
||||
self.framable.position()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Button {
|
||||
|
|
|
@ -738,6 +738,10 @@ impl Gridable for Grid {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn position_extent(&self) -> (i32, i32, u32, u32) {
|
||||
self.framable.position()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Grid {
|
||||
|
|
|
@ -287,6 +287,10 @@ impl Gridable for Icon {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn position_extent(&self) -> (i32, i32, u32, u32) {
|
||||
self.framable.position()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Icon {
|
||||
|
|
|
@ -242,6 +242,10 @@ impl Gridable for Label {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn position_extent(&self) -> (i32, i32, u32, u32) {
|
||||
self.framable.position()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Label {
|
||||
|
|
|
@ -296,4 +296,8 @@ impl Gridable for MultiLineLabel {
|
|||
fn set_layer(&self, layer: i32) -> Result<()> {
|
||||
self.grid.set_layer(layer)
|
||||
}
|
||||
|
||||
fn position_extent(&self) -> (i32, i32, u32, u32) {
|
||||
self.grid.position_extent()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -416,6 +416,10 @@ impl Gridable for MultiLineTextField {
|
|||
self.writeable.set_ui_layer(layer);
|
||||
self.grid.set_layer(layer)
|
||||
}
|
||||
|
||||
fn position_extent(&self) -> (i32, i32, u32, u32) {
|
||||
self.grid.position_extent()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for MultiLineTextField {
|
||||
|
|
|
@ -343,6 +343,10 @@ impl Gridable for ProgressBar {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn position_extent(&self) -> (i32, i32, u32, u32) {
|
||||
self.framable.position()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ProgressBar {
|
||||
|
|
|
@ -293,6 +293,10 @@ impl Gridable for TextField {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn position_extent(&self) -> (i32, i32, u32, u32) {
|
||||
self.framable.position()
|
||||
}
|
||||
}
|
||||
|
||||
impl Visibility for TextField {
|
||||
|
|
|
@ -67,6 +67,8 @@ pub trait Gridable {
|
|||
fn type_name(&self) -> &str;
|
||||
|
||||
fn set_layer(&self, layer: i32) -> Result<()>;
|
||||
|
||||
fn position_extent(&self) -> (i32, i32, u32, u32);
|
||||
}
|
||||
|
||||
pub trait Visibility {
|
||||
|
|
|
@ -281,6 +281,16 @@ impl Framable {
|
|||
self.bottom.load(SeqCst)
|
||||
}
|
||||
|
||||
pub fn position(&self) -> (i32, i32, u32, u32) {
|
||||
let x = self.left();
|
||||
let y = self.top();
|
||||
|
||||
let w = self.right() - x;
|
||||
let h = self.bottom() - y;
|
||||
|
||||
(x, y, w as u32, h as u32)
|
||||
}
|
||||
|
||||
/// Returns `true` if `set_frame` got called, otherwise `false`
|
||||
pub fn is_framed(&self) -> bool {
|
||||
self.framed.load(SeqCst)
|
||||
|
|
Loading…
Reference in a new issue