Implementing hack for tooltip.
This commit is contained in:
@@ -19,6 +19,13 @@ namespace JUI {
|
||||
/// A JUI Widget that displays a HSV color input dialog.
|
||||
class ColorPicker : public Rect, public TextStyler {
|
||||
public:
|
||||
ColorPicker();
|
||||
|
||||
explicit ColorPicker(Widget* parent);
|
||||
|
||||
/// Invoked when the color value is changed by the user.
|
||||
/// @param Color4 The new color value.
|
||||
Event<Color4> OnColorValueChanged;
|
||||
|
||||
/// Sets the font of the text elements contained in this widget.
|
||||
void Font(const JGL::Font &value) override;
|
||||
@@ -32,21 +39,15 @@ namespace JUI {
|
||||
|
||||
|
||||
|
||||
|
||||
Event<Color4> OnColorValueChanged;
|
||||
void SetColorValue(const Color4& color);
|
||||
Color4 GetColorValue() const;
|
||||
|
||||
|
||||
float Hue() const { return hue;}
|
||||
float Sat() const { return sat;}
|
||||
float Val() const { return bri;}
|
||||
|
||||
|
||||
float hue = 0;
|
||||
float sat = 1.f;
|
||||
float bri = 1.f; // AKA val
|
||||
ColorPicker();
|
||||
|
||||
explicit ColorPicker(Widget* parent);
|
||||
|
||||
protected:
|
||||
/// Calculates the colors of the label, and the inverse color for the text.
|
||||
void RecomputeVisuals();
|
||||
@@ -61,6 +62,10 @@ namespace JUI {
|
||||
JUI::Text* sat_label = nullptr;
|
||||
JUI::Text* bri_label = nullptr;
|
||||
JUI::TextRect* hex_label = nullptr;
|
||||
|
||||
float hue = 0;
|
||||
float sat = 1.f;
|
||||
float bri = 1.f; // AKA val
|
||||
private:
|
||||
};
|
||||
|
||||
|
@@ -12,32 +12,21 @@ namespace JUI
|
||||
Tooltip() : TextRect() {
|
||||
Name("Tooltip");
|
||||
}
|
||||
explicit Tooltip(Widget* parent) : Tooltip()
|
||||
{
|
||||
this->Parent(parent);
|
||||
explicit Tooltip(Widget* parent) : Tooltip() {
|
||||
attachment = parent;
|
||||
this->Parent(parent->GetFamilyTreeRoot());
|
||||
this->AutoFitSizeToText(true);
|
||||
this->ZIndex(10);
|
||||
this->Visible(false);
|
||||
this->Size({100_px, 20_px});
|
||||
|
||||
}
|
||||
|
||||
void Update(float delta) override
|
||||
{
|
||||
void Update(float delta) override;
|
||||
|
||||
if (parent && parent->IsMouseInside() || IsMouseInside())
|
||||
{
|
||||
auto coords = InputService::GetMousePosition();
|
||||
Position(UDim2::FromPixels(coords.x, coords.y));
|
||||
Visible(true);
|
||||
} else
|
||||
Visible(false);
|
||||
|
||||
|
||||
TextRect::Update(delta);
|
||||
}
|
||||
~Tooltip() override {};
|
||||
|
||||
Widget* attachment = nullptr;
|
||||
|
||||
protected:
|
||||
};
|
||||
}
|
@@ -21,6 +21,7 @@ namespace JUI {
|
||||
|
||||
void Scene::Update(float delta) {
|
||||
Widget::Update(delta);
|
||||
|
||||
}
|
||||
|
||||
void Scene::GlobalUIScale(const Vector2 &value) { ui_scale = value;}
|
||||
|
@@ -1 +1,25 @@
|
||||
#include <JUI/Widgets/Tooltip.hpp>
|
||||
#include <JUI/Widgets/Tooltip.hpp>
|
||||
|
||||
void JUI::Tooltip::Update(float delta) {
|
||||
|
||||
if (attachment && attachment->IsMouseInside())
|
||||
{
|
||||
auto coords = InputService::GetMousePosition();
|
||||
|
||||
|
||||
auto rel_pos = parent->GetAbsolutePosition();
|
||||
|
||||
auto rel_udim = UDim2::FromPixels(rel_pos.x, rel_pos.y);
|
||||
|
||||
auto anchor = AnchorPoint();
|
||||
|
||||
Position(UDim2::FromPixels(coords.x - rel_pos.x, coords.y - rel_pos.y));
|
||||
Visible(true);
|
||||
} else
|
||||
Visible(false);
|
||||
|
||||
|
||||
TextRect::Update(delta);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user