new widgets
This commit is contained in:
parent
3dce41ea39
commit
8f62c8f387
18 changed files with 373 additions and 43 deletions
|
|
@ -43,6 +43,7 @@ void EventHandler::processEvent() {
|
|||
switch (eventData.type) {
|
||||
case InputEvent::Type::MOUSE_POS:
|
||||
{
|
||||
mPointerPrev = mPointer;
|
||||
mPointer = eventData.mouseEvent;
|
||||
mEventQueue.popFront();
|
||||
break;
|
||||
|
|
@ -77,6 +78,8 @@ void EventHandler::processEvent() {
|
|||
|
||||
const Vec2F& EventHandler::getPointer() const { return mPointer; }
|
||||
|
||||
const Vec2F& EventHandler::getPointerPrev() const { return mPointerPrev; }
|
||||
|
||||
bool EventHandler::isPressed(InputID id) const {
|
||||
return mInputStates[(int) id].mCurrentState == InputState::State::PRESSED;
|
||||
}
|
||||
|
|
@ -92,4 +95,6 @@ bool EventHandler::isDown(InputID id) const {
|
|||
mInputStates[(int) id].mCurrentState == InputState::State::HOLD;
|
||||
}
|
||||
|
||||
halnf EventHandler::getScrollY() const { return 0; }
|
||||
halnf EventHandler::getScrollY() const { return 0; }
|
||||
|
||||
Vec2F EventHandler::getPointerDelta() const { return mPointer - mPointerPrev; }
|
||||
|
|
|
|||
|
|
@ -23,6 +23,17 @@ void Application::run() {
|
|||
|
||||
bool redrawNeeded = false;
|
||||
|
||||
// proc first frame by default
|
||||
{
|
||||
mWindow->processEvents();
|
||||
processFrame(eventHandler);
|
||||
|
||||
mGraphics->drawBegin();
|
||||
drawFrame(mGraphics->getCanvas());
|
||||
mGraphics->drawEnd();
|
||||
mWindow->draw();
|
||||
}
|
||||
|
||||
while (!mWindow->shouldClose()) {
|
||||
if (mProcTimer.isTimeout()) {
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,9 @@ namespace tp {
|
|||
void processEvent();
|
||||
|
||||
[[nodiscard]] const Vec2F& getPointer() const;
|
||||
[[nodiscard]] const Vec2F& getPointerPrev() const;
|
||||
[[nodiscard]] Vec2F getPointerDelta() const;
|
||||
|
||||
[[nodiscard]] bool isPressed(InputID id) const;
|
||||
[[nodiscard]] bool isReleased(InputID id) const;
|
||||
[[nodiscard]] bool isDown(InputID id) const;
|
||||
|
|
@ -85,6 +88,8 @@ namespace tp {
|
|||
|
||||
// input states
|
||||
Vec2F mPointer;
|
||||
Vec2F mPointerPrev;
|
||||
|
||||
halnf mPointerPressure = 0;
|
||||
|
||||
InputState mInputStates[(int) InputID::LAST_KEY_CODE]{};
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace tp {
|
|||
~Window();
|
||||
|
||||
public:
|
||||
static Window* createWindow(Vec2F size = { 1000.f, 900.f }, const char* title = "Window");
|
||||
static Window* createWindow(Vec2F size = { 500.f, 500.f }, const char* title = "Window");
|
||||
static void destroyWindow(Window* window);
|
||||
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue