Added documentation to Window class.
This commit is contained in:
@@ -1,13 +1,22 @@
|
||||
/// Josh's User Interface Library
|
||||
/// A C++20 Library for creating, styling, and rendering of a UI/UX widgets.
|
||||
/// Developed and Maintained by Josh O'Leary @ Redacted Software.
|
||||
/// Special Thanks to William Tomasine II and Maxine Hayes.
|
||||
/// (c) 2024 Redacted Software
|
||||
/// This work is dedicated to the public domain.
|
||||
|
||||
/// @file UDim2.hpp
|
||||
/// @desc Universal Dimensions 2D Class
|
||||
/// @edit 2024-07-10
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "JUI/Base/Widget.hpp"
|
||||
#include <JUI/Base/Widget.hpp>
|
||||
#include <JUI/Base/RectBase.hpp>
|
||||
|
||||
namespace JUI {
|
||||
|
||||
/// The Rect Widget Class
|
||||
/// The Rect Widget Class.
|
||||
/// Renders a rectangle or "box" and also serves as a vesatile container for laying out other widgets.
|
||||
class Rect : public Widget, public RectBase {
|
||||
public: /// Constructors
|
||||
|
@@ -1,18 +1,29 @@
|
||||
/// Josh's User Interface Library
|
||||
/// A C++20 Library for creating, styling, and rendering of a UI/UX widgets.
|
||||
/// Developed and Maintained by Josh O'Leary @ Redacted Software.
|
||||
/// Special Thanks to William Tomasine II and Maxine Hayes.
|
||||
/// (c) 2024 Redacted Software
|
||||
/// This work is dedicated to the public domain.
|
||||
|
||||
/// @file Window.hpp
|
||||
/// @desc Window Widget - self-managed container for other widgets.
|
||||
/// @edit 2024-08-01
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "J3ML/LinearAlgebra.h"
|
||||
#include "JUI/Base/Widget.hpp"
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <JUI/Base/Widget.hpp>
|
||||
|
||||
#include "JUI/Base/RectBase.hpp"
|
||||
#include "JUI/Widgets/Rect.hpp"
|
||||
#include "JUI/Widgets/Text.hpp"
|
||||
#include "JUI/Widgets/Button.hpp"
|
||||
#include <JUI/Base/RectBase.hpp>
|
||||
#include <JUI/Widgets/Rect.hpp>
|
||||
#include <JUI/Widgets/Text.hpp>
|
||||
#include <JUI/Widgets/Button.hpp>
|
||||
|
||||
namespace JUI
|
||||
{
|
||||
|
||||
using J3ML::LinearAlgebra::Vector2;
|
||||
|
||||
/// A mixin helper class that enables a widget to be dragged around by the mouse.
|
||||
class Draggable {
|
||||
public:
|
||||
Event<> OnDragBegan;
|
||||
@@ -32,6 +43,7 @@ namespace JUI
|
||||
Vector2 initial_drag_offset = {0, 0};
|
||||
};
|
||||
|
||||
/// A mixin helper class that enables a widget to be resized by the mouse.
|
||||
class Resizable {
|
||||
public:
|
||||
Event<> OnDragBegan;
|
||||
@@ -44,57 +56,70 @@ namespace JUI
|
||||
{
|
||||
initial_resize_offset = point;
|
||||
}
|
||||
virtual void StopDragging() {}
|
||||
virtual void StopResizing() {}
|
||||
virtual void Update(float delta) {}
|
||||
protected:
|
||||
bool resizing = false;
|
||||
Vector2 initial_resize_offset = {0, 0};
|
||||
};
|
||||
|
||||
/*
|
||||
class Resizeable {
|
||||
public:
|
||||
Event<> OnResizeBegan;
|
||||
Event<> OnResizeEnded;
|
||||
bool Resizing() const { return resizing; }
|
||||
virtual void SetResize(bool b) {
|
||||
this->resizing = b;
|
||||
}
|
||||
virtual void StartResizing(const )
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
/// A mixin helper class that enables a widget to be docked into a DockingStation.
|
||||
class Dockable {};
|
||||
|
||||
/// TODO: Scope out.
|
||||
class DockingStation {};
|
||||
|
||||
/// A container widget class, with title bar and buttons,
|
||||
/// which can be dragged around, resized, and docked into other applicable widgets.
|
||||
class Window : public Widget, RectBase, public Clickable, public Hoverable, public Draggable, public Resizable, public Dockable
|
||||
{
|
||||
public:
|
||||
/// The default constructor sets a default style for this Window.
|
||||
Window();
|
||||
/// Construct a window widget by specifying it's parent.
|
||||
Window(Widget* parent);
|
||||
Vector2 GetMinSize() const;
|
||||
Vector2 GetMaxSize() const;
|
||||
Vector2 GetCurrentSize() const;
|
||||
float GetTitlebarHeight() const;
|
||||
std::string GetTitle() const;
|
||||
/// Returns the minimum size (in x,y pixels) that the Window widget is allowed to be.
|
||||
[[nodiscard]] Vector2 MinSize() const;
|
||||
/// Returns the maximum size (in x,y pixels) that the Window widget is allowed to be.
|
||||
[[nodiscard]] Vector2 MaxSize() const;
|
||||
/// Returns the current size (in x,y pixels) of the Window widget.
|
||||
[[nodiscard]] Vector2 CurrentSize() const;
|
||||
/// Returns the height (in pixels) of the Window's titlebar.
|
||||
// TODO: Decide if this will auto-scale with the titlebar's text height, or the other way around.
|
||||
int TitlebarHeight() const;
|
||||
/// Returns the text displayed as the Window's title.
|
||||
[[nodiscard]] std::string Title() const;
|
||||
/// Returns whether dragging the window about with the mouse is enabled.
|
||||
/// @see class Draggable.
|
||||
bool IsDraggable() const;
|
||||
/// Returns whether this Window is able to be 'Docked' into another widget.
|
||||
/// @see class Dockable.
|
||||
bool IsDockable() const;
|
||||
/// Returns whether resizing the window via right-click is enabled.
|
||||
/// @see class Resizable
|
||||
bool IsResizable() const;
|
||||
|
||||
/// Returns a pointer to the Text Widget that is used to render the title bar's text.
|
||||
Text* GetTitleInstance();
|
||||
/// Returns a pointer to the Rect Widget that is used to layout the title bar contents.
|
||||
Rect* GetTopbarInstance();
|
||||
/// Returns a pointer to the Rect Widget that is used to layout the contents of the window.
|
||||
Rect* GetViewportInstance();
|
||||
|
||||
void SetDrag(bool d) override;
|
||||
/// Returns a pointer to the Exit Button Widget.
|
||||
TextButton* GetExitButtonInstance();
|
||||
|
||||
void SetTitleFont(const JUI::Font& f);
|
||||
/// @see class Draggable.
|
||||
void SetDrag(bool d) override;
|
||||
|
||||
/// @see class Widget.
|
||||
void Update(float delta) override;
|
||||
/// @see class Widget.
|
||||
void Draw() override;
|
||||
|
||||
|
||||
/// @see class Clickable.
|
||||
void OnClick(const Vector2& m_pos, const MouseBtn& m_btn) override;
|
||||
|
||||
/// @see class Clickable.
|
||||
void OnRelease(const Vector2& m_pos, const MouseBtn& m_btn, bool still_hovering) override;
|
||||
protected:
|
||||
JUI::Rect* Topbar;
|
||||
|
@@ -95,13 +95,13 @@ namespace JUI
|
||||
this->SetParent(parent);
|
||||
}
|
||||
|
||||
Vector2 Window::GetMinSize() const { return min_size; }
|
||||
Vector2 Window::MinSize() const { return min_size; }
|
||||
|
||||
Vector2 Window::GetMaxSize() const { return max_size; }
|
||||
Vector2 Window::MaxSize() const { return max_size; }
|
||||
|
||||
Vector2 Window::GetCurrentSize() const { return this->GetAbsoluteSize(); }
|
||||
Vector2 Window::CurrentSize() const { return this->GetAbsoluteSize(); }
|
||||
|
||||
std::string Window::GetTitle() const { return title; }
|
||||
std::string Window::Title() const { return title; }
|
||||
|
||||
bool Window::IsDraggable() const { return draggable; }
|
||||
|
||||
|
Reference in New Issue
Block a user