mirror of https://github.com/AxioDL/metaforce.git
Dedicated PathButtons class and horizontal ScrollView
This commit is contained in:
parent
0f3ab0450e
commit
35c51c6fee
|
@ -55,6 +55,7 @@ list(APPEND SPECTER_HEADERS
|
||||||
include/Specter/Menu.hpp
|
include/Specter/Menu.hpp
|
||||||
include/Specter/Node.hpp
|
include/Specter/Node.hpp
|
||||||
include/Specter/NodeSocket.hpp
|
include/Specter/NodeSocket.hpp
|
||||||
|
include/Specter/PathButtons.hpp
|
||||||
include/Specter/FileBrowser.hpp
|
include/Specter/FileBrowser.hpp
|
||||||
include/Specter/FontCache.hpp
|
include/Specter/FontCache.hpp
|
||||||
include/Specter/Translator.hpp)
|
include/Specter/Translator.hpp)
|
||||||
|
@ -85,6 +86,7 @@ list(APPEND SPECTER_SOURCES
|
||||||
lib/Menu.cpp
|
lib/Menu.cpp
|
||||||
lib/Node.cpp
|
lib/Node.cpp
|
||||||
lib/NodeSocket.cpp
|
lib/NodeSocket.cpp
|
||||||
|
lib/PathButtons.cpp
|
||||||
lib/FileBrowser.cpp
|
lib/FileBrowser.cpp
|
||||||
lib/FontCache.cpp
|
lib/FontCache.cpp
|
||||||
lib/Translator.cpp
|
lib/Translator.cpp
|
||||||
|
|
|
@ -6,38 +6,46 @@
|
||||||
|
|
||||||
namespace Specter
|
namespace Specter
|
||||||
{
|
{
|
||||||
|
class Control;
|
||||||
|
class Button;
|
||||||
|
|
||||||
struct IControlBinding
|
struct IControlBinding
|
||||||
{
|
{
|
||||||
virtual const char* name() const=0;
|
virtual const char* name(const Control* control) const=0;
|
||||||
virtual const char* help() const {return nullptr;}
|
virtual const char* help(const Control* control) const {return nullptr;}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IButtonBinding : IControlBinding
|
struct IButtonBinding : IControlBinding
|
||||||
{
|
{
|
||||||
/** Pressed/Released while Hovering action,
|
/** Pressed/Released while Hovering action,
|
||||||
* cancellable by holding the button and releasing outside */
|
* cancellable by holding the button and releasing outside */
|
||||||
virtual void activated(const boo::SWindowCoord& coord)=0;
|
virtual void activated(const Button* button, const boo::SWindowCoord& coord) {}
|
||||||
|
|
||||||
|
/** Pass-through down action */
|
||||||
|
virtual void down(const Button* button, const boo::SWindowCoord& coord) {}
|
||||||
|
|
||||||
|
/** Pass-through up action */
|
||||||
|
virtual void up(const Button* button, const boo::SWindowCoord& coord) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IFloatBinding : IControlBinding
|
struct IFloatBinding : IControlBinding
|
||||||
{
|
{
|
||||||
virtual float getDefault() const {return 0.0;}
|
virtual float getDefault(const Control* control) const {return 0.0;}
|
||||||
virtual std::pair<float,float> getBounds() const {return std::make_pair(FLT_MIN, FLT_MAX);}
|
virtual std::pair<float,float> getBounds(const Control* control) const {return std::make_pair(FLT_MIN, FLT_MAX);}
|
||||||
virtual void changed(float val)=0;
|
virtual void changed(const Control* control, float val)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IIntBinding : IControlBinding
|
struct IIntBinding : IControlBinding
|
||||||
{
|
{
|
||||||
virtual int getDefault() const {return 0;}
|
virtual int getDefault(const Control* control) const {return 0;}
|
||||||
virtual std::pair<int,int> getBounds() const {return std::make_pair(INT_MIN, INT_MAX);}
|
virtual std::pair<int,int> getBounds(const Control* control) const {return std::make_pair(INT_MIN, INT_MAX);}
|
||||||
virtual void changed(int val)=0;
|
virtual void changed(const Control* control, int val)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IStringBinding : IControlBinding
|
struct IStringBinding : IControlBinding
|
||||||
{
|
{
|
||||||
virtual std::string getDefault() const {return "";}
|
virtual std::string getDefault(const Control* control) const {return "";}
|
||||||
virtual void changed(const std::string& val)=0;
|
virtual void changed(const Control* control, const std::string& val)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CVarControlBinding : IControlBinding
|
struct CVarControlBinding : IControlBinding
|
||||||
|
@ -45,8 +53,8 @@ struct CVarControlBinding : IControlBinding
|
||||||
HECL::CVar* m_cvar;
|
HECL::CVar* m_cvar;
|
||||||
CVarControlBinding(HECL::CVar* cvar)
|
CVarControlBinding(HECL::CVar* cvar)
|
||||||
: m_cvar(cvar) {}
|
: m_cvar(cvar) {}
|
||||||
const char* name() const {return m_cvar->name().c_str();}
|
const char* name(const Control* control) const {return m_cvar->name().c_str();}
|
||||||
const char* help() const {return m_cvar->rawHelp().c_str();}
|
const char* help(const Control* control) const {return m_cvar->rawHelp().c_str();}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Control : public View
|
class Control : public View
|
||||||
|
|
|
@ -10,12 +10,13 @@
|
||||||
#include "ViewResources.hpp"
|
#include "ViewResources.hpp"
|
||||||
#include "IViewManager.hpp"
|
#include "IViewManager.hpp"
|
||||||
#include "MessageWindow.hpp"
|
#include "MessageWindow.hpp"
|
||||||
|
#include "PathButtons.hpp"
|
||||||
#include <HECL/HECL.hpp>
|
#include <HECL/HECL.hpp>
|
||||||
|
|
||||||
namespace Specter
|
namespace Specter
|
||||||
{
|
{
|
||||||
|
|
||||||
class FileBrowser : public ModalWindow
|
class FileBrowser : public ModalWindow, public IPathButtonsBinding
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class Type
|
enum class Type
|
||||||
|
@ -64,8 +65,8 @@ private:
|
||||||
m_button.m_view.reset(new Button(res, fb, this, text, Button::Style::Block,
|
m_button.m_view.reset(new Button(res, fb, this, text, Button::Style::Block,
|
||||||
RectangleConstraint(100 * res.pixelFactor(), -1, RectangleConstraint::Test::Minimum)));
|
RectangleConstraint(100 * res.pixelFactor(), -1, RectangleConstraint::Test::Minimum)));
|
||||||
}
|
}
|
||||||
const char* name() const {return m_text.c_str();}
|
const char* name(const Control* control) const {return m_text.c_str();}
|
||||||
void activated(const boo::SWindowCoord&) {m_fb.okActivated(true);}
|
void activated(const Button* button, const boo::SWindowCoord&) {m_fb.okActivated(true);}
|
||||||
} m_ok;
|
} m_ok;
|
||||||
|
|
||||||
void cancelActivated();
|
void cancelActivated();
|
||||||
|
@ -80,28 +81,12 @@ private:
|
||||||
m_button.m_view.reset(new Button(res, fb, this, text, Button::Style::Block,
|
m_button.m_view.reset(new Button(res, fb, this, text, Button::Style::Block,
|
||||||
RectangleConstraint(m_fb.m_ok.m_button.m_view->nominalWidth(), -1, RectangleConstraint::Test::Minimum)));
|
RectangleConstraint(m_fb.m_ok.m_button.m_view->nominalWidth(), -1, RectangleConstraint::Test::Minimum)));
|
||||||
}
|
}
|
||||||
const char* name() const {return m_text.c_str();}
|
const char* name(const Control* control) const {return m_text.c_str();}
|
||||||
void activated(const boo::SWindowCoord&) {m_fb.cancelActivated();}
|
void activated(const Button* button, const boo::SWindowCoord&) {m_fb.cancelActivated();}
|
||||||
} m_cancel;
|
} m_cancel;
|
||||||
|
|
||||||
int m_pathButtonPending = -1;
|
|
||||||
void pathButtonActivated(size_t idx);
|
void pathButtonActivated(size_t idx);
|
||||||
struct PathButton : IButtonBinding
|
ViewChild<std::unique_ptr<PathButtons>> m_pathButtons;
|
||||||
{
|
|
||||||
FileBrowser& m_fb;
|
|
||||||
size_t m_idx;
|
|
||||||
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 Button(res, fb, this, utf8View));
|
|
||||||
}
|
|
||||||
const char* name() const {return m_button.m_view->getText().c_str();}
|
|
||||||
void activated(const boo::SWindowCoord&) {m_fb.m_pathButtonPending = m_idx;}
|
|
||||||
};
|
|
||||||
friend struct PathButton;
|
|
||||||
std::vector<PathButton> m_pathButtons;
|
|
||||||
|
|
||||||
ViewChild<std::unique_ptr<TextField>> m_fileField;
|
ViewChild<std::unique_ptr<TextField>> m_fileField;
|
||||||
struct FileFieldBind : IStringBinding
|
struct FileFieldBind : IStringBinding
|
||||||
|
@ -110,8 +95,8 @@ private:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
FileFieldBind(FileBrowser& browser, const IViewManager& vm)
|
FileFieldBind(FileBrowser& browser, const IViewManager& vm)
|
||||||
: m_browser(browser), m_name(vm.translateOr("file_name", "File Name")) {}
|
: m_browser(browser), m_name(vm.translateOr("file_name", "File Name")) {}
|
||||||
const char* name() const {return m_name.c_str();}
|
const char* name(const Control* control) const {return m_name.c_str();}
|
||||||
void changed(const std::string& val)
|
void changed(const Control* control, const std::string& val)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
} m_fileFieldBind;
|
} m_fileFieldBind;
|
||||||
|
@ -345,7 +330,6 @@ public:
|
||||||
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&);
|
||||||
void mouseEnter(const boo::SWindowCoord&);
|
|
||||||
void mouseLeave(const boo::SWindowCoord&);
|
void mouseLeave(const boo::SWindowCoord&);
|
||||||
void scroll(const boo::SWindowCoord&, const boo::SScrollDelta&);
|
void scroll(const boo::SWindowCoord&, const boo::SScrollDelta&);
|
||||||
void touchDown(const boo::STouchCoord&, uintptr_t);
|
void touchDown(const boo::STouchCoord&, uintptr_t);
|
||||||
|
|
|
@ -29,8 +29,8 @@ private:
|
||||||
MessageWindow& m_mw;
|
MessageWindow& m_mw;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
OKBinding(MessageWindow& mw, std::string&& name) : m_mw(mw), m_name(std::move(name)) {}
|
OKBinding(MessageWindow& mw, std::string&& name) : m_mw(mw), m_name(std::move(name)) {}
|
||||||
const char* name() const {return m_name.c_str();}
|
const char* name(const Control* control) const {return m_name.c_str();}
|
||||||
void activated(const boo::SWindowCoord& coord)
|
void activated(const Button* button, const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
m_mw.m_func(true);
|
m_mw.m_func(true);
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ private:
|
||||||
MessageWindow& m_mw;
|
MessageWindow& m_mw;
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
CancelBinding(MessageWindow& mw, std::string&& name) : m_mw(mw), m_name(std::move(name)) {}
|
CancelBinding(MessageWindow& mw, std::string&& name) : m_mw(mw), m_name(std::move(name)) {}
|
||||||
const char* name() const {return m_name.c_str();}
|
const char* name(const Control* control) const {return m_name.c_str();}
|
||||||
void activated(const boo::SWindowCoord& coord)
|
void activated(const Button* button, const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
m_mw.m_func(false);
|
m_mw.m_func(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
#ifndef SPECTER_PATHBUTTONS_HPP
|
||||||
|
#define SPECTER_PATHBUTTONS_HPP
|
||||||
|
|
||||||
|
#include "Button.hpp"
|
||||||
|
#include "ScrollView.hpp"
|
||||||
|
|
||||||
|
namespace Specter
|
||||||
|
{
|
||||||
|
|
||||||
|
struct IPathButtonsBinding
|
||||||
|
{
|
||||||
|
virtual void pathButtonActivated(size_t idx)=0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PathButtons : public ScrollView
|
||||||
|
{
|
||||||
|
struct ContentView : public View
|
||||||
|
{
|
||||||
|
PathButtons& m_pb;
|
||||||
|
boo::SWindowRect m_scissorRect;
|
||||||
|
|
||||||
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
|
void mouseMove(const boo::SWindowCoord&);
|
||||||
|
void mouseLeave(const boo::SWindowCoord&);
|
||||||
|
|
||||||
|
int nominalWidth() const
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
for (PathButton& b : m_pb.m_pathButtons)
|
||||||
|
ret += b.m_button.m_view->nominalWidth() + 2;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
int nominalHeight() const
|
||||||
|
{
|
||||||
|
return m_pb.m_pathButtons.size() ? m_pb.m_pathButtons[0].m_button.m_view->nominalHeight() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub, const boo::SWindowRect& scissor);
|
||||||
|
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
||||||
|
|
||||||
|
ContentView(ViewResources& res, PathButtons& pb)
|
||||||
|
: View(res, pb), m_pb(pb) {}
|
||||||
|
};
|
||||||
|
ViewChild<std::unique_ptr<ContentView>> m_contentView;
|
||||||
|
|
||||||
|
int m_pathButtonPending = -1;
|
||||||
|
IPathButtonsBinding& m_binding;
|
||||||
|
struct PathButton : IButtonBinding
|
||||||
|
{
|
||||||
|
PathButtons& m_pb;
|
||||||
|
size_t m_idx;
|
||||||
|
ViewChild<std::unique_ptr<Button>> m_button;
|
||||||
|
PathButton(PathButtons& pb, ViewResources& res, size_t idx, const HECL::SystemString& str)
|
||||||
|
: m_pb(pb), m_idx(idx)
|
||||||
|
{
|
||||||
|
m_button.m_view.reset(new Button(res, pb, this, HECL::SystemUTF8View(str).str()));
|
||||||
|
}
|
||||||
|
const char* name(const Control* control) const {return m_button.m_view->getText().c_str();}
|
||||||
|
void activated(const Button* button, const boo::SWindowCoord&) {m_pb.m_pathButtonPending = m_idx;}
|
||||||
|
};
|
||||||
|
friend struct PathButton;
|
||||||
|
std::vector<PathButton> m_pathButtons;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PathButtons(ViewResources& res, View& parentView, IPathButtonsBinding& binding);
|
||||||
|
|
||||||
|
void setButtons(const std::vector<HECL::SystemString>& comps);
|
||||||
|
void setMultiplyColor(const Zeus::CColor& color);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SPECTER_PATHBUTTONS_HPP
|
|
@ -2,6 +2,8 @@
|
||||||
#define SPECTER_SCROLLVIEW_HPP
|
#define SPECTER_SCROLLVIEW_HPP
|
||||||
|
|
||||||
#include "View.hpp"
|
#include "View.hpp"
|
||||||
|
#include "Button.hpp"
|
||||||
|
#include "IViewManager.hpp"
|
||||||
|
|
||||||
namespace Specter
|
namespace Specter
|
||||||
{
|
{
|
||||||
|
@ -13,12 +15,13 @@ public:
|
||||||
enum class Style
|
enum class Style
|
||||||
{
|
{
|
||||||
Plain,
|
Plain,
|
||||||
ThinIndicator
|
ThinIndicator,
|
||||||
|
SideButtons
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Style m_style;
|
Style m_style;
|
||||||
View* m_contentView = nullptr;
|
ScissorViewChild<View*> m_contentView;
|
||||||
int m_scroll[2] = {};
|
int m_scroll[2] = {};
|
||||||
int m_targetScroll[2] = {};
|
int m_targetScroll[2] = {};
|
||||||
|
|
||||||
|
@ -26,18 +29,61 @@ private:
|
||||||
double m_consecutiveScroll[16][2] = {};
|
double m_consecutiveScroll[16][2] = {};
|
||||||
|
|
||||||
bool m_drawInd = false;
|
bool m_drawInd = false;
|
||||||
|
bool m_drawSideButtons = false;
|
||||||
|
|
||||||
SolidShaderVert m_verts[4];
|
SolidShaderVert m_verts[4];
|
||||||
boo::IGraphicsBufferD* m_vertsBuf = nullptr;
|
boo::IGraphicsBufferD* m_vertsBuf = nullptr;
|
||||||
boo::IVertexFormat* m_vtxFmt = nullptr; /* OpenGL only */
|
boo::IVertexFormat* m_vtxFmt = nullptr; /* OpenGL only */
|
||||||
boo::IShaderDataBinding* m_shaderBinding = nullptr;
|
boo::IShaderDataBinding* m_shaderBinding = nullptr;
|
||||||
|
|
||||||
|
enum class SideButtonState
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
ScrollLeft,
|
||||||
|
ScrollRight
|
||||||
|
} m_sideButtonState = SideButtonState::None;
|
||||||
|
struct SideButtonBinding : IButtonBinding
|
||||||
|
{
|
||||||
|
ScrollView& m_sv;
|
||||||
|
std::string m_leftName, m_rightName;
|
||||||
|
SideButtonBinding(ScrollView& sv, IViewManager& vm)
|
||||||
|
: m_sv(sv),
|
||||||
|
m_leftName(vm.translateOr("scroll_left", "Scroll Left")),
|
||||||
|
m_rightName(vm.translateOr("scroll_right", "Scroll Right")) {}
|
||||||
|
const char* name(const Control* control) const
|
||||||
|
{return (control == m_sv.m_sideButtons[0].m_view.get()) ? m_leftName.c_str() : m_rightName.c_str();}
|
||||||
|
void down(const Button* button, const boo::SWindowCoord& coord)
|
||||||
|
{
|
||||||
|
if (button == m_sv.m_sideButtons[0].m_view.get())
|
||||||
|
m_sv.m_sideButtonState = SideButtonState::ScrollRight;
|
||||||
|
else
|
||||||
|
m_sv.m_sideButtonState = SideButtonState::ScrollLeft;
|
||||||
|
}
|
||||||
|
void up(const Button* button, const boo::SWindowCoord& coord)
|
||||||
|
{
|
||||||
|
m_sv.m_sideButtonState = SideButtonState::None;
|
||||||
|
}
|
||||||
|
} m_sideButtonBind;
|
||||||
|
ViewChild<std::unique_ptr<Button>> m_sideButtons[2];
|
||||||
|
|
||||||
bool _scroll(const boo::SScrollDelta& scroll);
|
bool _scroll(const boo::SScrollDelta& scroll);
|
||||||
|
|
||||||
|
int scrollAreaWidth() const
|
||||||
|
{
|
||||||
|
int ret = subRect().size[0];
|
||||||
|
if (m_style == Style::SideButtons && m_drawSideButtons)
|
||||||
|
{
|
||||||
|
ret -= m_sideButtons[0].m_view->nominalWidth();
|
||||||
|
ret -= m_sideButtons[1].m_view->nominalWidth();
|
||||||
|
}
|
||||||
|
return std::max(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScrollView(ViewResources& res, View& parentView, Style style);
|
ScrollView(ViewResources& res, View& parentView, Style style);
|
||||||
void setContentView(View* v)
|
void setContentView(View* v)
|
||||||
{
|
{
|
||||||
m_contentView = v;
|
m_contentView.m_view = v;
|
||||||
updateSize();
|
updateSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +102,13 @@ public:
|
||||||
void setMultiplyColor(const Zeus::CColor& color)
|
void setMultiplyColor(const Zeus::CColor& color)
|
||||||
{
|
{
|
||||||
View::setMultiplyColor(color);
|
View::setMultiplyColor(color);
|
||||||
if (m_contentView)
|
if (m_style == Style::SideButtons)
|
||||||
m_contentView->setMultiplyColor(color);
|
{
|
||||||
|
m_sideButtons[0].m_view->setMultiplyColor(color);
|
||||||
|
m_sideButtons[1].m_view->setMultiplyColor(color);
|
||||||
|
}
|
||||||
|
if (m_contentView.m_view)
|
||||||
|
m_contentView.m_view->setMultiplyColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void think();
|
void think();
|
||||||
|
|
|
@ -19,7 +19,7 @@ class Space : public View
|
||||||
public:
|
public:
|
||||||
Space(ViewResources& res, View& parentView, Toolbar::Position toolbarPos);
|
Space(ViewResources& res, View& parentView, Toolbar::Position toolbarPos);
|
||||||
View* setContentView(View* view);
|
View* setContentView(View* view);
|
||||||
Toolbar& toolbar() {return *m_toolbar;}
|
Toolbar* toolbar() {return m_toolbar.get();}
|
||||||
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&);
|
||||||
|
|
|
@ -20,6 +20,7 @@ public:
|
||||||
|
|
||||||
enum class Position
|
enum class Position
|
||||||
{
|
{
|
||||||
|
None,
|
||||||
Bottom,
|
Bottom,
|
||||||
Top
|
Top
|
||||||
};
|
};
|
||||||
|
|
|
@ -296,6 +296,54 @@ struct ViewChild
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class ViewPtrType>
|
||||||
|
struct ScissorViewChild : ViewChild<ViewPtrType>
|
||||||
|
{
|
||||||
|
using base = ViewChild<ViewPtrType>;
|
||||||
|
boo::SWindowRect m_scissorRect;
|
||||||
|
|
||||||
|
bool mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
||||||
|
{
|
||||||
|
if (!base::m_view)
|
||||||
|
return false;
|
||||||
|
if (base::m_view->subRect().coordInRect(coord) &&
|
||||||
|
m_scissorRect.coordInRect(coord))
|
||||||
|
{
|
||||||
|
if ((base::m_mouseDown & 1 << int(button)) == 0)
|
||||||
|
{
|
||||||
|
base::m_view->mouseDown(coord, button, mod);
|
||||||
|
base::m_mouseDown |= 1 << int(button);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mouseMove(const boo::SWindowCoord& coord)
|
||||||
|
{
|
||||||
|
if (!base::m_view)
|
||||||
|
return;
|
||||||
|
if (base::m_view->subRect().coordInRect(coord) &&
|
||||||
|
m_scissorRect.coordInRect(coord))
|
||||||
|
{
|
||||||
|
if (!base::m_mouseIn)
|
||||||
|
{
|
||||||
|
base::m_view->mouseEnter(coord);
|
||||||
|
base::m_mouseIn = true;
|
||||||
|
}
|
||||||
|
base::m_view->mouseMove(coord);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (base::m_mouseIn)
|
||||||
|
{
|
||||||
|
base::m_view->mouseLeave(coord);
|
||||||
|
base::m_mouseIn = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SPECTER_VIEW_HPP
|
#endif // SPECTER_VIEW_HPP
|
||||||
|
|
|
@ -18,8 +18,9 @@ class ThemeData
|
||||||
Zeus::CColor m_selectedFieldText = Zeus::CColor::skWhite;
|
Zeus::CColor m_selectedFieldText = Zeus::CColor::skWhite;
|
||||||
|
|
||||||
Zeus::CColor m_vpBg = {0.2, 0.2, 0.2, 1.0};
|
Zeus::CColor m_vpBg = {0.2, 0.2, 0.2, 1.0};
|
||||||
Zeus::CColor m_tbBg = {0.4, 0.4, 0.4, 1.0};
|
Zeus::CColor m_tbBg = {0.2, 0.2, 0.2, 0.9};
|
||||||
Zeus::CColor m_tooltipBg = {0.1, 0.1, 0.1, 0.85};
|
Zeus::CColor m_tooltipBg = {0.1, 0.1, 0.1, 0.85};
|
||||||
|
Zeus::CColor m_spaceBg = {0.075, 0.075, 0.075, 0.85};
|
||||||
Zeus::CColor m_splashBg = {0.075, 0.075, 0.075, 0.85};
|
Zeus::CColor m_splashBg = {0.075, 0.075, 0.075, 0.85};
|
||||||
Zeus::CColor m_splashErrorBg = {0.1, 0.01, 0.01, 0.85};
|
Zeus::CColor m_splashErrorBg = {0.1, 0.01, 0.01, 0.85};
|
||||||
|
|
||||||
|
@ -59,6 +60,7 @@ public:
|
||||||
virtual const Zeus::CColor& viewportBackground() const {return m_vpBg;}
|
virtual const Zeus::CColor& viewportBackground() const {return m_vpBg;}
|
||||||
virtual const Zeus::CColor& toolbarBackground() const {return m_tbBg;}
|
virtual const Zeus::CColor& toolbarBackground() const {return m_tbBg;}
|
||||||
virtual const Zeus::CColor& tooltipBackground() const {return m_tooltipBg;}
|
virtual const Zeus::CColor& tooltipBackground() const {return m_tooltipBg;}
|
||||||
|
virtual const Zeus::CColor& spaceBackground() const {return m_spaceBg;}
|
||||||
virtual const Zeus::CColor& splashBackground() const {return m_splashBg;}
|
virtual const Zeus::CColor& splashBackground() const {return m_splashBg;}
|
||||||
virtual const Zeus::CColor& splashErrorBackground() const {return m_splashErrorBg;}
|
virtual const Zeus::CColor& splashErrorBackground() const {return m_splashErrorBg;}
|
||||||
|
|
||||||
|
|
|
@ -233,18 +233,25 @@ void Button::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button,
|
||||||
Control::mouseDown(coord, button, mod);
|
Control::mouseDown(coord, button, mod);
|
||||||
m_pressed = true;
|
m_pressed = true;
|
||||||
setPressed();
|
setPressed();
|
||||||
|
if (m_controlBinding && dynamic_cast<IButtonBinding*>(m_controlBinding))
|
||||||
|
static_cast<IButtonBinding&>(*m_controlBinding).down(this, coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
void Button::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
||||||
{
|
{
|
||||||
Control::mouseUp(coord, button, mod);
|
Control::mouseUp(coord, button, mod);
|
||||||
if (m_pressed && m_hovered)
|
if (m_pressed)
|
||||||
|
{
|
||||||
|
if (m_controlBinding && dynamic_cast<IButtonBinding*>(m_controlBinding))
|
||||||
|
static_cast<IButtonBinding&>(*m_controlBinding).up(this, coord);
|
||||||
|
if (m_hovered)
|
||||||
{
|
{
|
||||||
Log.report(LogVisor::Info, "button '%s' activated", m_textStr.c_str());
|
Log.report(LogVisor::Info, "button '%s' activated", m_textStr.c_str());
|
||||||
if (m_controlBinding && dynamic_cast<IButtonBinding*>(m_controlBinding))
|
if (m_controlBinding && dynamic_cast<IButtonBinding*>(m_controlBinding))
|
||||||
static_cast<IButtonBinding&>(*m_controlBinding).activated(coord);
|
static_cast<IButtonBinding&>(*m_controlBinding).activated(this, coord);
|
||||||
}
|
}
|
||||||
m_pressed = false;
|
m_pressed = false;
|
||||||
|
}
|
||||||
if (m_hovered)
|
if (m_hovered)
|
||||||
setHover();
|
setHover();
|
||||||
else
|
else
|
||||||
|
|
|
@ -64,6 +64,7 @@ FileBrowser::FileBrowser(ViewResources& res, View& parentView, const std::string
|
||||||
setBackground({0,0,0,0.5});
|
setBackground({0,0,0,0.5});
|
||||||
|
|
||||||
IViewManager& vm = rootView().viewManager();
|
IViewManager& vm = rootView().viewManager();
|
||||||
|
m_pathButtons.m_view.reset(new PathButtons(res, *this, *this));
|
||||||
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_fileListingBind, &m_fileListingBind, 3));
|
m_fileListing.m_view.reset(new Table(res, *this, &m_fileListingBind, &m_fileListingBind, 3));
|
||||||
m_systemBookmarks.m_view.reset(new Table(res, *this, &m_systemBookmarkBind, &m_systemBookmarkBind, 1));
|
m_systemBookmarks.m_view.reset(new Table(res, *this, &m_systemBookmarkBind, &m_systemBookmarkBind, 1));
|
||||||
|
@ -149,12 +150,7 @@ void FileBrowser::navigateToPath(const HECL::SystemString& path)
|
||||||
m_fileListing.m_view->selectRow(-1);
|
m_fileListing.m_view->selectRow(-1);
|
||||||
m_fileListing.m_view->updateData();
|
m_fileListing.m_view->updateData();
|
||||||
|
|
||||||
m_pathButtons.clear();
|
m_pathButtons.m_view->setButtons(m_comps);
|
||||||
m_pathButtons.reserve(m_comps.size());
|
|
||||||
size_t idx = 0;
|
|
||||||
ViewResources& res = rootView().viewRes();
|
|
||||||
for (const HECL::SystemString& c : m_comps)
|
|
||||||
m_pathButtons.emplace_back(*this, res, idx++, c);
|
|
||||||
|
|
||||||
updateSize();
|
updateSize();
|
||||||
}
|
}
|
||||||
|
@ -163,8 +159,7 @@ 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);
|
m_split.m_view->setMultiplyColor(color);
|
||||||
for (PathButton& b : m_pathButtons)
|
m_pathButtons.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_fileListing.m_view->setMultiplyColor(color);
|
||||||
m_ok.m_button.m_view->setMultiplyColor(color);
|
m_ok.m_button.m_view->setMultiplyColor(color);
|
||||||
|
@ -366,8 +361,7 @@ void FileBrowser::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton bu
|
||||||
m_confirmWindow->mouseDown(coord, button, mod);
|
m_confirmWindow->mouseDown(coord, button, mod);
|
||||||
|
|
||||||
m_split.mouseDown(coord, button, mod);
|
m_split.mouseDown(coord, button, mod);
|
||||||
for (PathButton& b : m_pathButtons)
|
m_pathButtons.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_fileListing.mouseDown(coord, button, mod);
|
||||||
m_systemBookmarks.m_view->mouseDown(coord, button, mod);
|
m_systemBookmarks.m_view->mouseDown(coord, button, mod);
|
||||||
|
@ -384,13 +378,7 @@ void FileBrowser::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton butt
|
||||||
|
|
||||||
m_split.mouseUp(coord, button, mod);
|
m_split.mouseUp(coord, button, mod);
|
||||||
|
|
||||||
for (PathButton& b : m_pathButtons)
|
m_pathButtons.mouseUp(coord, button, mod);
|
||||||
b.m_button.mouseUp(coord, button, mod);
|
|
||||||
if (m_pathButtonPending >= 0)
|
|
||||||
{
|
|
||||||
pathButtonActivated(m_pathButtonPending);
|
|
||||||
m_pathButtonPending = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_fileField.mouseUp(coord, button, mod);
|
m_fileField.mouseUp(coord, button, mod);
|
||||||
m_fileListing.mouseUp(coord, button, mod);
|
m_fileListing.mouseUp(coord, button, mod);
|
||||||
|
@ -409,8 +397,7 @@ void FileBrowser::mouseMove(const boo::SWindowCoord& coord)
|
||||||
if (closed())
|
if (closed())
|
||||||
return;
|
return;
|
||||||
m_split.mouseMove(coord);
|
m_split.mouseMove(coord);
|
||||||
for (PathButton& b : m_pathButtons)
|
m_pathButtons.mouseMove(coord);
|
||||||
b.m_button.mouseMove(coord);
|
|
||||||
m_fileField.mouseMove(coord);
|
m_fileField.mouseMove(coord);
|
||||||
m_fileListing.mouseMove(coord);
|
m_fileListing.mouseMove(coord);
|
||||||
m_systemBookmarks.m_view->mouseMove(coord);
|
m_systemBookmarks.m_view->mouseMove(coord);
|
||||||
|
@ -423,17 +410,12 @@ void FileBrowser::mouseMove(const boo::SWindowCoord& coord)
|
||||||
m_confirmWindow->mouseMove(coord);
|
m_confirmWindow->mouseMove(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::mouseEnter(const boo::SWindowCoord& coord)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileBrowser::mouseLeave(const boo::SWindowCoord& coord)
|
void FileBrowser::mouseLeave(const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
if (closed())
|
if (closed())
|
||||||
return;
|
return;
|
||||||
m_split.mouseLeave(coord);
|
m_split.mouseLeave(coord);
|
||||||
for (PathButton& b : m_pathButtons)
|
m_pathButtons.mouseLeave(coord);
|
||||||
b.m_button.mouseLeave(coord);
|
|
||||||
m_fileField.mouseLeave(coord);
|
m_fileField.mouseLeave(coord);
|
||||||
m_fileListing.mouseLeave(coord);
|
m_fileListing.mouseLeave(coord);
|
||||||
m_ok.m_button.mouseLeave(coord);
|
m_ok.m_button.mouseLeave(coord);
|
||||||
|
@ -445,6 +427,7 @@ void FileBrowser::mouseLeave(const boo::SWindowCoord& coord)
|
||||||
|
|
||||||
void FileBrowser::scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& scroll)
|
void FileBrowser::scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& scroll)
|
||||||
{
|
{
|
||||||
|
m_pathButtons.scroll(coord, scroll);
|
||||||
m_fileListing.scroll(coord, scroll);
|
m_fileListing.scroll(coord, scroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,18 +519,12 @@ void FileBrowser::RightSide::resized(const boo::SWindowRect& root, const boo::SW
|
||||||
boo::SWindowRect pathRect = sub;
|
boo::SWindowRect pathRect = sub;
|
||||||
pathRect.location[0] += BROWSER_MARGIN * pf;
|
pathRect.location[0] += BROWSER_MARGIN * pf;
|
||||||
pathRect.location[1] += pathRect.size[1] - (BROWSER_MARGIN + 20) * pf;
|
pathRect.location[1] += pathRect.size[1] - (BROWSER_MARGIN + 20) * pf;
|
||||||
for (PathButton& b : m_fb.m_pathButtons)
|
pathRect.size[0] = sub.size[0] - m_fb.m_ok.m_button.m_view->nominalWidth() - 20 * pf;
|
||||||
{
|
pathRect.size[1] = m_fb.m_fileField.m_view->nominalHeight();
|
||||||
pathRect.size[0] = b.m_button.m_view->nominalWidth();
|
m_fb.m_pathButtons.m_view->resized(root, pathRect);
|
||||||
pathRect.size[1] = b.m_button.m_view->nominalHeight();
|
|
||||||
b.m_button.m_view->resized(root, pathRect);
|
|
||||||
pathRect.location[0] += pathRect.size[0] + 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
pathRect.location[0] = sub.location[0] + BROWSER_MARGIN * pf;
|
pathRect.location[0] = sub.location[0] + BROWSER_MARGIN * pf;
|
||||||
pathRect.location[1] -= 25 * pf;
|
pathRect.location[1] -= 25 * pf;
|
||||||
pathRect.size[0] = sub.size[0] - m_fb.m_ok.m_button.m_view->nominalWidth() - 20 * pf;
|
|
||||||
pathRect.size[1] = m_fb.m_fileField.m_view->nominalHeight();
|
|
||||||
m_fb.m_fileField.m_view->resized(root, pathRect);
|
m_fb.m_fileField.m_view->resized(root, pathRect);
|
||||||
|
|
||||||
pathRect.location[1] = sub.location[1] + BROWSER_MARGIN * pf;
|
pathRect.location[1] = sub.location[1] + BROWSER_MARGIN * pf;
|
||||||
|
@ -570,6 +547,7 @@ void FileBrowser::think()
|
||||||
ModalWindow::think();
|
ModalWindow::think();
|
||||||
if (m_fileListingBind.m_needsUpdate)
|
if (m_fileListingBind.m_needsUpdate)
|
||||||
navigateToPath(m_path);
|
navigateToPath(m_path);
|
||||||
|
m_pathButtons.m_view->think();
|
||||||
m_fileField.m_view->think();
|
m_fileField.m_view->think();
|
||||||
m_fileListing.m_view->think();
|
m_fileListing.m_view->think();
|
||||||
m_systemBookmarks.m_view->think();
|
m_systemBookmarks.m_view->think();
|
||||||
|
@ -601,8 +579,7 @@ void FileBrowser::LeftSide::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
|
|
||||||
void FileBrowser::RightSide::draw(boo::IGraphicsCommandQueue* gfxQ)
|
void FileBrowser::RightSide::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
{
|
{
|
||||||
for (PathButton& b : m_fb.m_pathButtons)
|
m_fb.m_pathButtons.m_view->draw(gfxQ);
|
||||||
b.m_button.m_view->draw(gfxQ);
|
|
||||||
m_fb.m_fileListing.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_ok.m_button.m_view->draw(gfxQ);
|
||||||
m_fb.m_cancel.m_button.m_view->draw(gfxQ);
|
m_fb.m_cancel.m_button.m_view->draw(gfxQ);
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
#include "Specter/PathButtons.hpp"
|
||||||
|
#include "Specter/RootView.hpp"
|
||||||
|
|
||||||
|
namespace Specter
|
||||||
|
{
|
||||||
|
|
||||||
|
PathButtons::PathButtons(ViewResources& res, View& parentView, IPathButtonsBinding& binding)
|
||||||
|
: ScrollView(res, parentView, ScrollView::Style::SideButtons), m_binding(binding)
|
||||||
|
{
|
||||||
|
m_contentView.m_view.reset(new ContentView(res, *this));
|
||||||
|
setContentView(m_contentView.m_view.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathButtons::setButtons(const std::vector<HECL::SystemString>& comps)
|
||||||
|
{
|
||||||
|
m_pathButtons.clear();
|
||||||
|
m_pathButtons.reserve(comps.size());
|
||||||
|
size_t idx = 0;
|
||||||
|
ViewResources& res = rootView().viewRes();
|
||||||
|
for (const HECL::SystemString& c : comps)
|
||||||
|
m_pathButtons.emplace_back(*this, res, idx++, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathButtons::setMultiplyColor(const Zeus::CColor& color)
|
||||||
|
{
|
||||||
|
ScrollView::setMultiplyColor(color);
|
||||||
|
for (PathButton& b : m_pathButtons)
|
||||||
|
b.m_button.m_view->setMultiplyColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathButtons::ContentView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
||||||
|
{
|
||||||
|
for (PathButton& b : m_pb.m_pathButtons)
|
||||||
|
b.m_button.mouseDown(coord, button, mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathButtons::ContentView::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
||||||
|
{
|
||||||
|
for (PathButton& b : m_pb.m_pathButtons)
|
||||||
|
b.m_button.mouseUp(coord, button, mod);
|
||||||
|
if (m_pb.m_pathButtonPending >= 0)
|
||||||
|
{
|
||||||
|
m_pb.m_binding.pathButtonActivated(m_pb.m_pathButtonPending);
|
||||||
|
m_pb.m_pathButtonPending = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathButtons::ContentView::mouseMove(const boo::SWindowCoord& coord)
|
||||||
|
{
|
||||||
|
for (PathButton& b : m_pb.m_pathButtons)
|
||||||
|
b.m_button.mouseMove(coord);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathButtons::ContentView::mouseLeave(const boo::SWindowCoord& coord)
|
||||||
|
{
|
||||||
|
for (PathButton& b : m_pb.m_pathButtons)
|
||||||
|
b.m_button.mouseLeave(coord);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathButtons::ContentView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub,
|
||||||
|
const boo::SWindowRect& scissor)
|
||||||
|
{
|
||||||
|
View::resized(root, sub);
|
||||||
|
m_scissorRect = scissor;
|
||||||
|
m_scissorRect.size[1] += 2;
|
||||||
|
boo::SWindowRect pathRect = sub;
|
||||||
|
for (PathButton& b : m_pb.m_pathButtons)
|
||||||
|
{
|
||||||
|
pathRect.size[0] = b.m_button.m_view->nominalWidth();
|
||||||
|
pathRect.size[1] = b.m_button.m_view->nominalHeight();
|
||||||
|
b.m_button.m_view->resized(root, pathRect);
|
||||||
|
pathRect.location[0] += pathRect.size[0] + 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathButtons::ContentView::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
|
{
|
||||||
|
gfxQ->setScissor(m_scissorRect);
|
||||||
|
for (PathButton& b : m_pb.m_pathButtons)
|
||||||
|
b.m_button.m_view->draw(gfxQ);
|
||||||
|
gfxQ->setScissor(rootView().subRect());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ namespace Specter
|
||||||
#define MAX_SCROLL_SPEED 100
|
#define MAX_SCROLL_SPEED 100
|
||||||
|
|
||||||
ScrollView::ScrollView(ViewResources& res, View& parentView, Style style)
|
ScrollView::ScrollView(ViewResources& res, View& parentView, Style style)
|
||||||
: View(res, parentView), m_style(style)
|
: View(res, parentView), m_style(style), m_sideButtonBind(*this, rootView().viewManager())
|
||||||
{
|
{
|
||||||
m_vertsBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SolidShaderVert), 4);
|
m_vertsBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SolidShaderVert), 4);
|
||||||
|
|
||||||
|
@ -33,39 +33,66 @@ ScrollView::ScrollView(ViewResources& res, View& parentView, Style style)
|
||||||
nullptr, 1, bufs, 0, nullptr);
|
nullptr, 1, bufs, 0, nullptr);
|
||||||
}
|
}
|
||||||
commitResources(res);
|
commitResources(res);
|
||||||
|
|
||||||
|
if (style == Style::SideButtons)
|
||||||
|
{
|
||||||
|
m_sideButtons[0].m_view.reset(new Button(res, *this, &m_sideButtonBind, "<"));
|
||||||
|
m_sideButtons[1].m_view.reset(new Button(res, *this, &m_sideButtonBind, ">"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ScrollView::_scroll(const boo::SScrollDelta& scroll)
|
bool ScrollView::_scroll(const boo::SScrollDelta& scroll)
|
||||||
{
|
{
|
||||||
if (m_contentView)
|
if (m_contentView.m_view)
|
||||||
{
|
{
|
||||||
float ratio = subRect().size[1] / float(m_contentView->nominalHeight());
|
float ratioX = subRect().size[0] / float(m_contentView.m_view->nominalWidth());
|
||||||
if (ratio >= 1.f)
|
float ratioY = subRect().size[1] / float(m_contentView.m_view->nominalHeight());
|
||||||
{
|
|
||||||
m_scroll[0] = 0;
|
|
||||||
m_scroll[1] = 0;
|
|
||||||
m_targetScroll[0] = 0;
|
|
||||||
m_targetScroll[1] = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
float pf = rootView().viewRes().pixelFactor();
|
float pf = rootView().viewRes().pixelFactor();
|
||||||
double mult = 20.0 * pf;
|
double mult = 20.0 * pf;
|
||||||
if (scroll.isFine)
|
if (scroll.isFine)
|
||||||
mult = 1.0 * pf;
|
mult = 1.0 * pf;
|
||||||
//m_targetScroll[0] -= scroll.delta[0] * mult;
|
|
||||||
m_targetScroll[1] -= scroll.delta[1] * mult;
|
|
||||||
|
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
|
if (ratioX >= 1.f)
|
||||||
|
{
|
||||||
|
m_scroll[0] = 0;
|
||||||
|
m_targetScroll[0] = 0;
|
||||||
|
m_drawSideButtons = false;
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_drawSideButtons = true;
|
||||||
|
m_targetScroll[0] += scroll.delta[0] * mult;
|
||||||
|
m_targetScroll[0] = std::min(m_targetScroll[0], 0);
|
||||||
|
int scrollWidth = m_contentView.m_view->nominalWidth() - scrollAreaWidth();
|
||||||
|
m_targetScroll[0] = std::max(m_targetScroll[0], -scrollWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ratioY >= 1.f)
|
||||||
|
{
|
||||||
|
m_scroll[1] = 0;
|
||||||
|
m_targetScroll[1] = 0;
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_targetScroll[1] -= scroll.delta[1] * mult;
|
||||||
m_targetScroll[1] = std::max(m_targetScroll[1], 0);
|
m_targetScroll[1] = std::max(m_targetScroll[1], 0);
|
||||||
int scrollHeight = m_contentView->nominalHeight() - subRect().size[1];
|
int scrollHeight = m_contentView.m_view->nominalHeight() - subRect().size[1];
|
||||||
m_targetScroll[1] = std::min(m_targetScroll[1], scrollHeight);
|
m_targetScroll[1] = std::min(m_targetScroll[1], scrollHeight);
|
||||||
|
}
|
||||||
|
|
||||||
if (scroll.isFine)
|
if (scroll.isFine)
|
||||||
{
|
{
|
||||||
m_scroll[0] = m_targetScroll[0];
|
m_scroll[0] = m_targetScroll[0];
|
||||||
m_scroll[1] = m_targetScroll[1];
|
m_scroll[1] = m_targetScroll[1];
|
||||||
return true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -73,6 +100,7 @@ bool ScrollView::_scroll(const boo::SScrollDelta& scroll)
|
||||||
m_scroll[1] = 0;
|
m_scroll[1] = 0;
|
||||||
m_targetScroll[0] = 0;
|
m_targetScroll[0] = 0;
|
||||||
m_targetScroll[1] = 0;
|
m_targetScroll[1] = 0;
|
||||||
|
m_drawSideButtons = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -80,32 +108,53 @@ bool ScrollView::_scroll(const boo::SScrollDelta& scroll)
|
||||||
|
|
||||||
void ScrollView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
void ScrollView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
||||||
{
|
{
|
||||||
if (m_contentView)
|
if (m_style == Style::SideButtons && m_drawSideButtons)
|
||||||
m_contentView->mouseDown(coord, button, mod);
|
{
|
||||||
|
if (m_sideButtons[0].mouseDown(coord, button, mod) ||
|
||||||
|
m_sideButtons[1].mouseDown(coord, button, mod))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_contentView.mouseDown(coord, button, mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
void ScrollView::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
||||||
{
|
{
|
||||||
if (m_contentView)
|
if (m_style == Style::SideButtons)
|
||||||
m_contentView->mouseUp(coord, button, mod);
|
{
|
||||||
|
m_sideButtons[0].mouseUp(coord, button, mod);
|
||||||
|
m_sideButtons[1].mouseUp(coord, button, mod);
|
||||||
|
}
|
||||||
|
m_contentView.mouseUp(coord, button, mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::mouseMove(const boo::SWindowCoord& coord)
|
void ScrollView::mouseMove(const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
if (m_contentView)
|
if (m_style == Style::SideButtons && m_drawSideButtons)
|
||||||
m_contentView->mouseMove(coord);
|
{
|
||||||
|
m_sideButtons[0].mouseMove(coord);
|
||||||
|
m_sideButtons[1].mouseMove(coord);
|
||||||
|
}
|
||||||
|
m_contentView.mouseMove(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::mouseEnter(const boo::SWindowCoord& coord)
|
void ScrollView::mouseEnter(const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
if (m_contentView)
|
if (m_style == Style::SideButtons && m_drawSideButtons)
|
||||||
m_contentView->mouseEnter(coord);
|
{
|
||||||
|
m_sideButtons[0].mouseEnter(coord);
|
||||||
|
m_sideButtons[1].mouseEnter(coord);
|
||||||
|
}
|
||||||
|
m_contentView.mouseEnter(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::mouseLeave(const boo::SWindowCoord& coord)
|
void ScrollView::mouseLeave(const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
if (m_contentView)
|
if (m_style == Style::SideButtons)
|
||||||
m_contentView->mouseLeave(coord);
|
{
|
||||||
|
m_sideButtons[0].mouseLeave(coord);
|
||||||
|
m_sideButtons[1].mouseLeave(coord);
|
||||||
|
}
|
||||||
|
m_contentView.mouseLeave(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& scroll)
|
void ScrollView::scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& scroll)
|
||||||
|
@ -136,6 +185,17 @@ void ScrollView::think()
|
||||||
m_consecutiveScroll[m_consecutiveIdx][0] = 0.0;
|
m_consecutiveScroll[m_consecutiveIdx][0] = 0.0;
|
||||||
m_consecutiveScroll[m_consecutiveIdx][1] = 0.0;
|
m_consecutiveScroll[m_consecutiveIdx][1] = 0.0;
|
||||||
|
|
||||||
|
if (m_sideButtonState != SideButtonState::None)
|
||||||
|
{
|
||||||
|
if (m_sideButtonState == SideButtonState::ScrollLeft)
|
||||||
|
m_targetScroll[0] -= 3;
|
||||||
|
else if (m_sideButtonState == SideButtonState::ScrollRight)
|
||||||
|
m_targetScroll[0] += 3;
|
||||||
|
m_targetScroll[0] = std::min(m_targetScroll[0], 0);
|
||||||
|
int scrollWidth = m_contentView.m_view->nominalWidth() - scrollAreaWidth();
|
||||||
|
m_targetScroll[0] = std::max(m_targetScroll[0], -scrollWidth);
|
||||||
|
}
|
||||||
|
|
||||||
bool update = false;
|
bool update = false;
|
||||||
float pf = rootView().viewRes().pixelFactor();
|
float pf = rootView().viewRes().pixelFactor();
|
||||||
|
|
||||||
|
@ -171,14 +231,26 @@ void ScrollView::resized(const boo::SWindowRect& root, const boo::SWindowRect& s
|
||||||
{
|
{
|
||||||
View::resized(root, sub);
|
View::resized(root, sub);
|
||||||
_scroll({});
|
_scroll({});
|
||||||
if (m_contentView)
|
if (m_contentView.m_view)
|
||||||
{
|
{
|
||||||
boo::SWindowRect cRect = sub;
|
boo::SWindowRect cRect = sub;
|
||||||
cRect.location[0] += m_scroll[0];
|
cRect.location[0] += m_scroll[0];
|
||||||
cRect.location[1] += sub.size[1] - m_contentView->nominalHeight() + m_scroll[1];
|
cRect.location[1] += sub.size[1] - m_contentView.m_view->nominalHeight() + m_scroll[1];
|
||||||
cRect.size[0] = m_contentView->nominalWidth();
|
cRect.size[0] = m_contentView.m_view->nominalWidth();
|
||||||
cRect.size[1] = m_contentView->nominalHeight();
|
cRect.size[1] = m_contentView.m_view->nominalHeight();
|
||||||
m_contentView->resized(root, cRect, sub);
|
m_contentView.m_scissorRect = sub;
|
||||||
|
if (m_style == Style::SideButtons && m_drawSideButtons)
|
||||||
|
{
|
||||||
|
int width0 = m_sideButtons[0].m_view->nominalWidth() + 2;
|
||||||
|
int width1 = m_sideButtons[1].m_view->nominalWidth();
|
||||||
|
cRect.location[0] += width0;
|
||||||
|
cRect.size[0] -= (width0 + width1);
|
||||||
|
|
||||||
|
m_contentView.m_scissorRect.location[0] += width0;
|
||||||
|
m_contentView.m_scissorRect.size[0] -= (width0 + width1);
|
||||||
|
}
|
||||||
|
m_contentView.m_view->resized(root, cRect, m_contentView.m_scissorRect);
|
||||||
|
|
||||||
|
|
||||||
if (m_style == Style::ThinIndicator)
|
if (m_style == Style::ThinIndicator)
|
||||||
{
|
{
|
||||||
|
@ -202,14 +274,26 @@ void ScrollView::resized(const boo::SWindowRect& root, const boo::SWindowRect& s
|
||||||
m_vertsBuf->load(m_verts, sizeof(m_verts));
|
m_vertsBuf->load(m_verts, sizeof(m_verts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (m_style == Style::SideButtons && m_drawSideButtons)
|
||||||
|
{
|
||||||
|
boo::SWindowRect bRect = sub;
|
||||||
|
bRect.size[0] = m_sideButtons[0].m_view->nominalWidth();
|
||||||
|
bRect.size[1] = m_sideButtons[0].m_view->nominalHeight();
|
||||||
|
m_sideButtons[0].m_view->resized(root, bRect);
|
||||||
|
|
||||||
|
bRect.size[0] = m_sideButtons[1].m_view->nominalWidth();
|
||||||
|
bRect.size[1] = m_sideButtons[1].m_view->nominalHeight();
|
||||||
|
bRect.location[0] += sub.size[0] - bRect.size[0];
|
||||||
|
m_sideButtons[1].m_view->resized(root, bRect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollView::draw(boo::IGraphicsCommandQueue* gfxQ)
|
void ScrollView::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
{
|
{
|
||||||
if (m_contentView)
|
if (m_contentView.m_view)
|
||||||
{
|
{
|
||||||
m_contentView->draw(gfxQ);
|
m_contentView.m_view->draw(gfxQ);
|
||||||
|
|
||||||
if (m_style == Style::ThinIndicator && m_drawInd)
|
if (m_style == Style::ThinIndicator && m_drawInd)
|
||||||
{
|
{
|
||||||
|
@ -217,6 +301,11 @@ void ScrollView::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
|
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
|
||||||
gfxQ->draw(0, 4);
|
gfxQ->draw(0, 4);
|
||||||
}
|
}
|
||||||
|
else if (m_style == Style::SideButtons && m_drawSideButtons)
|
||||||
|
{
|
||||||
|
m_sideButtons[0].m_view->draw(gfxQ);
|
||||||
|
m_sideButtons[1].m_view->draw(gfxQ);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ Space::Space(ViewResources& res, View& parentView, Toolbar::Position tbPos)
|
||||||
: View(res, parentView), m_tbPos(tbPos)
|
: View(res, parentView), m_tbPos(tbPos)
|
||||||
{
|
{
|
||||||
commitResources(res);
|
commitResources(res);
|
||||||
|
setBackground(res.themeData().spaceBackground());
|
||||||
|
if (tbPos != Toolbar::Position::None)
|
||||||
m_toolbar.reset(new Toolbar(res, *this, tbPos));
|
m_toolbar.reset(new Toolbar(res, *this, tbPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,20 +120,24 @@ void Space::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||||
View::resized(root, sub);
|
View::resized(root, sub);
|
||||||
|
|
||||||
boo::SWindowRect tbRect = sub;
|
boo::SWindowRect tbRect = sub;
|
||||||
|
if (m_toolbar)
|
||||||
|
{
|
||||||
tbRect.size[1] = m_toolbar->nominalHeight();
|
tbRect.size[1] = m_toolbar->nominalHeight();
|
||||||
if (m_tbPos == Toolbar::Position::Top)
|
if (m_tbPos == Toolbar::Position::Top)
|
||||||
tbRect.location[1] += sub.size[1] - tbRect.size[1];
|
tbRect.location[1] += sub.size[1] - tbRect.size[1];
|
||||||
m_toolbar->resized(root, tbRect);
|
m_toolbar->resized(root, tbRect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tbRect.size[1] = 0;
|
||||||
|
|
||||||
if (m_contentView)
|
if (m_contentView)
|
||||||
{
|
{
|
||||||
if (m_tbPos == Toolbar::Position::Top)
|
boo::SWindowRect contentRect = sub;
|
||||||
tbRect.location[1] = sub.location[1];
|
if (m_tbPos == Toolbar::Position::Bottom)
|
||||||
else
|
contentRect.location[1] += tbRect.size[1];
|
||||||
tbRect.location[1] += tbRect.size[1];
|
contentRect.size[1] = sub.size[1] - tbRect.size[1];
|
||||||
tbRect.size[1] = sub.size[1] - tbRect.size[1];
|
contentRect.size[1] = std::max(contentRect.size[1], 0);
|
||||||
tbRect.size[1] = std::max(tbRect.size[1], 0);
|
m_contentView->resized(root, contentRect);
|
||||||
m_contentView->resized(root, tbRect);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +146,7 @@ void Space::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
View::draw(gfxQ);
|
View::draw(gfxQ);
|
||||||
if (m_contentView)
|
if (m_contentView)
|
||||||
m_contentView->draw(gfxQ);
|
m_contentView->draw(gfxQ);
|
||||||
|
if (m_toolbar)
|
||||||
m_toolbar->draw(gfxQ);
|
m_toolbar->draw(gfxQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ TextField::TextField(ViewResources& res, View& parentView, IStringBinding* strBi
|
||||||
|
|
||||||
m_text.reset(new TextView(res, *this, res.m_mainFont, TextView::Alignment::Left, 1024));
|
m_text.reset(new TextView(res, *this, res.m_mainFont, TextView::Alignment::Left, 1024));
|
||||||
if (strBind)
|
if (strBind)
|
||||||
setText(strBind->getDefault());
|
setText(strBind->getDefault(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextField::_setText()
|
void TextField::_setText()
|
||||||
|
@ -52,7 +52,7 @@ void TextField::_setText()
|
||||||
m_text->typesetGlyphs(m_textStr, m_error ? rootView().themeData().uiText() :
|
m_text->typesetGlyphs(m_textStr, m_error ? rootView().themeData().uiText() :
|
||||||
rootView().themeData().fieldText());
|
rootView().themeData().fieldText());
|
||||||
if (m_controlBinding && dynamic_cast<IStringBinding*>(m_controlBinding))
|
if (m_controlBinding && dynamic_cast<IStringBinding*>(m_controlBinding))
|
||||||
static_cast<IStringBinding&>(*m_controlBinding).changed(m_textStr);
|
static_cast<IStringBinding&>(*m_controlBinding).changed(this, m_textStr);
|
||||||
m_hasTextSet = false;
|
m_hasTextSet = false;
|
||||||
if (m_deferredMarkStr.size())
|
if (m_deferredMarkStr.size())
|
||||||
m_hasMarkSet = true;
|
m_hasMarkSet = true;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
namespace Specter
|
namespace Specter
|
||||||
{
|
{
|
||||||
|
static LogVisor::LogModule Log("Specter::View");
|
||||||
|
|
||||||
void View::Resources::init(boo::GLDataFactory* factory, const ThemeData& theme)
|
void View::Resources::init(boo::GLDataFactory* factory, const ThemeData& theme)
|
||||||
{
|
{
|
||||||
|
@ -357,6 +358,8 @@ void View::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
|
|
||||||
void View::commitResources(ViewResources& res)
|
void View::commitResources(ViewResources& res)
|
||||||
{
|
{
|
||||||
|
if (m_gfxData)
|
||||||
|
Log.report(LogVisor::FatalError, "multiple resource commits not allowed");
|
||||||
m_gfxData = res.m_factory->commit();
|
m_gfxData = res.m_factory->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue