mirror of https://github.com/AxioDL/metaforce.git
SplitView updates; work on FileBrowser
This commit is contained in:
parent
af56be4ac1
commit
b00635e09e
|
@ -27,6 +27,7 @@ private:
|
||||||
boo::IVertexFormat* m_bVtxFmt = nullptr; /* OpenGL only */
|
boo::IVertexFormat* m_bVtxFmt = nullptr; /* OpenGL only */
|
||||||
boo::IShaderDataBinding* m_bShaderBinding = nullptr;
|
boo::IShaderDataBinding* m_bShaderBinding = nullptr;
|
||||||
|
|
||||||
|
RectangleConstraint m_constraint;
|
||||||
int m_nomWidth, m_nomHeight;
|
int m_nomWidth, m_nomHeight;
|
||||||
bool m_pressed = false;
|
bool m_pressed = false;
|
||||||
bool m_hovered = false;
|
bool m_hovered = false;
|
||||||
|
@ -47,15 +48,16 @@ public:
|
||||||
|
|
||||||
Button(ViewResources& res, View& parentView,
|
Button(ViewResources& res, View& parentView,
|
||||||
IButtonBinding* controlBinding, const std::string& text,
|
IButtonBinding* controlBinding, const std::string& text,
|
||||||
Style style=Style::Block);
|
Style style=Style::Block, RectangleConstraint constraint=RectangleConstraint());
|
||||||
Button(ViewResources& res, View& parentView,
|
Button(ViewResources& res, View& parentView,
|
||||||
IButtonBinding* controlBinding, const std::string& text,
|
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 mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
void mouseEnter(const boo::SWindowCoord&);
|
void mouseEnter(const boo::SWindowCoord&);
|
||||||
void mouseLeave(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 draw(boo::IGraphicsCommandQueue* gfxQ);
|
||||||
|
|
||||||
void setText(const std::string& text, const Zeus::CColor& textColor);
|
void setText(const std::string& text, const Zeus::CColor& textColor);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "TextField.hpp"
|
#include "TextField.hpp"
|
||||||
#include "ScrollView.hpp"
|
#include "ScrollView.hpp"
|
||||||
#include "Table.hpp"
|
#include "Table.hpp"
|
||||||
|
#include "ViewResources.hpp"
|
||||||
#include <HECL/HECL.hpp>
|
#include <HECL/HECL.hpp>
|
||||||
|
|
||||||
namespace Specter
|
namespace Specter
|
||||||
|
@ -16,17 +17,68 @@ class FileBrowser : public ModalWindow
|
||||||
{
|
{
|
||||||
std::vector<HECL::SystemString> m_comps;
|
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);
|
void pathButtonActivated(size_t idx);
|
||||||
struct PathButton : Specter::IButtonBinding
|
struct PathButton : IButtonBinding
|
||||||
{
|
{
|
||||||
FileBrowser& m_fb;
|
FileBrowser& m_fb;
|
||||||
size_t m_idx;
|
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)
|
PathButton(FileBrowser& fb, ViewResources& res, size_t idx, const HECL::SystemString& str)
|
||||||
: m_fb(fb), m_idx(idx)
|
: m_fb(fb), m_idx(idx)
|
||||||
{
|
{
|
||||||
HECL::SystemUTF8View utf8View(str);
|
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();}
|
const char* name() const {return m_button.m_view->getText().c_str();}
|
||||||
void activated(const boo::SWindowCoord&) {m_fb.pathButtonActivated(m_idx);}
|
void activated(const boo::SWindowCoord&) {m_fb.pathButtonActivated(m_idx);}
|
||||||
|
@ -34,8 +86,8 @@ class FileBrowser : public ModalWindow
|
||||||
friend struct PathButton;
|
friend struct PathButton;
|
||||||
std::vector<PathButton> m_pathButtons;
|
std::vector<PathButton> m_pathButtons;
|
||||||
|
|
||||||
Specter::ViewChild<std::unique_ptr<Specter::TextField>> m_fileField;
|
ViewChild<std::unique_ptr<TextField>> m_fileField;
|
||||||
struct FileFieldBind : Specter::IStringBinding
|
struct FileFieldBind : IStringBinding
|
||||||
{
|
{
|
||||||
FileBrowser& m_browser;
|
FileBrowser& m_browser;
|
||||||
FileFieldBind(FileBrowser& browser) : m_browser(browser) {}
|
FileFieldBind(FileBrowser& browser) : m_browser(browser) {}
|
||||||
|
@ -45,13 +97,13 @@ class FileBrowser : public ModalWindow
|
||||||
}
|
}
|
||||||
} m_fileFieldBind;
|
} m_fileFieldBind;
|
||||||
|
|
||||||
Specter::ViewChild<std::unique_ptr<Specter::ScrollView>> m_fileScroll;
|
ViewChild<std::unique_ptr<ScrollView>> m_fileScroll;
|
||||||
Specter::ViewChild<std::unique_ptr<Specter::Table>> m_fileListing;
|
ViewChild<std::unique_ptr<Table>> m_fileListing;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FileBrowser(ViewResources& res, View& parentView)
|
FileBrowser(ViewResources& res, View& parentView, const std::string& title)
|
||||||
: FileBrowser(res, parentView, HECL::GetcwdStr()) {}
|
: FileBrowser(res, parentView, title, HECL::GetcwdStr()) {}
|
||||||
FileBrowser(ViewResources& res, View& parentView, const HECL::SystemString& initialPath);
|
FileBrowser(ViewResources& res, View& parentView, const std::string& title, const HECL::SystemString& initialPath);
|
||||||
|
|
||||||
void updateContentOpacity(float opacity);
|
void updateContentOpacity(float opacity);
|
||||||
|
|
||||||
|
|
|
@ -80,10 +80,41 @@ public:
|
||||||
m_activeDragView = dragView;
|
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 resetTooltip(ViewResources& res);
|
||||||
void displayTooltip(const std::string& name, const std::string& help);
|
void displayTooltip(const std::string& name, const std::string& help);
|
||||||
|
|
||||||
private:
|
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;
|
View* m_view = nullptr;
|
||||||
std::unique_ptr<Tooltip> m_tooltip;
|
std::unique_ptr<Tooltip> m_tooltip;
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,19 +26,16 @@ public:
|
||||||
private:
|
private:
|
||||||
Axis m_axis;
|
Axis m_axis;
|
||||||
float m_slide = 0.5;
|
float m_slide = 0.5;
|
||||||
|
void _setSlide(float slide);
|
||||||
bool m_dragging = false;
|
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];
|
ViewChild<View*> m_views[2];
|
||||||
ViewBlock m_splitBlock;
|
ViewBlock m_splitBlock;
|
||||||
boo::IGraphicsBufferD* m_splitBlockBuf;
|
boo::IGraphicsBufferD* m_splitBlockBuf;
|
||||||
TexShaderVert m_splitVerts[4];
|
TexShaderVert m_splitVerts[4];
|
||||||
|
|
||||||
|
int m_clearanceA, m_clearanceB;
|
||||||
|
|
||||||
void setHorizontalVerts(int width)
|
void setHorizontalVerts(int width)
|
||||||
{
|
{
|
||||||
m_splitVerts[0].m_pos.assign(0, 2, 0);
|
m_splitVerts[0].m_pos.assign(0, 2, 0);
|
||||||
|
@ -67,8 +64,9 @@ private:
|
||||||
boo::IVertexFormat* m_splitVtxFmt; /* OpenGL only */
|
boo::IVertexFormat* m_splitVtxFmt; /* OpenGL only */
|
||||||
boo::IShaderDataBinding* m_splitShaderBinding;
|
boo::IShaderDataBinding* m_splitShaderBinding;
|
||||||
public:
|
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);
|
View* setContentView(int slot, View* view);
|
||||||
|
void setSlide(float slide);
|
||||||
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
void mouseMove(const boo::SWindowCoord&);
|
void mouseMove(const boo::SWindowCoord&);
|
||||||
|
@ -76,6 +74,13 @@ public:
|
||||||
void mouseLeave(const boo::SWindowCoord&);
|
void mouseLeave(const boo::SWindowCoord&);
|
||||||
void resized(const boo::SWindowRect& rootView, const boo::SWindowRect& sub);
|
void resized(const boo::SWindowRect& rootView, const boo::SWindowRect& sub);
|
||||||
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
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));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,13 +13,15 @@ void Button::Resources::init(boo::IGraphicsDataFactory* factory, const ThemeData
|
||||||
|
|
||||||
Button::Button(ViewResources& res, View& parentView,
|
Button::Button(ViewResources& res, View& parentView,
|
||||||
IButtonBinding* controlBinding, const std::string& text,
|
IButtonBinding* controlBinding, const std::string& text,
|
||||||
Style style)
|
Style style, RectangleConstraint constraint)
|
||||||
: Button(res, parentView, controlBinding, text, res.themeData().uiText(), style) {}
|
: Button(res, parentView, controlBinding, text, res.themeData().uiText(), style, constraint) {}
|
||||||
|
|
||||||
Button::Button(ViewResources& res, View& parentView,
|
Button::Button(ViewResources& res, View& parentView,
|
||||||
IButtonBinding* controlBinding, const std::string& text,
|
IButtonBinding* controlBinding, const std::string& text,
|
||||||
const Zeus::CColor& textColor, Style style)
|
const Zeus::CColor& textColor, Style style,
|
||||||
: Control(res, parentView, controlBinding), m_style(style), m_textColor(textColor), m_textStr(text)
|
RectangleConstraint constraint)
|
||||||
|
: Control(res, parentView, controlBinding),
|
||||||
|
m_style(style), m_textColor(textColor), m_textStr(text), m_constraint(constraint)
|
||||||
{
|
{
|
||||||
m_bVertsBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SolidShaderVert), 28);
|
m_bVertsBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SolidShaderVert), 28);
|
||||||
|
|
||||||
|
@ -64,7 +66,7 @@ Button::Button(ViewResources& res, View& parentView,
|
||||||
m_bVertsBuf->load(m_verts, sizeof(SolidShaderVert) * 4);
|
m_bVertsBuf->load(m_verts, sizeof(SolidShaderVert) * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_text.reset(new TextView(res, *this, res.m_mainFont));
|
m_text.reset(new TextView(res, *this, res.m_mainFont, TextView::Alignment::Center));
|
||||||
setText(m_textStr);
|
setText(m_textStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,8 +86,9 @@ void Button::setText(const std::string& text, const Zeus::CColor& textColor)
|
||||||
|
|
||||||
if (m_style == Style::Block)
|
if (m_style == Style::Block)
|
||||||
{
|
{
|
||||||
width = m_text->nominalWidth() + 12 * pf;
|
std::pair<int,int> constraint = m_constraint.solve(m_text->nominalWidth() + 12 * pf, 20 * pf);
|
||||||
height = 20 * pf;
|
width = constraint.first;
|
||||||
|
height = constraint.second;
|
||||||
m_verts[0].m_pos.assign(1, height+1, 0);
|
m_verts[0].m_pos.assign(1, height+1, 0);
|
||||||
m_verts[1].m_pos.assign(1, 1, 0);
|
m_verts[1].m_pos.assign(1, 1, 0);
|
||||||
m_verts[2].m_pos.assign(width+1, height+1, 0);
|
m_verts[2].m_pos.assign(width+1, height+1, 0);
|
||||||
|
@ -271,10 +274,8 @@ void Button::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||||
boo::SWindowRect textRect = sub;
|
boo::SWindowRect textRect = sub;
|
||||||
float pf = rootView().viewRes().pixelFactor();
|
float pf = rootView().viewRes().pixelFactor();
|
||||||
if (m_style == Style::Block)
|
if (m_style == Style::Block)
|
||||||
{
|
|
||||||
textRect.location[0] += 5 * pf;
|
|
||||||
textRect.location[1] += 7 * pf;
|
textRect.location[1] += 7 * pf;
|
||||||
}
|
textRect.location[0] += sub.size[0] / 2;
|
||||||
m_text->resized(root, textRect);
|
m_text->resized(root, textRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,12 +39,17 @@ static std::vector<HECL::SystemString> PathComponents(const HECL::SystemString&
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileBrowser::FileBrowser(ViewResources& res, View& parentView, const HECL::SystemString& initialPath)
|
FileBrowser::FileBrowser(ViewResources& res, View& parentView, const std::string& title,
|
||||||
|
const HECL::SystemString& initialPath)
|
||||||
: ModalWindow(res, parentView, RectangleConstraint(BROWSER_MIN_WIDTH * res.pixelFactor(),
|
: ModalWindow(res, parentView, RectangleConstraint(BROWSER_MIN_WIDTH * res.pixelFactor(),
|
||||||
BROWSER_MIN_HEIGHT * res.pixelFactor(),
|
BROWSER_MIN_HEIGHT * res.pixelFactor(),
|
||||||
RectangleConstraint::Test::Minimum,
|
RectangleConstraint::Test::Minimum,
|
||||||
RectangleConstraint::Test::Minimum)),
|
RectangleConstraint::Test::Minimum)),
|
||||||
m_comps(PathComponents(initialPath)),
|
m_comps(PathComponents(initialPath)),
|
||||||
|
m_left(*this, res),
|
||||||
|
m_right(*this, res),
|
||||||
|
m_ok(*this, res, title),
|
||||||
|
m_cancel(*this, res),
|
||||||
m_fileFieldBind(*this)
|
m_fileFieldBind(*this)
|
||||||
{
|
{
|
||||||
commitResources(res);
|
commitResources(res);
|
||||||
|
@ -56,15 +61,36 @@ FileBrowser::FileBrowser(ViewResources& res, View& parentView, const HECL::Syste
|
||||||
m_pathButtons.emplace_back(*this, res, idx++, c);
|
m_pathButtons.emplace_back(*this, res, idx++, c);
|
||||||
|
|
||||||
m_fileField.m_view.reset(new TextField(res, *this, &m_fileFieldBind));
|
m_fileField.m_view.reset(new TextField(res, *this, &m_fileFieldBind));
|
||||||
|
m_fileListing.m_view.reset(new Table(res, *this));
|
||||||
|
m_fileListing.m_view->setBackground(Zeus::CColor::skBlue);
|
||||||
|
|
||||||
|
m_split.m_view.reset(new SplitView(res, *this, SplitView::Axis::Vertical,
|
||||||
|
200 * res.pixelFactor(), 400 * res.pixelFactor()));
|
||||||
|
m_split.m_view->setContentView(0, &m_left);
|
||||||
|
m_split.m_view->setContentView(1, &m_right);
|
||||||
|
m_split.m_view->setSlide(0.2);
|
||||||
|
|
||||||
updateContentOpacity(0.0);
|
updateContentOpacity(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::updateContentOpacity(float opacity)
|
void FileBrowser::updateContentOpacity(float opacity)
|
||||||
{
|
{
|
||||||
Zeus::CColor color = Zeus::CColor::lerp({1,1,1,0}, {1,1,1,1}, opacity);
|
Zeus::CColor color = Zeus::CColor::lerp({1,1,1,0}, {1,1,1,1}, opacity);
|
||||||
|
m_split.m_view->setMultiplyColor(color);
|
||||||
for (PathButton& b : m_pathButtons)
|
for (PathButton& b : m_pathButtons)
|
||||||
b.m_button.m_view->setMultiplyColor(color);
|
b.m_button.m_view->setMultiplyColor(color);
|
||||||
m_fileField.m_view->setMultiplyColor(color);
|
m_fileField.m_view->setMultiplyColor(color);
|
||||||
|
m_fileListing.m_view->setMultiplyColor(color);
|
||||||
|
m_ok.m_button.m_view->setMultiplyColor(color);
|
||||||
|
m_cancel.m_button.m_view->setMultiplyColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileBrowser::okActivated()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileBrowser::cancelActivated()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::pathButtonActivated(size_t idx)
|
void FileBrowser::pathButtonActivated(size_t idx)
|
||||||
|
@ -75,23 +101,35 @@ void FileBrowser::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton bu
|
||||||
{
|
{
|
||||||
if (skipBuildInAnimation())
|
if (skipBuildInAnimation())
|
||||||
return;
|
return;
|
||||||
|
m_split.mouseDown(coord, button, mod);
|
||||||
for (PathButton& b : m_pathButtons)
|
for (PathButton& b : m_pathButtons)
|
||||||
b.m_button.mouseDown(coord, button, mod);
|
b.m_button.mouseDown(coord, button, mod);
|
||||||
m_fileField.mouseDown(coord, button, mod);
|
m_fileField.mouseDown(coord, button, mod);
|
||||||
|
m_fileListing.mouseDown(coord, button, mod);
|
||||||
|
m_ok.m_button.mouseDown(coord, button, mod);
|
||||||
|
m_cancel.m_button.mouseDown(coord, button, mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
void FileBrowser::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
||||||
{
|
{
|
||||||
|
m_split.mouseUp(coord, button, mod);
|
||||||
for (PathButton& b : m_pathButtons)
|
for (PathButton& b : m_pathButtons)
|
||||||
b.m_button.mouseUp(coord, button, mod);
|
b.m_button.mouseUp(coord, button, mod);
|
||||||
m_fileField.mouseUp(coord, button, mod);
|
m_fileField.mouseUp(coord, button, mod);
|
||||||
|
m_fileListing.mouseUp(coord, button, mod);
|
||||||
|
m_ok.m_button.mouseUp(coord, button, mod);
|
||||||
|
m_cancel.m_button.mouseUp(coord, button, mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::mouseMove(const boo::SWindowCoord& coord)
|
void FileBrowser::mouseMove(const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
|
m_split.mouseMove(coord);
|
||||||
for (PathButton& b : m_pathButtons)
|
for (PathButton& b : m_pathButtons)
|
||||||
b.m_button.mouseMove(coord);
|
b.m_button.mouseMove(coord);
|
||||||
m_fileField.mouseMove(coord);
|
m_fileField.mouseMove(coord);
|
||||||
|
m_fileListing.mouseMove(coord);
|
||||||
|
m_ok.m_button.mouseMove(coord);
|
||||||
|
m_cancel.m_button.mouseMove(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::mouseEnter(const boo::SWindowCoord& coord)
|
void FileBrowser::mouseEnter(const boo::SWindowCoord& coord)
|
||||||
|
@ -100,9 +138,13 @@ void FileBrowser::mouseEnter(const boo::SWindowCoord& coord)
|
||||||
|
|
||||||
void FileBrowser::mouseLeave(const boo::SWindowCoord& coord)
|
void FileBrowser::mouseLeave(const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
|
m_split.mouseLeave(coord);
|
||||||
for (PathButton& b : m_pathButtons)
|
for (PathButton& b : m_pathButtons)
|
||||||
b.m_button.mouseLeave(coord);
|
b.m_button.mouseLeave(coord);
|
||||||
m_fileField.mouseLeave(coord);
|
m_fileField.mouseLeave(coord);
|
||||||
|
m_fileListing.mouseLeave(coord);
|
||||||
|
m_ok.m_button.mouseLeave(coord);
|
||||||
|
m_cancel.m_button.mouseLeave(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& scroll)
|
void FileBrowser::scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& scroll)
|
||||||
|
@ -127,13 +169,26 @@ void FileBrowser::resized(const boo::SWindowRect& root, const boo::SWindowRect&
|
||||||
float pf = rootView().viewRes().pixelFactor();
|
float pf = rootView().viewRes().pixelFactor();
|
||||||
|
|
||||||
boo::SWindowRect centerRect = subRect();
|
boo::SWindowRect centerRect = subRect();
|
||||||
centerRect.location[0] = root.size[0] / 2 - (centerRect.size[0] / 2.0);
|
centerRect.location[0] = root.size[0] / 2 - (centerRect.size[0] / 2.0) + 2 * pf;
|
||||||
centerRect.location[1] = root.size[1] / 2 - (centerRect.size[1] / 2.0);
|
centerRect.location[1] = root.size[1] / 2 - (centerRect.size[1] / 2.0) + 2 * pf;;
|
||||||
|
centerRect.size[0] -= 4 * pf;
|
||||||
|
centerRect.size[1] -= 4 * pf;
|
||||||
|
|
||||||
boo::SWindowRect pathRect = centerRect;
|
m_split.m_view->resized(root, centerRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileBrowser::LeftSide::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileBrowser::RightSide::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||||
|
{
|
||||||
|
float pf = rootView().viewRes().pixelFactor();
|
||||||
|
|
||||||
|
boo::SWindowRect pathRect = sub;
|
||||||
pathRect.location[0] += 25 * pf;
|
pathRect.location[0] += 25 * pf;
|
||||||
pathRect.location[1] += pathRect.size[1] - 50 * pf;
|
pathRect.location[1] += pathRect.size[1] - 50 * pf;
|
||||||
for (PathButton& b : m_pathButtons)
|
for (PathButton& b : m_fb.m_pathButtons)
|
||||||
{
|
{
|
||||||
pathRect.size[0] = b.m_button.m_view->nominalWidth();
|
pathRect.size[0] = b.m_button.m_view->nominalWidth();
|
||||||
pathRect.size[1] = b.m_button.m_view->nominalHeight();
|
pathRect.size[1] = b.m_button.m_view->nominalHeight();
|
||||||
|
@ -141,25 +196,52 @@ void FileBrowser::resized(const boo::SWindowRect& root, const boo::SWindowRect&
|
||||||
pathRect.location[0] += pathRect.size[0] + 2;
|
pathRect.location[0] += pathRect.size[0] + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
pathRect.location[0] = centerRect.location[0] + 25 * pf;
|
pathRect.location[0] = sub.location[0] + 25 * pf;
|
||||||
pathRect.location[1] -= 25 * pf;
|
pathRect.location[1] -= 25 * pf;
|
||||||
pathRect.size[0] = centerRect.size[0] - 50 * pf;
|
pathRect.size[0] = sub.size[0] - 155 * pf;
|
||||||
pathRect.size[1] = m_fileField.m_view->nominalHeight();
|
pathRect.size[1] = m_fb.m_fileField.m_view->nominalHeight();
|
||||||
m_fileField.m_view->resized(root, pathRect);
|
m_fb.m_fileField.m_view->resized(root, pathRect);
|
||||||
|
|
||||||
|
pathRect.location[1] = sub.location[1] + 25 * pf;
|
||||||
|
pathRect.size[0] = sub.size[0] - 50 * pf;
|
||||||
|
pathRect.size[1] = sub.size[1] - 105 * pf;
|
||||||
|
m_fb.m_fileListing.m_view->resized(root, pathRect);
|
||||||
|
|
||||||
|
boo::SWindowRect buttonRect = sub;
|
||||||
|
buttonRect.size[0] = m_fb.m_ok.m_button.m_view->nominalWidth();
|
||||||
|
buttonRect.size[1] = m_fb.m_ok.m_button.m_view->nominalHeight();
|
||||||
|
buttonRect.location[0] += sub.size[0] - 25 * pf - buttonRect.size[0];
|
||||||
|
buttonRect.location[1] += sub.size[1] - 50 * pf;
|
||||||
|
m_fb.m_ok.m_button.m_view->resized(root, buttonRect);
|
||||||
|
buttonRect.location[1] -= 25 * pf;
|
||||||
|
m_fb.m_cancel.m_button.m_view->resized(root, buttonRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::think()
|
void FileBrowser::think()
|
||||||
{
|
{
|
||||||
ModalWindow::think();
|
ModalWindow::think();
|
||||||
m_fileField.m_view->think();
|
m_fileField.m_view->think();
|
||||||
|
m_fileListing.m_view->think();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::draw(boo::IGraphicsCommandQueue* gfxQ)
|
void FileBrowser::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
{
|
{
|
||||||
ModalWindow::draw(gfxQ);
|
ModalWindow::draw(gfxQ);
|
||||||
for (PathButton& b : m_pathButtons)
|
m_split.m_view->draw(gfxQ);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileBrowser::LeftSide::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileBrowser::RightSide::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
|
{
|
||||||
|
for (PathButton& b : m_fb.m_pathButtons)
|
||||||
b.m_button.m_view->draw(gfxQ);
|
b.m_button.m_view->draw(gfxQ);
|
||||||
m_fileField.m_view->draw(gfxQ);
|
m_fb.m_fileField.m_view->draw(gfxQ);
|
||||||
|
m_fb.m_fileListing.m_view->draw(gfxQ);
|
||||||
|
m_fb.m_ok.m_button.m_view->draw(gfxQ);
|
||||||
|
m_fb.m_cancel.m_button.m_view->draw(gfxQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ void SplitView::Resources::init(boo::IGraphicsDataFactory* factory, const ThemeD
|
||||||
m_shadingTex = factory->newStaticTexture(3, 1, 1, boo::TextureFormat::RGBA8, tex, 12);
|
m_shadingTex = factory->newStaticTexture(3, 1, 1, boo::TextureFormat::RGBA8, tex, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
SplitView::SplitView(ViewResources& system, View& parentView, Axis axis)
|
SplitView::SplitView(ViewResources& system, View& parentView, Axis axis, int clearanceA, int clearanceB)
|
||||||
: View(system, parentView), m_axis(axis)
|
: View(system, parentView), m_axis(axis), m_clearanceA(clearanceA), m_clearanceB(clearanceB)
|
||||||
{
|
{
|
||||||
m_splitBlockBuf = system.m_factory->newDynamicBuffer(boo::BufferUse::Uniform, sizeof(ViewBlock), 1);
|
m_splitBlockBuf = system.m_factory->newDynamicBuffer(boo::BufferUse::Uniform, sizeof(ViewBlock), 1);
|
||||||
m_splitVertsBuf = system.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(TexShaderVert), 4);
|
m_splitVertsBuf = system.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(TexShaderVert), 4);
|
||||||
|
@ -63,17 +63,50 @@ View* SplitView::setContentView(int slot, View* view)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SplitView::_setSlide(float slide)
|
||||||
|
{
|
||||||
|
m_slide = std::min(std::max(slide, 0.0f), 1.0f);
|
||||||
|
const boo::SWindowRect& rect = subRect();
|
||||||
|
if (rect.size[0] && rect.size[1] &&
|
||||||
|
(m_clearanceA >= 0 || m_clearanceB >= 0))
|
||||||
|
{
|
||||||
|
if (m_axis == Axis::Horizontal)
|
||||||
|
{
|
||||||
|
int slidePx = rect.size[1] * m_slide;
|
||||||
|
if (m_clearanceA >= 0 && slidePx < m_clearanceA)
|
||||||
|
m_slide = m_clearanceA / float(rect.size[1]);
|
||||||
|
if (m_clearanceB >= 0 && (rect.size[1] - slidePx) < m_clearanceB)
|
||||||
|
m_slide = 1.0 - m_clearanceB / float(rect.size[1]);
|
||||||
|
}
|
||||||
|
else if (m_axis == Axis::Vertical)
|
||||||
|
{
|
||||||
|
int slidePx = rect.size[0] * m_slide;
|
||||||
|
if (m_clearanceA >= 0 && slidePx < m_clearanceA)
|
||||||
|
m_slide = m_clearanceA / float(rect.size[0]);
|
||||||
|
if (m_clearanceB >= 0 && (rect.size[0] - slidePx) < m_clearanceB)
|
||||||
|
m_slide = 1.0 - m_clearanceB / float(rect.size[0]);
|
||||||
|
}
|
||||||
|
m_slide = std::min(std::max(m_slide, 0.0f), 1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SplitView::setSlide(float slide)
|
||||||
|
{
|
||||||
|
_setSlide(slide);
|
||||||
|
updateSize();
|
||||||
|
}
|
||||||
|
|
||||||
void SplitView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
void SplitView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
||||||
{
|
{
|
||||||
if (m_axis == Axis::Horizontal)
|
if (m_axis == Axis::Horizontal)
|
||||||
{
|
{
|
||||||
int slidePx = subRect().size[1] * m_slide;
|
int slidePx = subRect().size[1] * m_slide;
|
||||||
if (abs(int(coord.pixel[1] + 2) - slidePx) < 4)
|
if (abs(int(coord.pixel[1] - subRect().location[1]) - slidePx) < 4)
|
||||||
{
|
{
|
||||||
if (button == boo::EMouseButton::Primary)
|
if (button == boo::EMouseButton::Primary)
|
||||||
{
|
{
|
||||||
m_dragging = true;
|
m_dragging = true;
|
||||||
setSlide((coord.pixel[1] + 2) / float(subRect().size[1]));
|
setSlide((coord.pixel[1] - subRect().location[1]) / float(subRect().size[1]));
|
||||||
}
|
}
|
||||||
else if (button == boo::EMouseButton::Secondary)
|
else if (button == boo::EMouseButton::Secondary)
|
||||||
{
|
{
|
||||||
|
@ -85,12 +118,12 @@ void SplitView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton butt
|
||||||
else if (m_axis == Axis::Vertical)
|
else if (m_axis == Axis::Vertical)
|
||||||
{
|
{
|
||||||
int slidePx = subRect().size[0] * m_slide;
|
int slidePx = subRect().size[0] * m_slide;
|
||||||
if (abs(int(coord.pixel[0] + 2) - slidePx) < 4)
|
if (abs(int(coord.pixel[0] - subRect().location[0]) - slidePx) < 4)
|
||||||
{
|
{
|
||||||
if (button == boo::EMouseButton::Primary)
|
if (button == boo::EMouseButton::Primary)
|
||||||
{
|
{
|
||||||
m_dragging = true;
|
m_dragging = true;
|
||||||
setSlide((coord.pixel[0] + 2) / float(subRect().size[0]));
|
setSlide((coord.pixel[0] - subRect().location[0]) / float(subRect().size[0]));
|
||||||
}
|
}
|
||||||
else if (button == boo::EMouseButton::Secondary)
|
else if (button == boo::EMouseButton::Secondary)
|
||||||
{
|
{
|
||||||
|
@ -116,22 +149,16 @@ void SplitView::mouseMove(const boo::SWindowCoord& coord)
|
||||||
if (m_axis == Axis::Horizontal)
|
if (m_axis == Axis::Horizontal)
|
||||||
{
|
{
|
||||||
if (m_dragging)
|
if (m_dragging)
|
||||||
setSlide((coord.pixel[1] + 2) / float(subRect().size[1]));
|
setSlide((coord.pixel[1] - subRect().location[1]) / float(subRect().size[1]));
|
||||||
int slidePx = subRect().size[1] * m_slide;
|
int slidePx = subRect().size[1] * m_slide;
|
||||||
if (abs(int(coord.pixel[1] + 2) - slidePx) < 4)
|
rootView().setHorizontalSplitHover(abs(int(coord.pixel[1] - subRect().location[1]) - slidePx) < 4);
|
||||||
rootView().window()->setCursor(boo::EMouseCursor::VerticalArrow);
|
|
||||||
else
|
|
||||||
rootView().window()->setCursor(boo::EMouseCursor::Pointer);
|
|
||||||
}
|
}
|
||||||
else if (m_axis == Axis::Vertical)
|
else if (m_axis == Axis::Vertical)
|
||||||
{
|
{
|
||||||
if (m_dragging)
|
if (m_dragging)
|
||||||
setSlide((coord.pixel[0] + 2) / float(subRect().size[0]));
|
setSlide((coord.pixel[0] - subRect().location[0]) / float(subRect().size[0]));
|
||||||
int slidePx = subRect().size[0] * m_slide;
|
int slidePx = subRect().size[0] * m_slide;
|
||||||
if (abs(int(coord.pixel[0] + 2) - slidePx) < 4)
|
rootView().setVerticalSplitHover(abs(int(coord.pixel[0] - subRect().location[0]) - slidePx) < 4);
|
||||||
rootView().window()->setCursor(boo::EMouseCursor::HorizontalArrow);
|
|
||||||
else
|
|
||||||
rootView().window()->setCursor(boo::EMouseCursor::Pointer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_views[0].mouseMove(coord);
|
m_views[0].mouseMove(coord);
|
||||||
|
@ -153,6 +180,7 @@ void SplitView::mouseLeave(const boo::SWindowCoord& coord)
|
||||||
void SplitView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
void SplitView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||||
{
|
{
|
||||||
View::resized(root, sub);
|
View::resized(root, sub);
|
||||||
|
_setSlide(m_slide);
|
||||||
if (m_axis == Axis::Horizontal)
|
if (m_axis == Axis::Horizontal)
|
||||||
{
|
{
|
||||||
boo::SWindowRect ssub = sub;
|
boo::SWindowRect ssub = sub;
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Specter
|
||||||
Table::Table(ViewResources& res, View& parentView)
|
Table::Table(ViewResources& res, View& parentView)
|
||||||
: View(res, parentView)
|
: View(res, parentView)
|
||||||
{
|
{
|
||||||
|
commitResources(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,13 +143,13 @@ void TextField::mouseMove(const boo::SWindowCoord& coord)
|
||||||
void TextField::mouseEnter(const boo::SWindowCoord& coord)
|
void TextField::mouseEnter(const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
setHover();
|
setHover();
|
||||||
rootView().window()->setCursor(boo::EMouseCursor::IBeam);
|
rootView().setTextFieldHover(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::mouseLeave(const boo::SWindowCoord& coord)
|
void TextField::mouseLeave(const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
setInactive();
|
setInactive();
|
||||||
rootView().window()->setCursor(boo::EMouseCursor::Pointer);
|
rootView().setTextFieldHover(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat)
|
void TextField::charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat)
|
||||||
|
|
Loading…
Reference in New Issue