Preparation for self-split space functionality

This commit is contained in:
Jack Andersen 2016-01-09 20:40:23 -10:00
parent 24917f2367
commit 08c4270707
18 changed files with 415 additions and 153 deletions

View File

@ -41,7 +41,7 @@ public:
friend class ViewResources;
friend class Button;
void init(boo::IGraphicsDataFactory* factory, const ThemeData& theme);
void init(boo::IGraphicsDataFactory* factory, const IThemeData& theme);
};
Button(ViewResources& res, View& parentView,

View File

@ -25,6 +25,7 @@ public:
SaveDirectory,
OpenFile,
OpenDirectory,
NewHECLProject,
OpenHECLProject
};
private:

View File

@ -34,7 +34,7 @@ public:
friend class ViewResources;
friend class Button;
void init(boo::IGraphicsDataFactory* factory, const ThemeData& theme);
void init(boo::IGraphicsDataFactory* factory, const IThemeData& theme);
};
NumericField(ViewResources& res, View& parentView, const std::string& text);

View File

@ -62,7 +62,7 @@ public:
boo::IWindow* window() const {return m_window;}
IViewManager& viewManager() const {return m_viewMan;}
ViewResources& viewRes() const {return *m_viewRes;}
const ThemeData& themeData() const {return m_viewRes->m_theme;}
const IThemeData& themeData() const {return *m_viewRes->m_theme;}
std::vector<View*>& accessContentViews() {return m_views;}
@ -97,6 +97,12 @@ public:
m_textFieldHover = hover;
_updateCursor();
}
bool m_spaceCornerHover = false;
void setSpaceCornerHover(bool hover)
{
m_spaceCornerHover = hover;
_updateCursor();
}
void resetTooltip(ViewResources& res);
void displayTooltip(const std::string& name, const std::string& help);
@ -104,7 +110,9 @@ public:
private:
void _updateCursor()
{
if (m_vSplitHover)
if (m_spaceCornerHover)
m_window->setCursor(boo::EMouseCursor::Crosshairs);
else if (m_vSplitHover)
m_window->setCursor(boo::EMouseCursor::HorizontalArrow);
else if (m_hSplitHover)
m_window->setCursor(boo::EMouseCursor::VerticalArrow);

View File

@ -1,25 +1,58 @@
#ifndef SPECTER_SPACE_HPP
#define SPECTER_SPACE_HPP
#include "Specter/View.hpp"
#include "Specter/Toolbar.hpp"
#include "View.hpp"
#include "Toolbar.hpp"
#include "SplitView.hpp"
namespace Specter
{
class Space;
struct ISplitSpaceController;
struct ISpaceController
{
virtual bool spaceSplitAllowed() const {return false;}
virtual ISplitSpaceController* spaceSplit(SplitView::Axis axis, int thisSlot) {return nullptr;}
virtual ISpaceController* spaceJoin(int keepSlot) {return nullptr;}
};
struct ISplitSpaceController
{
virtual SplitView* splitView()=0;
};
class Space : public View
{
ISpaceController& m_controller;
Toolbar::Position m_tbPos;
std::unique_ptr<Toolbar> m_toolbar;
bool m_toolbarMouseIn = false;
bool m_toolbarMouseDown = false;
View* m_contentView = nullptr;
bool m_contentMouseIn = false;
bool m_contentMouseDown = false;
ViewChild<std::unique_ptr<Toolbar>> m_toolbar;
ViewChild<View*> m_contentView;
bool m_cornerDrag = false;
int m_cornerDragPoint[2];
ISplitSpaceController* m_cornerDragSplitSpace = nullptr;
struct CornerView : View
{
Space& m_space;
VertexBufferBinding m_vertexBinding;
bool m_flip;
CornerView(ViewResources& res, Space& space, const Zeus::CColor& triColor);
void mouseEnter(const boo::SWindowCoord&);
void mouseLeave(const boo::SWindowCoord&);
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub, bool flip);
void draw(boo::IGraphicsCommandQueue* gfxQ);
};
friend struct CornerView;
ViewChild<std::unique_ptr<CornerView>> m_cornerView;
public:
Space(ViewResources& res, View& parentView, Toolbar::Position toolbarPos);
Space(ViewResources& res, View& parentView, ISpaceController& controller, Toolbar::Position toolbarPos);
View* setContentView(View* view);
Toolbar* toolbar() {return m_toolbar.get();}
Toolbar* toolbar() {return m_toolbar.m_view.get();}
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseMove(const boo::SWindowCoord&);
@ -31,10 +64,16 @@ public:
void setMultiplyColor(const Zeus::CColor& color)
{
View::setMultiplyColor(color);
if (m_contentView)
m_contentView->setMultiplyColor(color);
if (m_toolbar)
m_toolbar->setMultiplyColor(color);
if (m_contentView.m_view)
m_contentView.m_view->setMultiplyColor(color);
if (m_toolbar.m_view)
m_toolbar.m_view->setMultiplyColor(color);
}
virtual const Zeus::CColor& spaceTriangleColor() const
{
static const Zeus::CColor defaultColor = {0.75, 0.75, 0.75, 1.0};
return defaultColor;
}
};

View File

@ -15,7 +15,7 @@ public:
friend class SplitView;
boo::ITextureS* m_shadingTex;
void init(boo::IGraphicsDataFactory* factory, const ThemeData& theme);
void init(boo::IGraphicsDataFactory* factory, const IThemeData& theme);
};
enum class Axis
@ -26,7 +26,7 @@ public:
private:
Axis m_axis;
float m_slide = 0.5;
void _setSlide(float slide);
void _setSplit(float slide);
bool m_dragging = false;
ViewChild<View*> m_views[2];
@ -65,7 +65,8 @@ private:
public:
SplitView(ViewResources& res, View& parentView, Axis axis, int clearanceA=-1, int clearanceB=-1);
View* setContentView(int slot, View* view);
void setSlide(float slide);
void setSplit(float slide);
void startDragSplit(const boo::SWindowCoord& coord);
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
void mouseMove(const boo::SWindowCoord&);

