feat(ui): stub CSimpleEditBox::DispatchAction

This commit is contained in:
fallenoak 2025-10-05 11:24:21 -05:00
parent 66ffd99696
commit a7a221af38
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
3 changed files with 34 additions and 4 deletions

8
src/ui/CObserver.hpp Normal file
View File

@ -0,0 +1,8 @@
#ifndef UI_C_OBSERVER_HPP
#define UI_C_OBSERVER_HPP
class CObserver {
// TODO
};
#endif

View File

@ -135,8 +135,9 @@ CSimpleEditBox::CSimpleEditBox(CSimpleFrame* parent) : CSimpleFrame(parent) {
CImVector cursorColor = { 0xFF, 0xFF, 0xFF, 0xFF };
this->m_cursor->SetTexture(cursorColor);
// TODO
// - initialize actions
for (auto& action : this->m_actions) {
action.obj = nullptr;
}
this->EnableEvent(SIMPLE_EVENT_CHAR, -1);
this->EnableEvent(SIMPLE_EVENT_KEY, -1);
@ -301,6 +302,10 @@ LABEL_12:
}
}
void CSimpleEditBox::DispatchAction(int32_t action) {
// TODO
}
void CSimpleEditBox::FontUpdated(CSimpleFontedFrameFont* font, int32_t a3) {
// TODO
}
@ -766,12 +771,12 @@ void CSimpleEditBox::OnEnterPressed() {
void CSimpleEditBox::OnEscapePressed() {
this->RunOnEscapePressedScript();
// TODO this->DispatchAction(EVENT_ESCAPE);
this->DispatchAction(EVENT_ESCAPE);
}
void CSimpleEditBox::OnTabPressed() {
this->RunOnTabPressedScript();
// TODO this->DispatchAction(EVENT_TAB);
this->DispatchAction(EVENT_TAB);
}
void CSimpleEditBox::OnFrameSizeChanged(float width, float height) {

View File

@ -4,11 +4,23 @@
#include "ui/CSimpleFrame.hpp"
#include "ui/CSimpleFontedFrame.hpp"
class CObserver;
class CSimpleFontString;
class CSimpleTexture;
class CSimpleEditBox : public CSimpleFrame, CSimpleFontedFrame {
public:
// Enums
enum {
EVENT_ENTER = 0,
EVENT_ESCAPE = 1,
EVENT_SPACE = 2,
EVENT_TAB = 3,
EVENT_CHANGED = 4,
EVENT_SET = 5,
NUM_EDITBOX_ACTIONS,
};
// Static variables
static CSimpleEditBox* s_currentFocus;
static int32_t s_metatable;
@ -48,6 +60,10 @@ class CSimpleEditBox : public CSimpleFrame, CSimpleFontedFrame {
float m_cursorBlinkSpeed = 0.5f;
float m_blinkElapsedTime = 0.0f;
TSGrowableArray<uint32_t> m_visibleLines;
struct {
uint32_t id;
CObserver* obj;
} m_actions[NUM_EDITBOX_ACTIONS];
int32_t m_imeInputMode = 0;
CRect m_editTextInset = {};
ScriptIx m_onEnterPressed;
@ -83,6 +99,7 @@ class CSimpleEditBox : public CSimpleFrame, CSimpleFontedFrame {
void DeleteForward(int32_t a2);
void DeleteHighlight(int32_t a2);
void DeleteSubstring(int32_t left, int32_t right, int32_t a4);
void DispatchAction(int32_t action);
int32_t GetNumToLen(int32_t offset, int32_t amount, bool a4);
void GrowText(int32_t size);
void Insert(uint32_t chr);