2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-21 16:19:12 +00:00

SplitView updates; work on FileBrowser

This commit is contained in:
Jack Andersen
2015-12-21 15:33:27 -10:00
parent af56be4ac1
commit b00635e09e
9 changed files with 261 additions and 59 deletions

View File

@@ -27,6 +27,7 @@ private:
boo::IVertexFormat* m_bVtxFmt = nullptr; /* OpenGL only */
boo::IShaderDataBinding* m_bShaderBinding = nullptr;
RectangleConstraint m_constraint;
int m_nomWidth, m_nomHeight;
bool m_pressed = false;
bool m_hovered = false;
@@ -47,15 +48,16 @@ public:
Button(ViewResources& res, View& parentView,
IButtonBinding* controlBinding, const std::string& text,
Style style=Style::Block);
Style style=Style::Block, RectangleConstraint constraint=RectangleConstraint());
Button(ViewResources& res, View& parentView,
IButtonBinding* controlBinding, const std::string& text,
const Zeus::CColor& textColor, Style style=Style::Block);
const Zeus::CColor& textColor, Style style=Style::Block,
RectangleConstraint constraint=RectangleConstraint());
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseEnter(const boo::SWindowCoord&);
void mouseLeave(const boo::SWindowCoord&);
void resized(const boo::SWindowRect& rootView, const boo::SWindowRect& sub);
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
void draw(boo::IGraphicsCommandQueue* gfxQ);
void setText(const std::string& text, const Zeus::CColor& textColor);

View File

@@ -7,6 +7,7 @@
#include "TextField.hpp"
#include "ScrollView.hpp"
#include "Table.hpp"
#include "ViewResources.hpp"
#include <HECL/HECL.hpp>
namespace Specter
@@ -16,17 +17,68 @@ class FileBrowser : public ModalWindow
{
std::vector<HECL::SystemString> m_comps;
class LeftSide : public View
{
friend class FileBrowser;
FileBrowser& m_fb;
LeftSide(FileBrowser& fb, ViewResources& res) : View(res, fb), m_fb(fb) {}
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
void draw(boo::IGraphicsCommandQueue* gfxQ);
} m_left;
class RightSide : public View
{
friend class FileBrowser;
FileBrowser& m_fb;
RightSide(FileBrowser& fb, ViewResources& res) : View(res, fb), m_fb(fb) {}
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
void draw(boo::IGraphicsCommandQueue* gfxQ);
} m_right;
ViewChild<std::unique_ptr<SplitView>> m_split;
void okActivated();
struct OKButton : IButtonBinding
{
FileBrowser& m_fb;
ViewChild<std::unique_ptr<Button>> m_button;
std::string m_text;
OKButton(FileBrowser& fb, ViewResources& res, const std::string& text)
: m_fb(fb), m_text(text)
{
m_button.m_view.reset(new Button(res, fb, this, text, Button::Style::Block,
RectangleConstraint(100 * res.pixelFactor(), -1, RectangleConstraint::Test::Minimum)));
}
const char* name() const {return m_text.c_str();}
void activated(const boo::SWindowCoord&) {m_fb.okActivated();}
} m_ok;
void cancelActivated();
struct CancelButton : IButtonBinding
{
FileBrowser& m_fb;
ViewChild<std::unique_ptr<Button>> m_button;
CancelButton(FileBrowser& fb, ViewResources& res)
: m_fb(fb)
{
m_button.m_view.reset(new Button(res, fb, this, "Cancel", Button::Style::Block,
RectangleConstraint(100 * res.pixelFactor(), -1, RectangleConstraint::Test::Minimum)));
}
const char* name() const {return "Cancel";}
void activated(const boo::SWindowCoord&) {m_fb.cancelActivated();}
} m_cancel;
void pathButtonActivated(size_t idx);
struct PathButton : Specter::IButtonBinding
struct PathButton : IButtonBinding
{
FileBrowser& m_fb;
size_t m_idx;
Specter::ViewChild<std::unique_ptr<Specter::Button>> m_button;
ViewChild<std::unique_ptr<Button>> m_button;
PathButton(FileBrowser& fb, ViewResources& res, size_t idx, const HECL::SystemString& str)
: m_fb(fb), m_idx(idx)
{
HECL::SystemUTF8View utf8View(str);
m_button.m_view.reset(new Specter::Button(res, fb, this, utf8View));
m_button.m_view.reset(new Button(res, fb, this, utf8View));
}
const char* name() const {return m_button.m_view->getText().c_str();}
void activated(const boo::SWindowCoord&) {m_fb.pathButtonActivated(m_idx);}
@@ -34,8 +86,8 @@ class FileBrowser : public ModalWindow
friend struct PathButton;
std::vector<PathButton> m_pathButtons;
Specter::ViewChild<std::unique_ptr<Specter::TextField>> m_fileField;
struct FileFieldBind : Specter::IStringBinding
ViewChild<std::unique_ptr<TextField>> m_fileField;
struct FileFieldBind : IStringBinding
{
FileBrowser& m_browser;
FileFieldBind(FileBrowser& browser) : m_browser(browser) {}
@@ -45,13 +97,13 @@ class FileBrowser : public ModalWindow
}
} m_fileFieldBind;
Specter::ViewChild<std::unique_ptr<Specter::ScrollView>> m_fileScroll;
Specter::ViewChild<std::unique_ptr<Specter::Table>> m_fileListing;
ViewChild<std::unique_ptr<ScrollView>> m_fileScroll;
ViewChild<std::unique_ptr<Table>> m_fileListing;
public:
FileBrowser(ViewResources& res, View& parentView)
: FileBrowser(res, parentView, HECL::GetcwdStr()) {}
FileBrowser(ViewResources& res, View& parentView, const HECL::SystemString& initialPath);
FileBrowser(ViewResources& res, View& parentView, const std::string& title)
: FileBrowser(res, parentView, title, HECL::GetcwdStr()) {}
FileBrowser(ViewResources& res, View& parentView, const std::string& title, const HECL::SystemString& initialPath);
void updateContentOpacity(float opacity);

View File

@@ -80,10 +80,41 @@ public:
m_activeDragView = dragView;
}
bool m_hSplitHover = false;
void setHorizontalSplitHover(bool hover)
{
m_hSplitHover = hover;
_updateCursor();
}
bool m_vSplitHover = false;
void setVerticalSplitHover(bool hover)
{
m_vSplitHover = hover;
_updateCursor();
}
bool m_textFieldHover = false;
void setTextFieldHover(bool hover)
{
m_textFieldHover = hover;
_updateCursor();
}
void resetTooltip(ViewResources& res);
void displayTooltip(const std::string& name, const std::string& help);
private:
void _updateCursor()
{
if (m_vSplitHover)
m_window->setCursor(boo::EMouseCursor::HorizontalArrow);
else if (m_hSplitHover)
m_window->setCursor(boo::EMouseCursor::VerticalArrow);
else if (m_textFieldHover)
m_window->setCursor(boo::EMouseCursor::IBeam);
else
m_window->setCursor(boo::EMouseCursor::Pointer);
}
View* m_view = nullptr;
std::unique_ptr<Tooltip> m_tooltip;
};