View File

@ -15,7 +15,7 @@ public:
friend class Toolbar;
boo::ITextureS* m_shadingTex;
void init(boo::IGraphicsDataFactory* factory, const ThemeData& theme);
void init(boo::IGraphicsDataFactory* factory, const IThemeData& theme);
};
enum class Position

View File

@ -14,7 +14,7 @@
namespace Specter
{
class ThemeData;
class IThemeData;
class ViewResources;
class RootView;
@ -157,11 +157,11 @@ public:
boo::IShaderPipeline* m_texShader = nullptr;
boo::IVertexFormat* m_texVtxFmt = nullptr; /* Not OpenGL */
void init(boo::GLDataFactory* factory, const ThemeData& theme);
void init(boo::GLDataFactory* factory, const IThemeData& theme);
#if _WIN32
void init(boo::ID3DDataFactory* factory, const ThemeData& theme);
#elif BOO_HAS_METAL
void init(boo::MetalDataFactory* factory, const ThemeData& theme);
void init(boo::MetalDataFactory* factory, const IThemeData& theme);
#endif
};
@ -218,6 +218,7 @@ public:
virtual void modKeyUp(boo::EModifierKey) {}
virtual void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
virtual void resized(const ViewBlock& vb, const boo::SWindowRect& sub);
virtual void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub,
const boo::SWindowRect& scissor) {resized(root, sub);}
virtual void think() {}

View File

