button shit
This commit is contained in:
@@ -45,7 +45,9 @@ namespace JUI
|
||||
|
||||
|
||||
void SetEnabled(bool enabled);
|
||||
void Update(float delta);
|
||||
protected:
|
||||
bool mouse_inside_debounce;
|
||||
private:
|
||||
};
|
||||
}
|
6
main.cpp
6
main.cpp
@@ -12,7 +12,7 @@
|
||||
#include <iostream>
|
||||
#include <JGL/JGL.h>
|
||||
#include "JUI/Widgets/Rect.hpp"
|
||||
//#include "JUI/Widgets/Button.hpp"
|
||||
#include "JUI/Widgets/Button.hpp"
|
||||
#include "JUI/Widgets/Scene.hpp"
|
||||
#include "JUI/Widgets/Text.hpp"
|
||||
#include <rewindow/types/window.h>
|
||||
@@ -26,8 +26,8 @@ JUI::Scene* CreateScene() {
|
||||
|
||||
Scene* root = new Scene();
|
||||
|
||||
Rect* element = new Rect(root);
|
||||
//Button* element = new Button(root);
|
||||
//Rect* elementr = new Rect(root);
|
||||
Button* element = new Button(root);
|
||||
element->SetName("JimBob");
|
||||
//element->BGColor({0,255,0});
|
||||
element->BGColor({0, 64, 0});
|
||||
|
@@ -10,7 +10,7 @@ namespace JUI
|
||||
};
|
||||
|
||||
bool Button::IsMouseInside() const {
|
||||
DEBUG("IM A BUTTON DADDY")
|
||||
DEBUG("IM A BUTTON")
|
||||
float x = last_known_mouse_pos.x;
|
||||
float y = last_known_mouse_pos.y;
|
||||
auto pos = GetAbsolutePosition();
|
||||
@@ -20,4 +20,19 @@ namespace JUI
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Button::Update(float delta) {
|
||||
DEBUG("FUCK")
|
||||
if (IsMouseInside() && !mouse_inside_debounce)
|
||||
{
|
||||
MouseEnter.Invoke(last_known_mouse_pos);
|
||||
mouse_inside_debounce = true;
|
||||
}
|
||||
|
||||
if (!IsMouseInside() && mouse_inside_debounce)
|
||||
{
|
||||
MouseExit.Invoke(last_known_mouse_pos);
|
||||
mouse_inside_debounce = false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
#include "JGL/JGL.h"
|
||||
#include "JUI/Widgets/Rect.hpp"
|
||||
#include "jlog/jlog.hpp"
|
||||
|
||||
namespace JUI {
|
||||
Rect::Rect(): Widget() {}
|
||||
@@ -59,7 +60,6 @@ namespace JUI {
|
||||
|
||||
|
||||
void Rect::Update(float delta) {
|
||||
|
||||
if (IsMouseInside() && !mouse_inside_debounce)
|
||||
{
|
||||
MouseEnter.Invoke(last_known_mouse_pos);
|
||||
@@ -79,6 +79,7 @@ namespace JUI {
|
||||
}
|
||||
|
||||
bool Rect::IsMouseInside() const {
|
||||
DEBUG("CUM INSIDE ME")
|
||||
float x = last_known_mouse_pos.x;
|
||||
float y = last_known_mouse_pos.y;
|
||||
auto pos = GetAbsolutePosition();
|
||||
|
Reference in New Issue
Block a user