Functional input binding
This commit is contained in:
+10
-1
@@ -235,14 +235,23 @@ impl<'a> Drop for ContextLock<'a> {
|
||||
|
||||
pub trait UiExt {
|
||||
fn fullscreen_window(&self) -> Option<WindowToken<'_>>;
|
||||
fn right_align_text<T: AsRef<str>>(&self, text: T, space: f32);
|
||||
}
|
||||
|
||||
impl UiExt for imgui::Ui {
|
||||
fn fullscreen_window(&self) -> Option<WindowToken<'_>> {
|
||||
self.window("fullscreen")
|
||||
.position([0.0, 0.0], imgui::Condition::Always)
|
||||
.size(self.window_size(), imgui::Condition::Always)
|
||||
.size(self.io().display_size, imgui::Condition::Always)
|
||||
.flags(imgui::WindowFlags::NO_DECORATION)
|
||||
.begin()
|
||||
}
|
||||
|
||||
fn right_align_text<T: AsRef<str>>(&self, text: T, space: f32) {
|
||||
let width = self.calc_text_size(text.as_ref())[0];
|
||||
let [left, y] = self.cursor_pos();
|
||||
let right = left + space;
|
||||
self.set_cursor_pos([right - width, y]);
|
||||
self.text(text);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user