@ -10,7 +10,53 @@
namespace Specter
{
class ThemeData
class IThemeData
{
public:
virtual const Zeus::CColor& uiText() const=0;
virtual const Zeus::CColor& fieldText() const=0;
virtual const Zeus::CColor& fieldMarkedText() const=0;
virtual const Zeus::CColor& selectedFieldText() const=0;
virtual const Zeus::CColor& viewportBackground() const=0;
virtual const Zeus::CColor& toolbarBackground() const=0;
virtual const Zeus::CColor& tooltipBackground() const=0;
virtual const Zeus::CColor& spaceBackground() const=0;
virtual const Zeus::CColor& splashBackground() const=0;
virtual const Zeus::CColor& splashErrorBackground() const=0;
virtual const Zeus::CColor& splash1() const=0;
virtual const Zeus::CColor& splash2() const=0;
virtual const Zeus::CColor& button1Inactive() const=0;
virtual const Zeus::CColor& button2Inactive() const=0;
virtual const Zeus::CColor& button1Hover() const=0;
virtual const Zeus::CColor& button2Hover() const=0;
virtual const Zeus::CColor& button1Press() const=0;
virtual const Zeus::CColor& button2Press() const=0;
virtual const Zeus::CColor& button1Disabled() const=0;
virtual const Zeus::CColor& button2Disabled() const=0;
virtual const Zeus::CColor& textfield1Inactive() const=0;
virtual const Zeus::CColor& textfield2Inactive() const=0;
virtual const Zeus::CColor& textfield1Hover() const=0;
virtual const Zeus::CColor& textfield2Hover() const=0;
virtual const Zeus::CColor& textfield1Disabled() const=0;
virtual const Zeus::CColor& textfield2Disabled() const=0;
virtual const Zeus::CColor& textfieldSelection() const=0;
virtual const Zeus::CColor& textfieldMarkSelection() const=0;
virtual const Zeus::CColor& tableCellBg1() const=0;
virtual const Zeus::CColor& tableCellBg2() const=0;
virtual const Zeus::CColor& tableCellBgSelected() const=0;
virtual const Zeus::CColor& scrollIndicator() const=0;
virtual const Zeus::CColor& spaceTriangleShading1() const=0;
virtual const Zeus::CColor& spaceTriangleShading2() const=0;
};
class DefaultThemeData : public IThemeData
{
Zeus::CColor m_uiText = Zeus::CColor::skWhite;
Zeus::CColor m_fieldText = Zeus::CColor::skBlack;
@ -51,6 +97,9 @@ class ThemeData
Zeus::CColor m_scrollIndicator = {0.2823, 0.2823, 0.2823, 1.0};
Zeus::CColor m_spaceTriangleShading1 = {0.6425, 0.6425, 0.6425, 1.0};
Zeus::CColor m_spaceTriangleShading2 = {0.5725, 0.5725, 0.5725, 1.0};
public:
virtual const Zeus::CColor& uiText() const {return m_uiText;}
virtual const Zeus::CColor& fieldText() const {return m_fieldText;}
@ -90,12 +139,15 @@ public:
virtual const Zeus::CColor& tableCellBgSelected() const {return m_tableCellBgSelected;}
virtual const Zeus::CColor& scrollIndicator() const {return m_scrollIndicator;}
virtual const Zeus::CColor& spaceTriangleShading1() const {return m_spaceTriangleShading1;}
virtual const Zeus::CColor& spaceTriangleShading2() const {return m_spaceTriangleShading2;}
};
class ViewResources
{
template <class Factory>
void init(Factory* factory, const ThemeData& theme, FontCache* fcache)
void init(Factory* factory, const IThemeData& theme, FontCache* fcache)
{
m_viewRes.init(factory, theme);
m_textRes.init(factory, fcache);
@ -142,19 +194,18 @@ public:
}
}
void init(boo::IGraphicsDataFactory* factory, FontCache* fcache, const ThemeData& theme, float pixelFactor);
void init(boo::IGraphicsDataFactory* factory, FontCache* fcache, const IThemeData* theme, float pixelFactor);
void prepFontCacheSync();
void prepFontCacheAsync(boo::IWindow* window);
bool fontCacheReady() const {return m_fcacheReady;}
void resetPixelFactor(float pixelFactor);
void resetTheme(const ThemeData& theme);
void resetLanguage(const ThemeData& theme);
void resetTheme(const IThemeData* theme);
float m_pixelFactor = 0;
float pixelFactor() const {return m_pixelFactor;}
ThemeData m_theme;
const ThemeData& themeData() const {return m_theme;}
const IThemeData* m_theme;
const IThemeData& themeData() const {return *m_theme;}
};
}

View File

