mirror of https://github.com/AxioDL/metaforce.git
Removed view ownership (client should do this)
This commit is contained in:
parent
d58d8c2391
commit
cb2df22ec2
|
@ -38,7 +38,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
Button(ViewResources& res, View& parentView,
|
Button(ViewResources& res, View& parentView,
|
||||||
std::unique_ptr<IButtonBinding>&& controlBinding, const std::string& text);
|
IButtonBinding* controlBinding, const std::string& text);
|
||||||
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&);
|
||||||
|
|
|
@ -44,15 +44,15 @@ struct CVarControlBinding : IControlBinding
|
||||||
class Control : public View
|
class Control : public View
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<IControlBinding> m_controlBinding;
|
IControlBinding* m_controlBinding = nullptr;
|
||||||
public:
|
public:
|
||||||
Control(ViewResources& res, View& parentView, std::unique_ptr<IControlBinding>&& controlBinding);
|
Control(ViewResources& res, View& parentView, IControlBinding* controlBinding);
|
||||||
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 setControlBinding(std::unique_ptr<IControlBinding>&& controlBinding);
|
IControlBinding* setControlBinding(IControlBinding* controlBinding);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,12 +63,12 @@ public:
|
||||||
ViewResources& viewRes() const {return *m_viewRes;}
|
ViewResources& viewRes() const {return *m_viewRes;}
|
||||||
const ThemeData& themeData() const {return m_viewRes->m_theme;}
|
const ThemeData& themeData() const {return m_viewRes->m_theme;}
|
||||||
|
|
||||||
void setContentView(std::unique_ptr<View>&& view);
|
View* setContentView(View* view);
|
||||||
|
|
||||||
void displayTooltip(const std::string& name, const std::string& help);
|
void displayTooltip(const std::string& name, const std::string& help);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<View> m_view;
|
View* m_view = nullptr;
|
||||||
std::unique_ptr<Tooltip> m_tooltip;
|
std::unique_ptr<Tooltip> m_tooltip;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,12 @@ class Space : public View
|
||||||
std::unique_ptr<Toolbar> m_toolbar;
|
std::unique_ptr<Toolbar> m_toolbar;
|
||||||
bool m_toolbarMouseIn = false;
|
bool m_toolbarMouseIn = false;
|
||||||
bool m_toolbarMouseDown = false;
|
bool m_toolbarMouseDown = false;
|
||||||
std::unique_ptr<View> m_contentView;
|
View* m_contentView = nullptr;
|
||||||
bool m_contentMouseIn = false;
|
bool m_contentMouseIn = false;
|
||||||
bool m_contentMouseDown = false;
|
bool m_contentMouseDown = false;
|
||||||
public:
|
public:
|
||||||
Space(ViewResources& res, View& parentView, Toolbar::Position toolbarPos);
|
Space(ViewResources& res, View& parentView, Toolbar::Position toolbarPos);
|
||||||
std::unique_ptr<View> setContentView(std::unique_ptr<View>&& view);
|
View* setContentView(View* view);
|
||||||
Toolbar& toolbar() {return *m_toolbar;}
|
Toolbar& toolbar() {return *m_toolbar;}
|
||||||
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);
|
||||||
|
|
|
@ -36,7 +36,7 @@ private:
|
||||||
|
|
||||||
struct Child
|
struct Child
|
||||||
{
|
{
|
||||||
std::unique_ptr<View> m_view;
|
View* m_view = nullptr;
|
||||||
bool m_mouseIn = false;
|
bool m_mouseIn = false;
|
||||||
bool m_mouseDown = false;
|
bool m_mouseDown = false;
|
||||||
};
|
};
|
||||||
|
@ -74,7 +74,7 @@ private:
|
||||||
boo::IShaderDataBinding* m_splitShaderBinding;
|
boo::IShaderDataBinding* m_splitShaderBinding;
|
||||||
public:
|
public:
|
||||||
SplitView(ViewResources& res, View& parentView, Axis axis);
|
SplitView(ViewResources& res, View& parentView, Axis axis);
|
||||||
std::unique_ptr<View> setContentView(int slot, std::unique_ptr<View>&& view);
|
View* setContentView(int slot, View* view);
|
||||||
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&);
|
||||||
|
|
|
@ -27,10 +27,10 @@ private:
|
||||||
Position m_tbPos;
|
Position m_tbPos;
|
||||||
struct Child
|
struct Child
|
||||||
{
|
{
|
||||||
std::unique_ptr<View> m_view;
|
View* m_view = nullptr;
|
||||||
bool m_mouseIn = false;
|
bool m_mouseIn = false;
|
||||||
bool m_mouseDown = false;
|
bool m_mouseDown = false;
|
||||||
Child(std::unique_ptr<View>&& v) : m_view(std::move(v)) {}
|
Child(View* v) : m_view(v) {}
|
||||||
};
|
};
|
||||||
std::vector<Child> m_children;
|
std::vector<Child> m_children;
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ public:
|
||||||
int nominalHeight() const {return m_nomHeight;}
|
int nominalHeight() const {return m_nomHeight;}
|
||||||
|
|
||||||
void clear() {m_children.clear();}
|
void clear() {m_children.clear();}
|
||||||
void push_back(std::unique_ptr<View>&& v) {m_children.push_back(std::move(v));}
|
void push_back(View* v) {m_children.push_back(v);}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ void Button::Resources::init(boo::IGraphicsDataFactory* factory, const ThemeData
|
||||||
}
|
}
|
||||||
|
|
||||||
Button::Button(ViewResources& res, View& parentView,
|
Button::Button(ViewResources& res, View& parentView,
|
||||||
std::unique_ptr<IButtonBinding>&& controlBinding, const std::string& text)
|
IButtonBinding* controlBinding, const std::string& text)
|
||||||
: Control(res, parentView, std::move(controlBinding)), m_textStr(text)
|
: Control(res, parentView, controlBinding), m_textStr(text)
|
||||||
{
|
{
|
||||||
m_bBlockBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Uniform, sizeof(ViewBlock), 1);
|
m_bBlockBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Uniform, sizeof(ViewBlock), 1);
|
||||||
m_bVertsBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SolidShaderVert), 28);
|
m_bVertsBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SolidShaderVert), 28);
|
||||||
|
@ -153,7 +153,7 @@ void Button::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, b
|
||||||
if (m_pressed && m_hovered)
|
if (m_pressed && 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.get()))
|
if (m_controlBinding && dynamic_cast<IButtonBinding*>(m_controlBinding))
|
||||||
static_cast<IButtonBinding&>(*m_controlBinding).pressed(coord);
|
static_cast<IButtonBinding&>(*m_controlBinding).pressed(coord);
|
||||||
}
|
}
|
||||||
m_pressed = false;
|
m_pressed = false;
|
||||||
|
|
|
@ -4,12 +4,14 @@ namespace Specter
|
||||||
{
|
{
|
||||||
|
|
||||||
Control::Control(ViewResources& res, View& parentView,
|
Control::Control(ViewResources& res, View& parentView,
|
||||||
std::unique_ptr<IControlBinding>&& controlBinding)
|
IControlBinding* controlBinding)
|
||||||
: View(res, parentView), m_controlBinding(std::move(controlBinding)) {}
|
: View(res, parentView), m_controlBinding(controlBinding) {}
|
||||||
|
|
||||||
void Control::setControlBinding(std::unique_ptr<IControlBinding>&& controlBinding)
|
IControlBinding* Control::setControlBinding(IControlBinding* controlBinding)
|
||||||
{
|
{
|
||||||
m_controlBinding = std::move(controlBinding);
|
IControlBinding* ret = m_controlBinding;
|
||||||
|
m_controlBinding = controlBinding;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Control::mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey)
|
void Control::mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey)
|
||||||
|
|
|
@ -122,10 +122,12 @@ void RootView::modKeyUp(boo::EModifierKey mod)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RootView::setContentView(std::unique_ptr<View>&& view)
|
View* RootView::setContentView(View* view)
|
||||||
{
|
{
|
||||||
m_view = std::move(view);
|
View* ret = m_view;
|
||||||
|
m_view = view;
|
||||||
updateSize();
|
updateSize();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RootView::displayTooltip(const std::string& name, const std::string& help)
|
void RootView::displayTooltip(const std::string& name, const std::string& help)
|
||||||
|
|
|
@ -13,11 +13,10 @@ Space::Space(ViewResources& res, View& parentView, Toolbar::Position tbPos)
|
||||||
m_toolbar.reset(new Toolbar(res, *this, tbPos));
|
m_toolbar.reset(new Toolbar(res, *this, tbPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<View> Space::setContentView(std::unique_ptr<View>&& view)
|
View* Space::setContentView(View* view)
|
||||||
{
|
{
|
||||||
std::unique_ptr<View> ret;
|
View* ret = m_contentView;
|
||||||
m_contentView.swap(ret);
|
m_contentView = view;
|
||||||
m_contentView = std::move(view);
|
|
||||||
updateSize();
|
updateSize();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,13 +51,12 @@ SplitView::SplitView(ViewResources& system, View& parentView, Axis axis)
|
||||||
commitResources(system);
|
commitResources(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<View> SplitView::setContentView(int slot, std::unique_ptr<View>&& view)
|
View* SplitView::setContentView(int slot, View* view)
|
||||||
{
|
{
|
||||||
if (slot < 0 || slot > 1)
|
if (slot < 0 || slot > 1)
|
||||||
Log.report(LogVisor::FatalError, "out-of-range slot to RootView::SplitView::setContentView");
|
Log.report(LogVisor::FatalError, "out-of-range slot to RootView::SplitView::setContentView");
|
||||||
std::unique_ptr<View> ret;
|
View* ret = m_views[slot].m_view;
|
||||||
m_views[slot].m_view.swap(ret);
|
m_views[slot].m_view = view;
|
||||||
m_views[slot].m_view = std::move(view);
|
|
||||||
m_views[slot].m_mouseDown = false;
|
m_views[slot].m_mouseDown = false;
|
||||||
m_views[slot].m_mouseIn = false;
|
m_views[slot].m_mouseIn = false;
|
||||||
updateSize();
|
updateSize();
|
||||||
|
|
Loading…
Reference in New Issue