View File

@@ -26,19 +26,16 @@ public:
private:
Axis m_axis;
float m_slide = 0.5;
void _setSlide(float slide);
bool m_dragging = false;
void setSlide(float slide)
{
m_slide = std::min(std::max(slide, 0.0f), 1.0f);
updateSize();
}
ViewChild<View*> m_views[2];
ViewBlock m_splitBlock;
boo::IGraphicsBufferD* m_splitBlockBuf;
TexShaderVert m_splitVerts[4];
int m_clearanceA, m_clearanceB;
void setHorizontalVerts(int width)
{
m_splitVerts[0].m_pos.assign(0, 2, 0);
@@ -67,8 +64,9 @@ private:
boo::IVertexFormat* m_splitVtxFmt; /* OpenGL only */
boo::IShaderDataBinding* m_splitShaderBinding;
public:
SplitView(ViewResources& res, View& parentView, Axis axis);
SplitView(ViewResources& res, View& parentView, Axis axis, int clearanceA=-1, int clearanceB=-1);
View* setContentView(int slot, View* view);
void setSlide(float slide);
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseMove(const boo::SWindowCoord&);
@@ -76,6 +74,13 @@ public:
void mouseLeave(const boo::SWindowCoord&);
void resized(const boo::SWindowRect& rootView, const boo::SWindowRect& sub);
void draw(boo::IGraphicsCommandQueue* gfxQ);
void setMultiplyColor(const Zeus::CColor& color)
{
View::setMultiplyColor(color);
m_splitBlock.m_color = color;
m_splitBlockBuf->load(&m_splitBlock, sizeof(m_splitBlock));
}
};
}