@ -7,7 +7,7 @@ namespace Specter
{
static LogVisor::LogModule Log("Specter::Button");
void Button::Resources::init(boo::IGraphicsDataFactory* factory, const ThemeData& theme)
void Button::Resources::init(boo::IGraphicsDataFactory* factory, const IThemeData& theme)
{
}

View File

@ -89,7 +89,7 @@ FileBrowser::FileBrowser(ViewResources& res, View& parentView, const std::string
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);
m_split.m_view->setSplit(0.2);
updateContentOpacity(0.0);
}
@ -237,7 +237,7 @@ void FileBrowser::okActivated(bool viaButton)
close();
return;
}
else if (m_type == Type::SaveDirectory)
else if (m_type == Type::SaveDirectory || m_type == Type::NewHECLProject)
{
if (m_fileField.m_view->getText().empty())
{
@ -253,6 +253,16 @@ void FileBrowser::okActivated(bool viaButton)
}
if (!err && S_ISDIR(theStat.st_mode))
{
if (m_type == Type::NewHECLProject)
{
HECL::ProjectRootPath projRoot = HECL::SearchForProject(path);
if (projRoot)
{
m_fileField.m_view->setErrorState(
vm.translateOr("no_overwrite_project", "Unable to make project within existing project").c_str());
return;
}
}
navigateToPath(path);
return;
}

View File

@ -1,153 +1,282 @@
#include <LogVisor/LogVisor.hpp>
#include "Specter/Space.hpp"
#include "Specter/ViewResources.hpp"
#include "Specter/RootView.hpp"
namespace Specter
{
static LogVisor::LogModule Log("Specter::Space");
Space::Space(ViewResources& res, View& parentView, Toolbar::Position tbPos)
: View(res, parentView), m_tbPos(tbPos)
#define TRIANGLE_DIM 12
#define TRIANGLE_DIM1 10
#define TRIANGLE_DIM2 8
#define TRIANGLE_DIM3 6
#define TRIANGLE_DIM4 4
#define TRIANGLE_DIM5 2
#define CORNER_DRAG_THRESHOLD 20
Space::Space(ViewResources& res, View& parentView, ISpaceController& controller, Toolbar::Position tbPos)
: View(res, parentView), m_controller(controller), m_tbPos(tbPos)
{
commitResources(res);
setBackground(res.themeData().spaceBackground());
if (controller.spaceSplitAllowed())
m_cornerView.m_view.reset(new CornerView(res, *this, spaceTriangleColor()));
if (tbPos != Toolbar::Position::None)
m_toolbar.reset(new Toolbar(res, *this, tbPos));
m_toolbar.m_view.reset(new Toolbar(res, *this, tbPos));
}
Space::CornerView::CornerView(ViewResources& res, Space& space, const Zeus::CColor& triColor)
: View(res, space), m_space(space)
{
m_vertexBinding.initSolid(res, 34, m_viewVertBlockBuf);
float pf = res.pixelFactor();
Zeus::CColor edgeColor1 = triColor * res.themeData().spaceTriangleShading1();
Zeus::CColor edgeColor2 = triColor * res.themeData().spaceTriangleShading2();
View::SolidShaderVert verts[34];
verts[0].m_pos.assign(0, TRIANGLE_DIM * pf, 0);
verts[0].m_color = edgeColor1;
verts[1].m_pos.assign(TRIANGLE_DIM * pf, 0, 0);
verts[1].m_color = edgeColor1;
verts[2].m_pos.assign(0, (TRIANGLE_DIM + 1) * pf, 0);
verts[2].m_color = edgeColor1;
verts[3].m_pos.assign((TRIANGLE_DIM + 1) * pf, 0, 0);
verts[3].m_color = edgeColor1;
verts[4] = verts[3];
verts[5].m_pos.assign(0, TRIANGLE_DIM1 * pf, 0);
verts[5].m_color = edgeColor2;
verts[6] = verts[5];
verts[7].m_pos.assign(TRIANGLE_DIM1 * pf, 0, 0);
verts[7].m_color = edgeColor2;
verts[8].m_pos.assign(0, (TRIANGLE_DIM1 + 1) * pf, 0);
verts[8].m_color = edgeColor2;
verts[9].m_pos.assign((TRIANGLE_DIM1 + 1) * pf, 0, 0);
verts[9].m_color = edgeColor2;
verts[10] = verts[9];
verts[11].m_pos.assign(0, TRIANGLE_DIM2 * pf, 0);
verts[11].m_color = edgeColor2;
verts[12] = verts[11];
verts[13].m_pos.assign(TRIANGLE_DIM2 * pf, 0, 0);
verts[13].m_color = edgeColor2;
verts[14].m_pos.assign(0, (TRIANGLE_DIM2 + 1) * pf, 0);
verts[14].m_color = edgeColor2;
verts[15].m_pos.assign((TRIANGLE_DIM2 + 1) * pf, 0, 0);
verts[15].m_color = edgeColor2;
verts[16] = verts[15];
verts[17].m_pos.assign(0, TRIANGLE_DIM3 * pf, 0);
verts[17].m_color = edgeColor2;
verts[18] = verts[17];
verts[19].m_pos.assign(TRIANGLE_DIM3 * pf, 0, 0);
verts[19].m_color = edgeColor2;
verts[20].m_pos.assign(0, (TRIANGLE_DIM3 + 1) * pf, 0);
verts[20].m_color = edgeColor2;
verts[21].m_pos.assign((TRIANGLE_DIM3 + 1) * pf, 0, 0);
verts[21].m_color = edgeColor2;
verts[22] = verts[21];
verts[23].m_pos.assign(0, TRIANGLE_DIM4 * pf, 0);
verts[23].m_color = edgeColor2;
verts[24] = verts[23];
verts[25].m_pos.assign(TRIANGLE_DIM4 * pf, 0, 0);
verts[25].m_color = edgeColor2;
verts[26].m_pos.assign(0, (TRIANGLE_DIM4 + 1) * pf, 0);
verts[26].m_color = edgeColor2;
verts[27].m_pos.assign((TRIANGLE_DIM4 + 1) * pf, 0, 0);
verts[27].m_color = edgeColor2;
verts[28] = verts[27];
verts[29].m_pos.assign(0, TRIANGLE_DIM5 * pf, 0);
verts[29].m_color = edgeColor2;
verts[30] = verts[29];
verts[31].m_pos.assign(TRIANGLE_DIM5 * pf, 0, 0);
verts[31].m_color = edgeColor2;
verts[32].m_pos.assign(0, (TRIANGLE_DIM5 + 1) * pf, 0);
verts[32].m_color = edgeColor2;
verts[33].m_pos.assign((TRIANGLE_DIM5 + 1) * pf, 0, 0);
verts[33].m_color = edgeColor2;
m_vertexBinding.load(verts, sizeof(verts));
}
View* Space::setContentView(View* view)
{
View* ret = m_contentView;
m_contentView = view;
View* ret = m_contentView.m_view;
m_contentView.m_view = view;
updateSize();
return ret;
}
void Space::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
{
if (m_contentView && !m_contentMouseDown &&
m_contentView->subRect().coordInRect(coord))
if (m_cornerView.mouseDown(coord, button, mod))
return;
m_contentView.mouseDown(coord, button, mod);
m_toolbar.mouseDown(coord, button, mod);
}
void Space::CornerView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
{
if (button == boo::EMouseButton::Primary)
{
m_contentView->mouseDown(coord, button, mod);
m_contentMouseDown = true;
}
if (m_toolbar && !m_toolbarMouseDown &&
m_toolbar->subRect().coordInRect(coord))
{
m_toolbar->mouseDown(coord, button, mod);
m_toolbarMouseDown = true;
m_space.m_cornerDrag = true;
m_space.m_cornerDragPoint[0] = coord.pixel[0];
m_space.m_cornerDragPoint[1] = coord.pixel[1];
}
}
void Space::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
{
if (m_contentView && m_contentMouseDown)
m_cornerView.mouseUp(coord, button, mod);
m_contentView.mouseUp(coord, button, mod);
m_toolbar.mouseUp(coord, button, mod);
}
void Space::CornerView::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
{
if (button == boo::EMouseButton::Primary)
{
m_contentView->mouseUp(coord, button, mod);
m_contentMouseDown = false;
}
if (m_toolbar && m_toolbarMouseDown)
{
m_toolbar->mouseUp(coord, button, mod);
m_toolbarMouseDown = false;
m_space.m_cornerDrag = false;
m_space.m_cornerDragSplitSpace = nullptr;
}
}
void Space::mouseMove(const boo::SWindowCoord& coord)
{
if (m_contentView)
if (m_cornerDragSplitSpace)
{
if (m_contentView->subRect().coordInRect(coord))
{
if (!m_contentMouseIn)
{
m_contentView->mouseEnter(coord);
m_contentMouseIn = true;
}
m_contentView->mouseMove(coord);
}
else
{
if (m_contentMouseIn)
{
m_contentView->mouseLeave(coord);
m_contentMouseIn = false;
}
}
m_cornerDragSplitSpace->splitView()->mouseMove(coord);
}
if (m_toolbar)
else if (m_cornerDrag)
{
if (m_toolbar->subRect().coordInRect(coord))
float pf = rootView().viewRes().pixelFactor();
if (m_cornerView.m_view->m_flip)
{
if (!m_toolbarMouseIn)
{
m_toolbar->mouseEnter(coord);
m_toolbarMouseIn = true;
}
m_toolbar->mouseMove(coord);
if (coord.pixel[0] < m_cornerDragPoint[0] - CORNER_DRAG_THRESHOLD * pf)
m_cornerDragSplitSpace = m_controller.spaceSplit(SplitView::Axis::Vertical, 1);
else if (coord.pixel[1] < m_cornerDragPoint[1] - CORNER_DRAG_THRESHOLD * pf)
m_cornerDragSplitSpace = m_controller.spaceSplit(SplitView::Axis::Horizontal, 1);
}
else
{
if (m_toolbarMouseIn)
{
m_toolbar->mouseLeave(coord);
m_toolbarMouseIn = false;
}
if (coord.pixel[0] > m_cornerDragPoint[0] + CORNER_DRAG_THRESHOLD * pf)
m_cornerDragSplitSpace = m_controller.spaceSplit(SplitView::Axis::Vertical, 0);
else if (coord.pixel[1] > m_cornerDragPoint[1] + CORNER_DRAG_THRESHOLD * pf)
m_cornerDragSplitSpace = m_controller.spaceSplit(SplitView::Axis::Horizontal, 0);
}
if (m_cornerDragSplitSpace)
m_cornerDragSplitSpace->splitView()->startDragSplit(coord);
}
else
{
m_cornerView.mouseMove(coord);
m_contentView.mouseMove(coord);
m_toolbar.mouseMove(coord);
}
}
void Space::mouseEnter(const boo::SWindowCoord& coord)
{
m_cornerView.mouseEnter(coord);
m_contentView.mouseEnter(coord);
m_toolbar.mouseEnter(coord);
}
void Space::CornerView::mouseEnter(const boo::SWindowCoord& coord)
{
rootView().setSpaceCornerHover(true);
}
void Space::mouseLeave(const boo::SWindowCoord& coord)
{
if (m_contentView && m_contentMouseIn)
{
m_contentView->mouseLeave(coord);
m_contentMouseIn = false;
}
if (m_toolbar && m_toolbarMouseIn)
{
m_toolbar->mouseLeave(coord);
m_toolbarMouseIn = false;
}
m_cornerView.mouseLeave(coord);
m_contentView.mouseLeave(coord);
m_toolbar.mouseLeave(coord);
}
void Space::CornerView::mouseLeave(const boo::SWindowCoord& coord)
{
rootView().setSpaceCornerHover(false);
}
void Space::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
{
View::resized(root, sub);
boo::SWindowRect tbRect = sub;
if (m_toolbar)
float pf = rootView().viewRes().pixelFactor();
if (m_cornerView.m_view)
{
tbRect.size[1] = m_toolbar->nominalHeight();
boo::SWindowRect cornerRect = sub;
int triDim = TRIANGLE_DIM * pf;
cornerRect.size[0] = cornerRect.size[1] = triDim;
if (cornerRect.location[0] < triDim && cornerRect.location[1] < triDim)
{
cornerRect.location[0] += sub.size[0] - triDim;
cornerRect.location[1] += sub.size[1] - triDim;
m_cornerView.m_view->resized(root, cornerRect, true);
}
else
m_cornerView.m_view->resized(root, cornerRect, false);
}
boo::SWindowRect tbRect = sub;
if (m_toolbar.m_view)
{
tbRect.size[1] = m_toolbar.m_view->nominalHeight();
if (m_tbPos == Toolbar::Position::Top)
tbRect.location[1] += sub.size[1] - tbRect.size[1];
m_toolbar->resized(root, tbRect);
m_toolbar.m_view->resized(root, tbRect);
}
else
tbRect.size[1] = 0;
if (m_contentView)
if (m_contentView.m_view)
{
boo::SWindowRect contentRect = sub;
if (m_tbPos == Toolbar::Position::Bottom)
contentRect.location[1] += tbRect.size[1];
contentRect.size[1] = sub.size[1] - tbRect.size[1];
contentRect.size[1] = std::max(contentRect.size[1], 0);
m_contentView->resized(root, contentRect);
m_contentView.m_view->resized(root, contentRect);
}
}
void Space::CornerView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub, bool flip)
{
m_flip = flip;
if (flip)
{
m_viewVertBlock.m_mv[0][0] = -2.0f / root.size[0];
m_viewVertBlock.m_mv[1][1] = -2.0f / root.size[1];
m_viewVertBlock.m_mv[3][0] = (sub.location[0] + sub.size[0]) * -m_viewVertBlock.m_mv[0][0] - 1.0f;
m_viewVertBlock.m_mv[3][1] = (sub.location[1] + sub.size[1]) * -m_viewVertBlock.m_mv[1][1] - 1.0f;
View::resized(m_viewVertBlock, sub);
}
else
View::resized(root, sub);
}
void Space::draw(boo::IGraphicsCommandQueue* gfxQ)
{
View::draw(gfxQ);
if (m_contentView)
m_contentView->draw(gfxQ);
if (m_toolbar)
m_toolbar->draw(gfxQ);
if (m_contentView.m_view)
m_contentView.m_view->draw(gfxQ);
if (m_toolbar.m_view)
m_toolbar.m_view->draw(gfxQ);
if (m_cornerView.m_view)
m_cornerView.m_view->draw(gfxQ);
}
void Space::CornerView::draw(boo::IGraphicsCommandQueue* gfxQ)
{
gfxQ->setShaderDataBinding(m_vertexBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
gfxQ->draw(0, 34);
}
}

View File

@ -7,7 +7,7 @@ namespace Specter
{
static LogVisor::LogModule Log("Specter::SplitView");
void SplitView::Resources::init(boo::IGraphicsDataFactory* factory, const ThemeData& theme)
void SplitView::Resources::init(boo::IGraphicsDataFactory* factory, const IThemeData& theme)
{
static const Zeus::RGBA32 tex[3] =
{
@ -38,7 +38,7 @@ View* SplitView::setContentView(int slot, View* view)
return ret;
}
void SplitView::_setSlide(float slide)
void SplitView::_setSplit(float slide)
{
m_slide = std::min(std::max(slide, 0.0f), 1.0f);
const boo::SWindowRect& rect = subRect();
@ -65,46 +65,55 @@ void SplitView::_setSlide(float slide)
}
}
void SplitView::setSlide(float slide)
void SplitView::setSplit(float slide)
{
_setSlide(slide);
_setSplit(slide);
updateSize();
}
void SplitView::startDragSplit(const boo::SWindowCoord& coord)
{
m_dragging = true;
mouseMove(coord);
}
void SplitView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
{
if (m_axis == Axis::Horizontal)
if (!rootView().m_spaceCornerHover)
{
int slidePx = subRect().size[1] * m_slide;
if (abs(int(coord.pixel[1] - subRect().location[1]) - slidePx) < 4)
if (m_axis == Axis::Horizontal)
{
if (button == boo::EMouseButton::Primary)
int slidePx = subRect().size[1] * m_slide;
if (abs(int(coord.pixel[1] - subRect().location[1]) - slidePx) < 4)
{
m_dragging = true;
setSlide((coord.pixel[1] - subRect().location[1]) / float(subRect().size[1]));
if (button == boo::EMouseButton::Primary)
{
m_dragging = true;
setSplit((coord.pixel[1] - subRect().location[1]) / float(subRect().size[1]));
}
else if (button == boo::EMouseButton::Secondary)
{
// TODO: Split menu
}
return;
}
else if (button == boo::EMouseButton::Secondary)
{
// TODO: Split menu
}
return;
}
}
else if (m_axis == Axis::Vertical)
{
int slidePx = subRect().size[0] * m_slide;
if (abs(int(coord.pixel[0] - subRect().location[0]) - slidePx) < 4)
else if (m_axis == Axis::Vertical)
{
if (button == boo::EMouseButton::Primary)
int slidePx = subRect().size[0] * m_slide;
if (abs(int(coord.pixel[0] - subRect().location[0]) - slidePx) < 4)
{
m_dragging = true;
setSlide((coord.pixel[0] - subRect().location[0]) / float(subRect().size[0]));
if (button == boo::EMouseButton::Primary)
{
m_dragging = true;
setSplit((coord.pixel[0] - subRect().location[0]) / float(subRect().size[0]));
}
else if (button == boo::EMouseButton::Secondary)
{
// TODO: Split menu
}
return;
}
else if (button == boo::EMouseButton::Secondary)
{
// TODO: Split menu
}
return;
}
}
m_views[0].mouseDown(coord, button, mod);
@ -124,14 +133,14 @@ void SplitView::mouseMove(const boo::SWindowCoord& coord)
if (m_axis == Axis::Horizontal)
{
if (m_dragging)
setSlide((coord.pixel[1] - subRect().location[1]) / float(subRect().size[1]));
setSplit((coord.pixel[1] - subRect().location[1]) / float(subRect().size[1]));
int slidePx = subRect().size[1] * m_slide;
rootView().setHorizontalSplitHover(abs(int(coord.pixel[1] - subRect().location[1]) - slidePx) < 4);
}
else if (m_axis == Axis::Vertical)
{
if (m_dragging)
setSlide((coord.pixel[0] - subRect().location[0]) / float(subRect().size[0]));
setSplit((coord.pixel[0] - subRect().location[0]) / float(subRect().size[0]));
int slidePx = subRect().size[0] * m_slide;
rootView().setVerticalSplitHover(abs(int(coord.pixel[0] - subRect().location[0]) - slidePx) < 4);
}
@ -155,7 +164,7 @@ void SplitView::mouseLeave(const boo::SWindowCoord& coord)
void SplitView::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
{
View::resized(root, sub);
_setSlide(m_slide);
_setSplit(m_slide);
if (m_axis == Axis::Horizontal)
{
boo::SWindowRect ssub = sub;

View File

@ -39,7 +39,7 @@ void Table::_setHeaderVerts(const boo::SWindowRect& sub)
if (m_headerViews.empty())
return;
SolidShaderVert* v = m_hVerts.get();
const ThemeData& theme = rootView().themeData();
const IThemeData& theme = rootView().themeData();
float pf = rootView().viewRes().pixelFactor();
int margin = CELL_MARGIN * pf;
@ -118,7 +118,7 @@ void Table::_setHeaderVerts(const boo::SWindowRect& sub)
void Table::RowsView::_setRowVerts(const boo::SWindowRect& sub, const boo::SWindowRect& scissor)
{
SolidShaderVert* v = m_verts.get();
const ThemeData& theme = rootView().themeData();
const IThemeData& theme = rootView().themeData();
if (m_t.m_cellPools.empty())
return;

View File

@ -106,7 +106,7 @@ void TextField::setText(const std::string& str)
void TextField::setInactive()
{
const ThemeData& theme = rootView().themeData();
const IThemeData& theme = rootView().themeData();
if (m_error)
{
m_verts[0].m_color = theme.textfield1Inactive() * Zeus::CColor::skRed;
@ -133,7 +133,7 @@ void TextField::setInactive()
void TextField::setHover()
{
const ThemeData& theme = rootView().themeData();
const IThemeData& theme = rootView().themeData();
if (m_error)
{
m_verts[0].m_color = theme.textfield1Hover() * Zeus::CColor::skRed;
@ -160,7 +160,7 @@ void TextField::setHover()
void TextField::setDisabled()
{
const ThemeData& theme = rootView().themeData();
const IThemeData& theme = rootView().themeData();
if (m_error)
{
m_verts[0].m_color = theme.textfield1Disabled() * Zeus::CColor::skRed;

View File

@ -9,7 +9,7 @@ namespace Specter
{
static LogVisor::LogModule Log("Specter::Space");
void Toolbar::Resources::init(boo::IGraphicsDataFactory* factory, const ThemeData& theme)
void Toolbar::Resources::init(boo::IGraphicsDataFactory* factory, const IThemeData& theme)
{
static const Zeus::RGBA32 tex[] =
{

View File

@ -6,7 +6,7 @@ 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 IThemeData& theme)
{
static const char* SolidVS =
"#version 330\n"
@ -183,7 +183,7 @@ void View::Resources::init(boo::ID3DDataFactory* factory, const ThemeData& theme
#elif BOO_HAS_METAL
void View::Resources::init(boo::MetalDataFactory* factory, const ThemeData& theme)
void View::Resources::init(boo::MetalDataFactory* factory, const IThemeData& theme)
{
static const char* SolidVS =
"#include <metal_stdlib>\n"
@ -323,6 +323,17 @@ void View::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
m_bgVertsBinding.load(m_bgRect, sizeof(m_bgRect));
}
void View::resized(const ViewBlock& vb, const boo::SWindowRect& sub)
{
m_subRect = sub;
m_bgRect[0].m_pos.assign(0.f, sub.size[1], 0.f);
m_bgRect[1].m_pos.assign(0.f, 0.f, 0.f);
m_bgRect[2].m_pos.assign(sub.size[0], sub.size[1], 0.f);
m_bgRect[3].m_pos.assign(sub.size[0], 0.f, 0.f);
m_viewVertBlockBuf->load(&vb, sizeof(ViewBlock));
m_bgVertsBinding.load(m_bgRect, sizeof(m_bgRect));
}
void View::draw(boo::IGraphicsCommandQueue* gfxQ)
{
gfxQ->setShaderDataBinding(m_bgVertsBinding);

View File

@ -5,8 +5,10 @@ namespace Specter
static LogVisor::LogModule Log("Specter::ViewResources");
void ViewResources::init(boo::IGraphicsDataFactory* factory, FontCache* fcache,
const ThemeData& theme, float pf)
const IThemeData* theme, float pf)
{
if (!factory || !fcache || !theme)
Log.report(LogVisor::FatalError, "all arguments of ViewResources::init() must be non-null");
m_pixelFactor = pf;
m_theme = theme;
m_factory = factory;
@ -16,16 +18,16 @@ void ViewResources::init(boo::IGraphicsDataFactory* factory, FontCache* fcache,
switch (factory->platform())
{
case boo::IGraphicsDataFactory::Platform::OGL:
init<boo::GLDataFactory>(static_cast<boo::GLDataFactory*>(factory), theme, fcache);
init<boo::GLDataFactory>(static_cast<boo::GLDataFactory*>(factory), *theme, fcache);
break;
#if _WIN32
case boo::IGraphicsDataFactory::Platform::D3D11:
case boo::IGraphicsDataFactory::Platform::D3D12:
init<boo::ID3DDataFactory>(static_cast<boo::ID3DDataFactory*>(factory), theme, fcache);
init<boo::ID3DDataFactory>(static_cast<boo::ID3DDataFactory*>(factory), *theme, fcache);
break;
#elif BOO_HAS_METAL
case boo::IGraphicsDataFactory::Platform::Metal:
init<boo::MetalDataFactory>(static_cast<boo::MetalDataFactory*>(factory), theme, fcache);
init<boo::MetalDataFactory>(static_cast<boo::MetalDataFactory*>(factory), *theme, fcache);
break;
#endif
default:
@ -70,7 +72,7 @@ void ViewResources::resetPixelFactor(float pf)
prepFontCacheSync();
}
void ViewResources::resetTheme(const ThemeData& theme)
void ViewResources::resetTheme(const IThemeData* theme)
{
m_theme = theme;
}