This commit is contained in:
IlyaShurupov 2024-10-08 14:23:49 +03:00 committed by Ilya Shurupov
parent 279cf58dff
commit 4b6e7da994
18 changed files with 592 additions and 203 deletions

View file

@ -52,6 +52,36 @@ void Canvas::rect(RectF rec, const RGBA& col, halnf round) {
nvgFill(mContext->vg);
}
void Canvas::debugCross(RectF rec, const RGBA& col) {
nvgBeginPath(mContext->vg);
nvgMoveTo(mContext->vg, rec.p1().x, rec.p1().y);
nvgLineTo(mContext->vg, rec.p3().x, rec.p3().y);
nvgMoveTo(mContext->vg, rec.p2().x, rec.p2().y);
nvgLineTo(mContext->vg, rec.p4().x, rec.p4().y);
nvgStrokeWidth(mContext->vg, 2);
nvgStrokeColor(mContext->vg, { col.r, col.g, col.b, col.a });
nvgStroke(mContext->vg);
// nvgFill(mContext->vg);
}
void Canvas::frame(RectF rec, const RGBA& col, halnf round) {
nvgBeginPath(mContext->vg);
nvgMoveTo(mContext->vg, rec.p1().x, rec.p1().y);
nvgLineTo(mContext->vg, rec.p2().x, rec.p2().y);
nvgLineTo(mContext->vg, rec.p3().x, rec.p3().y);
nvgLineTo(mContext->vg, rec.p4().x, rec.p4().y);
nvgLineTo(mContext->vg, rec.p1().x, rec.p1().y);
nvgStrokeWidth(mContext->vg, 2);
nvgStrokeColor(mContext->vg, { col.r, col.g, col.b, col.a });
nvgStroke(mContext->vg);
// nvgFill(mContext->vg);
}
void Canvas::circle(Vec2F pos, halnf size, const RGBA& col) {
pos += mOrigin;

View file

@ -122,16 +122,22 @@ Vec2F EventHandler::getPointer() const { return mPointer - mPointerOrigin; }
Vec2F EventHandler::getPointerPrev() const { return mPointerPrev - mPointerOrigin; }
bool EventHandler::isPressed(InputID id) const {
if (!mEnableKeyEvents) return false;
return mInputStates[(int) id].mCurrentState == InputState::State::PRESSED;
}
bool EventHandler::isReleased(InputID id) const {
if (!mEnableKeyEvents) return false;
return mInputStates[(int) id].mCurrentState == InputState::State::RELEASED;
}
halnf EventHandler::getPointerPressure() const { return mPointerPressure; }
halnf EventHandler::getPointerPressure() const {
if (!mEnableKeyEvents) return 0;
return mPointerPressure;
}
bool EventHandler::isDown(InputID id) const {
if (!mEnableKeyEvents) return false;
return mInputStates[(int) id].mCurrentState == InputState::State::PRESSED ||
mInputStates[(int) id].mCurrentState == InputState::State::HOLD;
}
@ -139,3 +145,7 @@ bool EventHandler::isDown(InputID id) const {
halnf EventHandler::getScrollY() const { return mScrollDelta.y; }
Vec2F EventHandler::getPointerDelta() const { return mPointer - mPointerPrev; }
void EventHandler::setEnableKeyEvents(bool enable) {
mEnableKeyEvents = enable;
}