From 3b26f6bde9fd5b17d132613c7a3984fc1ba37506 Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Thu, 13 Sep 2018 15:39:50 +0900 Subject: [PATCH] [ImGui] Wrap igIsWindowFocused Wrap with three different functions, one for each of the possible values of ImGuiFocusedFlags given as argument to igIsWindowFocused. --- src/lib.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e7887bc..9b78d17 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,9 +33,9 @@ pub use sliders::{ pub use string::{ImStr, ImString}; pub use style::StyleVar; pub use sys::{ - ImDrawIdx, ImDrawVert, ImGuiCol, ImGuiColorEditFlags, ImGuiCond, ImGuiHoveredFlags, - ImGuiInputTextFlags, ImGuiKey, ImGuiMouseCursor, ImGuiSelectableFlags, ImGuiStyle, - ImGuiTreeNodeFlags, ImGuiWindowFlags, ImVec2, ImVec4, + ImDrawIdx, ImDrawVert, ImGuiCol, ImGuiColorEditFlags, ImGuiCond, ImGuiFocusedFlags, + ImGuiHoveredFlags, ImGuiInputTextFlags, ImGuiKey, ImGuiMouseCursor, ImGuiSelectableFlags, + ImGuiStyle, ImGuiTreeNodeFlags, ImGuiWindowFlags, ImVec2, ImVec4, }; pub use trees::{CollapsingHeader, TreeNode}; pub use window::Window; @@ -1558,6 +1558,21 @@ impl<'ui> Ui<'ui> { unsafe { sys::igIsWindowHovered(ImGuiHoveredFlags::empty()) } } + /// Return `true` if the current window is currently focused. + pub fn is_window_focused(&self) -> bool { + unsafe { sys::igIsWindowFocused(ImGuiFocusedFlags::RootAndChildWindows) } + } + + /// Return `true` if the current root window is currently focused. + pub fn is_root_window_focused(&self) -> bool { + unsafe { sys::igIsWindowFocused(ImGuiFocusedFlags::RootWindow) } + } + + /// Return `true` if the current child window is currently focused. + pub fn is_child_window_focused(&self) -> bool { + unsafe { sys::igIsWindowFocused(ImGuiFocusedFlags::ChildWindows) } + } + /// Returns `true` if the last item is being active. pub fn is_item_active(&self) -> bool { unsafe { sys::igIsItemActive() }