Annotation for Image & ImageBase, add files for ImageRect class
This commit is contained in:
@@ -19,19 +19,31 @@ using J3ML::LinearAlgebra::Vector2;
|
||||
|
||||
namespace JUI
|
||||
{
|
||||
|
||||
/// The ImageBase class is an object that handles managing and rendering a texture reference.
|
||||
/// This class is used as a mixin on widgets that must render images. i.e. Image class
|
||||
class ImageBase
|
||||
{
|
||||
public:
|
||||
/// The default constructor initializes this ImageBase with a null pointer texture.
|
||||
ImageBase();
|
||||
ImageBase(JGL::Texture* texture);
|
||||
/// This constructor initializes this ImageBase with a JGL::Texture pointer.
|
||||
explicit ImageBase(JGL::Texture* texture);
|
||||
public:
|
||||
[[nodiscard]] JGL::Texture* Content() const { return texture;}
|
||||
[[nodiscard]] Color4 Color() const { return image_color;}
|
||||
[[nodiscard]] Vector2 Scale() const { return scale;}
|
||||
[[nodiscard]] Vector2 Origin() const { return origin;}
|
||||
/// Returns the texture pointer held by this object.
|
||||
[[nodiscard]] JGL::Texture* Content() const;
|
||||
/// Returns the color of this object. The texture is rendered with this color.
|
||||
[[nodiscard]] Color4 Color() const;
|
||||
/// Returns the scale factor of this object. The texture is scaled with this value.
|
||||
[[nodiscard]] Vector2 Scale() const;
|
||||
/// Returns the origin factor of this object. The texture's origin is determined by this value.
|
||||
[[nodiscard]] Vector2 Origin() const;
|
||||
|
||||
void SetContent(JGL::Texture* content);
|
||||
/// Sets the texture of this object.
|
||||
void Content(JGL::Texture* content);
|
||||
/// Sets the color of this object.
|
||||
void Color(const Color4& newColor);
|
||||
/// Sets the scale factor of this object.
|
||||
void Scale(const Vector2& newScale);
|
||||
void Origin(const Vector2& newOrigin);
|
||||
public:
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
/// @file Image.hpp
|
||||
/// @desc A widget that contains and renders an image provided by JGL.
|
||||
/// @edit 2024-08-05
|
||||
/// @edit 2024-10-31
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -16,11 +16,21 @@
|
||||
|
||||
namespace JUI
|
||||
{
|
||||
/// The image class contains and renders an image provided by JGL.
|
||||
/// By default, this class renders it's image to fill the parent widget.
|
||||
/// For a self-contained image rectangle, see ImageRect.hpp
|
||||
class Image : public Widget, public ImageBase
|
||||
{
|
||||
public:
|
||||
/// The default constructor initializes the image with a nullptr texture.
|
||||
Image();
|
||||
|
||||
/// Constructs a new image by explicitly setting the parent Widget.
|
||||
explicit Image(Widget* parent);
|
||||
|
||||
/// Constructs a new image by explicitly setting both the parent Widget and the texture.
|
||||
/// @param parent
|
||||
/// @param tex
|
||||
explicit Image(Widget* parent, JGL::Texture* tex);
|
||||
~Image() override {}
|
||||
|
||||
|
25
include/JUI/Widgets/ImageRect.hpp
Normal file
25
include/JUI/Widgets/ImageRect.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/// 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 ImageRect.hpp
|
||||
/// @desc A widget that contains and renders an image provided by JGL, within a rectangular frame.
|
||||
/// @edit 2024-08-05
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <JUI/Widgets/Rect.hpp>
|
||||
#include <JUI/Base/ImageBase.hpp>
|
||||
|
||||
namespace JUI
|
||||
{
|
||||
class ImageRect: public Rect, public ImageBase
|
||||
{
|
||||
|
||||
};
|
||||
}
|
@@ -14,7 +14,7 @@ namespace JUI
|
||||
|
||||
ImageBase::ImageBase()
|
||||
{
|
||||
|
||||
this->texture = nullptr;
|
||||
}
|
||||
|
||||
ImageBase::ImageBase(JGL::Texture* tex) : ImageBase()
|
||||
@@ -22,7 +22,7 @@ namespace JUI
|
||||
this->texture = tex;
|
||||
}
|
||||
|
||||
void ImageBase::SetContent(JGL::Texture *content) {
|
||||
void ImageBase::Content(JGL::Texture *content) {
|
||||
this->texture = content;
|
||||
}
|
||||
|
||||
@@ -31,5 +31,13 @@ namespace JUI
|
||||
void ImageBase::Scale(const Vector2 &newScale) { scale = newScale;}
|
||||
|
||||
void ImageBase::Origin(const Vector2 &newOrigin) { origin = newOrigin; }
|
||||
|
||||
JGL::Texture *ImageBase::Content() const { return texture;}
|
||||
|
||||
Color4 ImageBase::Color() const { return image_color;}
|
||||
|
||||
Vector2 ImageBase::Scale() const { return scale;}
|
||||
|
||||
Vector2 ImageBase::Origin() const { return origin;}
|
||||
}
|
||||
|
||||
|
2
src/JUI/Widgets/ImageRect.cpp
Normal file
2
src/JUI/Widgets/ImageRect.cpp
Normal file
@@ -0,0 +1,2 @@
|
||||
#include <JUI/Widgets/ImageRect.hpp>
|
||||
|
Reference in New Issue
Block a user