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