Implement window focusing.
This commit is contained in:
@@ -334,7 +334,6 @@ namespace JUI {
|
||||
/// See ReWindowIntegrationDemo for an example.
|
||||
virtual bool ObserveKeyInput(Key key, bool pressed);
|
||||
|
||||
|
||||
protected:
|
||||
void DrawChildWidgets();
|
||||
void UpdateChildWidgets(float delta);
|
||||
|
@@ -56,6 +56,7 @@ namespace JUI {
|
||||
const Vector2 DefaultMinimumSize = {200, 200};
|
||||
const int TitlebarHeight = 20;
|
||||
const Color4 OutlineColor = {92, 92, 192};
|
||||
const Color4 UnfocusedOutlineColor = Colors::Gray;
|
||||
const Color4 ViewportBackgroundColor = Colors::DarkGray;
|
||||
const int OutlineWidth = 2;
|
||||
|
||||
|
@@ -55,6 +55,19 @@ namespace JUI {
|
||||
// TODO: Decide if this will auto-scale with the titlebar's text height, or the other way around.
|
||||
[[nodiscard]] int TitlebarHeight() const;
|
||||
|
||||
|
||||
/// @return True if this window widget is on-top of all other window-widgets with the same parent.
|
||||
bool OnTop() const;
|
||||
|
||||
|
||||
/// Brings this window widget to the top of the window-widget stack.
|
||||
void BringToTop();
|
||||
|
||||
/// Moves this window up in the window-widget stack.
|
||||
void MoveUp() const;
|
||||
/// Moves this window down in the window-widget stack.
|
||||
void MoveDown() const;
|
||||
|
||||
void TitlebarHeight(int height);
|
||||
|
||||
/// Returns the text displayed as the Window's title.
|
||||
@@ -112,6 +125,27 @@ namespace JUI {
|
||||
void OnClick(const Vector2& m_pos, const MouseButton& m_btn) override;
|
||||
/// @see class Clickable.
|
||||
void OnRelease(const Vector2& m_pos, const MouseButton& m_btn, bool still_hovering) override;
|
||||
|
||||
|
||||
/// @see class Hoverable.
|
||||
void OnHover(const J3ML::LinearAlgebra::Vector2 &MousePos) override
|
||||
{
|
||||
Hoverable::OnHover(MousePos);
|
||||
zindex++;
|
||||
focused = true;
|
||||
this->BorderColor(Style::Window::OutlineColor);
|
||||
this->BGColor(Style::Window::OutlineColor);
|
||||
}
|
||||
|
||||
/// @see class Hoverable.
|
||||
void OnExit(const J3ML::LinearAlgebra::Vector2 &MousePos) override
|
||||
{
|
||||
Hoverable::OnExit(MousePos);
|
||||
zindex--;
|
||||
focused = false;
|
||||
this->BorderColor(Style::Window::UnfocusedOutlineColor);
|
||||
this->BGColor(Style::Window::UnfocusedOutlineColor);
|
||||
}
|
||||
protected:
|
||||
void UpdateInternalWidgetsTitlebarHeight();
|
||||
protected:
|
||||
@@ -123,6 +157,7 @@ namespace JUI {
|
||||
JUI::ImageButton* fs_btn;
|
||||
std::string title = "JUI Window";
|
||||
bool resizable = true;
|
||||
bool focused = false;
|
||||
//bool resizing = false;
|
||||
bool draggable = true;
|
||||
bool dockable = false;
|
||||
|
Reference in New Issue
Block a user