2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-17 20:45:23 +00:00

TextField updates

This commit is contained in:
Jack Andersen
2015-12-20 11:59:23 -10:00
parent 95fd2f90a9
commit 49ff010a20
12 changed files with 192 additions and 200 deletions

View File

@@ -21,7 +21,7 @@ class FileBrowser : public ModalWindow
{
FileBrowser& m_fb;
size_t m_idx;
Specter::ViewChild<Specter::Button> m_button;
Specter::ViewChild<std::unique_ptr<Specter::Button>> m_button;
PathButton(FileBrowser& fb, ViewResources& res, size_t idx, const HECL::SystemString& str)
: m_fb(fb), m_idx(idx)
{
@@ -34,7 +34,7 @@ class FileBrowser : public ModalWindow
friend struct PathButton;
std::vector<PathButton> m_pathButtons;
Specter::ViewChild<Specter::TextField> m_fileField;
Specter::ViewChild<std::unique_ptr<Specter::TextField>> m_fileField;
struct FileFieldBind : Specter::IStringBinding
{
FileBrowser& m_browser;
@@ -45,8 +45,8 @@ class FileBrowser : public ModalWindow
}
} m_fileFieldBind;
Specter::ViewChild<Specter::ScrollView> m_fileScroll;
Specter::ViewChild<Specter::Table> m_fileListing;
Specter::ViewChild<std::unique_ptr<Specter::ScrollView>> m_fileScroll;
Specter::ViewChild<std::unique_ptr<Specter::Table>> m_fileListing;
public:
FileBrowser(ViewResources& res, View& parentView)

View File

@@ -28,6 +28,7 @@ class RootView : public View
IViewManager& m_viewMan;
ViewResources* m_viewRes;
View* m_activeTextView = nullptr;
View* m_activeDragView = nullptr;
DeferredWindowEvents<RootView> m_events;
@@ -71,7 +72,12 @@ public:
if (m_activeTextView)
m_activeTextView->setActive(false);
m_activeTextView = textView;
textView->setActive(true);
if (textView)
textView->setActive(true);
}
void setActiveDragView(View* dragView)
{
m_activeDragView = dragView;
}
void resetTooltip(ViewResources& res);

View File

@@ -34,13 +34,7 @@ private:
updateSize();
}
struct Child
{
View* m_view = nullptr;
bool m_mouseIn = false;
bool m_mouseDown = false;
};
Child m_views[2];
ViewChild<View*> m_views[2];
ViewBlock m_splitBlock;
boo::IGraphicsBufferD* m_splitBlockBuf;
TexShaderVert m_splitVerts[4];

View File

@@ -24,6 +24,11 @@ class TextField : public Control
size_t m_selectionCount = 0;
size_t m_cursorPos = 0;
size_t m_cursorFrames = 0;
size_t m_clickFrames = 15;
size_t m_clickFrames2 = 15;
size_t m_dragStart = 0;
size_t m_dragging = 0;
bool m_active = false;

View File

@@ -66,6 +66,16 @@ public:
RenderGlyph(int& adv, const FontAtlas::Glyph& glyph, const Zeus::CColor& defaultColor);
};
struct RenderGlyphInfo
{
uint32_t m_char;
std::pair<int,int> m_dims;
int m_adv;
bool m_space = false;
RenderGlyphInfo(uint32_t ch, int width, int height, int adv)
: m_char(ch), m_dims(width, height), m_adv(adv), m_space(iswspace(ch)) {}
};
std::vector<RenderGlyph>& accessGlyphs() {return m_glyphs;}
const std::vector<RenderGlyph>& accessGlyphs() const {return m_glyphs;}
void updateGlyphs() {m_valid = false;}
@@ -88,11 +98,11 @@ public:
std::pair<int,int> queryGlyphDimensions(size_t pos) const;
size_t reverseSelectGlyph(int x) const;
int queryReverseAdvance(size_t idx) const;
std::pair<size_t,size_t> queryWholeWordRange(size_t idx) const;
private:
std::vector<RenderGlyph> m_glyphs;
std::vector<std::pair<int,int>> m_glyphDims;
std::vector<int> m_glyphAdvs;
std::vector<RenderGlyphInfo> m_glyphInfo;
};
}

View File

@@ -25,14 +25,7 @@ public:
};
private:
Position m_tbPos;
struct Child
{
View* m_view = nullptr;
bool m_mouseIn = false;
bool m_mouseDown = false;
Child(View* v) : m_view(v) {}
};
std::vector<Child> m_children;
std::vector<ViewChild<View*>> m_children;
ViewBlock m_tbBlock;
boo::IGraphicsBufferD* m_tbBlockBuf;
@@ -106,7 +99,11 @@ public:
int nominalHeight() const {return m_nomHeight;}
void clear() {m_children.clear();}
void push_back(View* v) {m_children.push_back(v);}
void push_back(View* v)
{
m_children.emplace_back();
m_children.back().m_view = v;
}
};
}

View File

@@ -209,12 +209,12 @@ public:
virtual void draw(boo::IGraphicsCommandQueue* gfxQ);
};
template <class ViewType>
template <class ViewPtrType>
struct ViewChild
{
std::unique_ptr<ViewType> m_view;
ViewPtrType m_view;
bool m_mouseIn = false;
bool m_mouseDown = false;
int m_mouseDown = 0;
void mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
{
@@ -222,10 +222,10 @@ struct ViewChild
return;
if (m_view->subRect().coordInRect(coord))
{
if (!m_mouseDown)
if ((m_mouseDown & 1 << int(button)) == 0)
{
m_view->mouseDown(coord, button, mod);
m_mouseDown = true;
m_mouseDown |= 1 << int(button);
}
}
}
@@ -234,10 +234,10 @@ struct ViewChild
{
if (!m_view)
return;
if (m_mouseDown)
if ((m_mouseDown & 1 << int(button)) != 0)
{
m_view->mouseUp(coord, button, mod);
m_mouseDown = false;
m_mouseDown &= ~(1 << int(button));
}
}