Doxygen annotation added to Button class

This commit is contained in:
2024-10-31 12:55:27 -04:00
parent 8a9ceb87e2
commit dcf65516cc
2 changed files with 42 additions and 33 deletions

View File

@@ -27,8 +27,8 @@ namespace JUI
Disabled
};
//class Button : public Widget, public RectBase, public Clickable, public Hoverable
/// The Button class is a basic rect widget that accepts mouse inputs, and provides event hooks.
/// The button also provides built-in automatic coloring based on it's current state, which are listed above.
class Button : public Widget, public RectBase, public Clickable, public Hoverable
{
public:
@@ -40,30 +40,59 @@ namespace JUI
~Button() override {};
public:
Color4 HoveredBGColor() const;
Color4 BaseBGColor() const;
Color4 PressedBGColor() const;
Color4 DisabledBGColor() const;
Color4 HoveredBorderColor() const;
Color4 BaseBorderColor() const;
Color4 PressedBorderColor() const;
Color4 DisabledBorderColor() const;
/// Returns the background color of this object when the mouse is hovering this button.
/// @note Setting BGColor and BorderColor directly on this class is not recommended, as it will be overwritten.
[[nodiscard]] Color4 HoveredBGColor() const;
/// Returns the background color of this object at rest.
/// @note Setting BGColor and BorderColor directly on this class is not recommended, as it will be overwritten.
[[nodiscard]] Color4 BaseBGColor() const;
/// Returns the background color of this object when it is clicked.
/// @note Setting BGColor and BorderColor directly on this class is not recommended, as it will be overwritten.
[[nodiscard]] Color4 PressedBGColor() const;
/// Returns the background color of this object when it is disabled.
/// @note Setting BGColor and BorderColor directly on this class is not recommended, as it will be overwritten.
[[nodiscard]] Color4 DisabledBGColor() const;
/// Returns the border color of this object when it is hovered.
/// @note Setting BGColor and BorderColor directly on this class is not recommended, as it will be overwritten.
[[nodiscard]] Color4 HoveredBorderColor() const;
/// Returns the border color of this object at rest.
/// @note Setting BGColor and BorderColor directly on this class is not recommended, as it will be overwritten.
[[nodiscard]] Color4 BaseBorderColor() const;
/// Returns the border color of this object when it is clicked.
/// @note Setting BGColor and BorderColor directly on this class is not recommended, as it will be overwritten.
[[nodiscard]] Color4 PressedBorderColor() const;
/// Returns the border color of this object when it is disabled.
/// @note Setting BGColor and BorderColor directly on this class is not recommended, as it will be overwritten.
[[nodiscard]] Color4 DisabledBorderColor() const;
/// Sets the background color of this object when the mouse is hovering.
void HoveredBGColor(const Color4& color);
/// Sets the background color of this object at rest.
void BaseBGColor(const Color4& color);
/// Sets the background color of this object when it is clicked.
void PressedBGColor(const Color4& color);
/// Sets the background color of this object when it is disabled.
void DisabledBGColor(const Color4& color);
/// Sets the border color of this object when the mouse is hovering.
void HoveredBorderColor(const Color4& color);
/// Sets the border color of this object at rest.
void BaseBorderColor(const Color4& color);
/// Sets the border color of this object when it is clicked.
void PressedBorderColor(const Color4& color);
/// Sets the border color of this object when it is disabled.
void DisabledBorderColor(const Color4& color);
/// Returns whether is button is interactable. If enabled, it will listen to mouse events and react accordingly.
bool Enabled() const;
/// Returns whether is button is interactable. If enabled, it will listen to mouse events and react accordingly.
bool Disabled() const;
/// Sets the interactable state of this button.
void SetEnabled(bool enabled);
/// Disables this button. Mouse events will be ignored and the button will grey-out.
void Disable();
/// Enables this button. @see Disable, SetEnabled
void Enable();
void Draw() override;
@@ -85,12 +114,5 @@ namespace JUI
Color4 base_border;
};
class TextButton : public Button, public TextBase {
public:
TextButton();
explicit TextButton(Widget* parent);
~TextButton() override {};
void Update(float delta) override;
void Draw() override;
};
}

View File

@@ -22,7 +22,7 @@ namespace JUI
GLint *old_scissor_bounds;
bool clip_was_enabled;
// TODO: Re-enable clipping
if (clips_descendants) {
clip_was_enabled = glIsEnabled(GL_SCISSOR_TEST);
if (clip_was_enabled)
@@ -185,18 +185,5 @@ namespace JUI
void Button::DisabledBorderColor(const Color4 &color) { disabled_border = color; }
TextButton::TextButton() : Button(), TextBase() {}
TextButton::TextButton(Widget* parent) : TextButton() {
this->Parent(parent);
}
void TextButton::Update(float delta) {
Button::Update(delta);
TextBase::Update(delta);
}
void TextButton::Draw() {
Button::Draw();
TextBase::Draw(this->GetAbsolutePosition(), this->GetAbsoluteSize());
}
}