From 633ecfb18ec4127d8f8291a8e00c7b867b227f77 Mon Sep 17 00:00:00 2001 From: Darby Johnston Date: Thu, 17 Oct 2024 17:36:35 -0700 Subject: [PATCH] Refactoring --- bin/toucan-view/CMakeLists.txt | 4 ++ bin/toucan-view/DocumentTab.cpp | 45 ++--------------- bin/toucan-view/DocumentTab.h | 15 ------ bin/toucan-view/Export.cpp | 9 ++++ bin/toucan-view/Export.h | 10 ++++ bin/toucan-view/ExportTool.cpp | 77 ++++++++++++++++++++++++++++++ bin/toucan-view/ExportTool.h | 58 ++++++++++++++++++++++ bin/toucan-view/GraphTool.cpp | 65 +++++++++++++++---------- bin/toucan-view/GraphTool.h | 6 +-- bin/toucan-view/InspectorTool.cpp | 41 +++++++++++----- bin/toucan-view/InspectorTool.h | 5 +- bin/toucan-view/MenuBar.cpp | 10 ++++ bin/toucan-view/TimelineWidget.cpp | 64 ++++++++++++++++--------- bin/toucan-view/TimelineWidget.h | 3 +- bin/toucan-view/Viewport.cpp | 5 +- bin/toucan-view/Window.cpp | 36 +++++++++++++- bin/toucan-view/Window.h | 11 +++++ 17 files changed, 336 insertions(+), 128 deletions(-) create mode 100644 bin/toucan-view/Export.cpp create mode 100644 bin/toucan-view/Export.h create mode 100644 bin/toucan-view/ExportTool.cpp create mode 100644 bin/toucan-view/ExportTool.h diff --git a/bin/toucan-view/CMakeLists.txt b/bin/toucan-view/CMakeLists.txt index f9bc4dc..5a0ee63 100644 --- a/bin/toucan-view/CMakeLists.txt +++ b/bin/toucan-view/CMakeLists.txt @@ -5,6 +5,8 @@ set(HEADERS DocumentTab.h Document.h DocumentsModel.h + Export.h + ExportTool.h GapItem.h GraphTool.h IItem.h @@ -33,6 +35,8 @@ set(SOURCE DocumentTab.cpp Document.cpp DocumentsModel.cpp + Export.cpp + ExportTool.cpp GapItem.cpp GraphTool.cpp IItem.cpp diff --git a/bin/toucan-view/DocumentTab.cpp b/bin/toucan-view/DocumentTab.cpp index 6e02f36..c052f0c 100644 --- a/bin/toucan-view/DocumentTab.cpp +++ b/bin/toucan-view/DocumentTab.cpp @@ -5,10 +5,6 @@ #include "DocumentTab.h" #include "App.h" -#include "BottomBar.h" -#include "GraphTool.h" -#include "InspectorTool.h" -#include "TimelineWidget.h" #include "Viewport.h" namespace toucan @@ -20,43 +16,8 @@ namespace toucan const std::shared_ptr& parent) { dtk::IWidget::_init(context, "toucan::DocumentTab", parent); - - _vSplitter = dtk::Splitter::create(context, dtk::Orientation::Vertical, shared_from_this()); - _vSplitter->setSplit({ .7F, .3F }); - _vSplitter->setStretch(dtk::Stretch::Expanding); - _hSplitter = dtk::Splitter::create(context, dtk::Orientation::Horizontal, _vSplitter); - _hSplitter->setSplit({ .75F, .25F }); - - _viewport = Viewport::create(context, document, _hSplitter); + _viewport = Viewport::create(context, document, shared_from_this()); _viewport->setStretch(dtk::Stretch::Expanding); - - _toolWidget = dtk::TabWidget::create(context, _hSplitter); - _toolWidgets.push_back(InspectorTool::create(context, app, document)); - _toolWidgets.push_back(GraphTool::create(context, app, document)); - for (const auto& toolWidget : _toolWidgets) - { - _toolWidget->addTab(toolWidget->getText(), toolWidget); - } - - _bottomLayout = dtk::VerticalLayout::create(context, _vSplitter); - _bottomLayout->setSpacingRole(dtk::SizeRole::None); - _bottomBar = BottomBar::create(context, app, _bottomLayout); - _timelineWidget = TimelineWidget::create(context, app, document, _bottomLayout); - _timelineWidget->setVStretch(dtk::Stretch::Expanding); - - std::weak_ptr appWeak(app); - _controlsObserver = dtk::MapObserver::create( - app->getWindowModel()->observeControls(), - [this](const std::map& value) - { - auto i = value.find(WindowControl::TimelineWidget); - _timelineWidget->setVisible(i->second); - auto j = value.find(WindowControl::BottomBar); - _bottomBar->setVisible(j->second); - _bottomLayout->setVisible(i->second || j->second); - i = value.find(WindowControl::Tools); - _toolWidget->setVisible(i->second); - }); } DocumentTab::~DocumentTab() @@ -76,12 +37,12 @@ namespace toucan void DocumentTab::setGeometry(const dtk::Box2I& value) { dtk::IWidget::setGeometry(value); - _vSplitter->setGeometry(value); + _viewport->setGeometry(value); } void DocumentTab::sizeHintEvent(const dtk::SizeHintEvent& event) { dtk::IWidget::sizeHintEvent(event); - _setSizeHint(_vSplitter->getSizeHint()); + _setSizeHint(_viewport->getSizeHint()); } } diff --git a/bin/toucan-view/DocumentTab.h b/bin/toucan-view/DocumentTab.h index 0020165..c31436b 100644 --- a/bin/toucan-view/DocumentTab.h +++ b/bin/toucan-view/DocumentTab.h @@ -6,18 +6,12 @@ #include "WindowModel.h" -#include #include -#include -#include namespace toucan { class App; - class BottomBar; class Document; - class IToolWidget; - class TimelineWidget; class Viewport; class DocumentTab : public dtk::IWidget @@ -42,16 +36,7 @@ namespace toucan void sizeHintEvent(const dtk::SizeHintEvent&) override; private: - std::shared_ptr _vSplitter; - std::shared_ptr _hSplitter; std::shared_ptr _viewport; - std::shared_ptr _toolWidget; - std::vector > _toolWidgets; - std::shared_ptr _bottomLayout; - std::shared_ptr _bottomBar; - std::shared_ptr _timelineWidget; - - std::shared_ptr > _controlsObserver; }; } diff --git a/bin/toucan-view/Export.cpp b/bin/toucan-view/Export.cpp new file mode 100644 index 0000000..b241a3f --- /dev/null +++ b/bin/toucan-view/Export.cpp @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2024 Darby Johnston +// All rights reserved. + +#include "Export.h" + +namespace toucan +{ +} diff --git a/bin/toucan-view/Export.h b/bin/toucan-view/Export.h new file mode 100644 index 0000000..e82a211 --- /dev/null +++ b/bin/toucan-view/Export.h @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2024 Darby Johnston +// All rights reserved. + +#pragma once + +namespace toucan +{ +} + diff --git a/bin/toucan-view/ExportTool.cpp b/bin/toucan-view/ExportTool.cpp new file mode 100644 index 0000000..7ed08c7 --- /dev/null +++ b/bin/toucan-view/ExportTool.cpp @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2024 Darby Johnston +// All rights reserved. + +#include "ExportTool.h" + +namespace toucan +{ + void ExportWidget::_init( + const std::shared_ptr& context, + const std::shared_ptr& parent) + { + IWidget::_init(context, "toucan::ExportWidget", parent); + + _layout = dtk::VerticalLayout::create(context, shared_from_this()); + } + + ExportWidget::~ExportWidget() + {} + + std::shared_ptr ExportWidget::create( + const std::shared_ptr& context, + const std::shared_ptr& parent) + { + auto out = std::shared_ptr(new ExportWidget); + out->_init(context, parent); + return out; + } + + void ExportWidget::setGeometry(const dtk::Box2I& value) + { + IWidget::setGeometry(value); + _layout->setGeometry(value); + } + + void ExportWidget::sizeHintEvent(const dtk::SizeHintEvent& event) + { + IWidget::sizeHintEvent(event); + _setSizeHint(_layout->getSizeHint()); + } + + void ExportTool::_init( + const std::shared_ptr& context, + const std::shared_ptr& app, + const std::shared_ptr& parent) + { + IToolWidget::_init(context, app, "toucan::ExportTool", "Export", parent); + + _layout = dtk::VerticalLayout::create(context, shared_from_this()); + _layout->setSpacingRole(dtk::SizeRole::None); + } + + ExportTool::~ExportTool() + {} + + std::shared_ptr ExportTool::create( + const std::shared_ptr& context, + const std::shared_ptr& app, + const std::shared_ptr& parent) + { + auto out = std::shared_ptr(new ExportTool); + out->_init(context, app, parent); + return out; + } + + void ExportTool::setGeometry(const dtk::Box2I& value) + { + IToolWidget::setGeometry(value); + _layout->setGeometry(value); + } + + void ExportTool::sizeHintEvent(const dtk::SizeHintEvent& event) + { + IToolWidget::sizeHintEvent(event); + _setSizeHint(_layout->getSizeHint()); + } +} diff --git a/bin/toucan-view/ExportTool.h b/bin/toucan-view/ExportTool.h new file mode 100644 index 0000000..fab664c --- /dev/null +++ b/bin/toucan-view/ExportTool.h @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (c) 2024 Darby Johnston +// All rights reserved. + +#pragma once + +#include "IToolWidget.h" + +#include + +namespace toucan +{ + class ExportWidget : public dtk::IWidget + { + protected: + void _init( + const std::shared_ptr&, + const std::shared_ptr& parent); + + public: + virtual ~ExportWidget(); + + static std::shared_ptr create( + const std::shared_ptr&, + const std::shared_ptr& parent = nullptr); + + void setGeometry(const dtk::Box2I&) override; + void sizeHintEvent(const dtk::SizeHintEvent&) override; + + private: + std::shared_ptr _layout; + }; + + class ExportTool : public IToolWidget + { + protected: + void _init( + const std::shared_ptr&, + const std::shared_ptr&, + const std::shared_ptr& parent); + + public: + virtual ~ExportTool(); + + static std::shared_ptr create( + const std::shared_ptr&, + const std::shared_ptr&, + const std::shared_ptr& parent = nullptr); + + void setGeometry(const dtk::Box2I&) override; + void sizeHintEvent(const dtk::SizeHintEvent&) override; + + private: + std::shared_ptr _layout; + std::shared_ptr _widget; + }; +} + diff --git a/bin/toucan-view/GraphTool.cpp b/bin/toucan-view/GraphTool.cpp index df31823..eab4be4 100644 --- a/bin/toucan-view/GraphTool.cpp +++ b/bin/toucan-view/GraphTool.cpp @@ -4,6 +4,7 @@ #include "GraphTool.h" +#include "App.h" #include "Document.h" #include @@ -13,7 +14,6 @@ namespace toucan void GraphWidget::_init( const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& document, const std::shared_ptr& parent) { IWidget::_init(context, "toucan::GraphWidget", parent); @@ -25,36 +25,54 @@ namespace toucan _buttonGroup = dtk::ButtonGroup::create(context, dtk::ButtonGroupType::Radio); _buttonGroup->setCheckedCallback( - [this, document](int index, bool value) + [this](int index, bool value) { - if (index >= 0 && index < _buttons.size()) + if (_document && index >= 0 && index < _buttons.size()) { auto i = _buttonToNode.find(_buttons[index]); if (i != _buttonToNode.end()) { - document->setCurrentNode(i->second); + _document->setCurrentNode(i->second); } } }); - _rootNodeObserver = dtk::ValueObserver >::create( - document->observeRootNode(), - [this](const std::shared_ptr& node) + _documentObserver = dtk::ValueObserver >::create( + app->getDocumentsModel()->observeCurrent(), + [this](const std::shared_ptr& document) { - _rootNode = node; - _depth = _getDepth(_rootNode); - _graphUpdate(); - }); + _document = document; + if (document) + { + _rootNodeObserver = dtk::ValueObserver >::create( + document->observeRootNode(), + [this](const std::shared_ptr& node) + { + _rootNode = node; + _depth = _getDepth(_rootNode); + _graphUpdate(); + }); - _currentNodeObserver = dtk::ValueObserver >::create( - document->observeRootNode(), - [this](const std::shared_ptr& node) - { - _currentNode = node; - auto i = _nodeToButton.find(node); - if (i != _nodeToButton.end()) + _currentNodeObserver = dtk::ValueObserver >::create( + document->observeCurrentNode(), + [this](const std::shared_ptr& node) + { + _currentNode = node; + auto i = _nodeToButton.find(node); + if (i != _nodeToButton.end()) + { + i->second->setChecked(true); + } + }); + } + else { - i->second->setChecked(true); + _rootNode.reset(); + _depth = 0; + _currentNode.reset(); + _rootNodeObserver.reset(); + _currentNodeObserver.reset(); + _graphUpdate(); } }); } @@ -65,11 +83,10 @@ namespace toucan std::shared_ptr GraphWidget::create( const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& document, const std::shared_ptr& parent) { auto out = std::shared_ptr(new GraphWidget); - out->_init(context, app, document, parent); + out->_init(context, app, parent); return out; } @@ -201,7 +218,6 @@ namespace toucan void GraphTool::_init( const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& document, const std::shared_ptr& parent) { IToolWidget::_init(context, app, "toucan::GraphTool", "Graph", parent); @@ -209,7 +225,7 @@ namespace toucan _scrollWidget = dtk::ScrollWidget::create(context, dtk::ScrollType::Both, shared_from_this()); _scrollWidget->setBorder(false); - _widget = GraphWidget::create(context, app, document); + _widget = GraphWidget::create(context, app); _scrollWidget->setWidget(_widget); } @@ -219,11 +235,10 @@ namespace toucan std::shared_ptr GraphTool::create( const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& document, const std::shared_ptr& parent) { auto out = std::shared_ptr(new GraphTool); - out->_init(context, app, document, parent); + out->_init(context, app, parent); return out; } diff --git a/bin/toucan-view/GraphTool.h b/bin/toucan-view/GraphTool.h index 3208750..56d9b67 100644 --- a/bin/toucan-view/GraphTool.h +++ b/bin/toucan-view/GraphTool.h @@ -23,7 +23,6 @@ namespace toucan void _init( const std::shared_ptr&, const std::shared_ptr&, - const std::shared_ptr&, const std::shared_ptr& parent); public: @@ -32,7 +31,6 @@ namespace toucan static std::shared_ptr create( const std::shared_ptr&, const std::shared_ptr&, - const std::shared_ptr&, const std::shared_ptr& parent = nullptr); void setGeometry(const dtk::Box2I&) override; @@ -55,6 +53,7 @@ namespace toucan void _graphUpdate(); + std::shared_ptr _document; std::shared_ptr _rootNode; int _depth = 0; std::shared_ptr _currentNode; @@ -74,6 +73,7 @@ namespace toucan }; SizeData _size; + std::shared_ptr > > _documentObserver; std::shared_ptr > > _rootNodeObserver; std::shared_ptr > > _currentNodeObserver; }; @@ -84,7 +84,6 @@ namespace toucan void _init( const std::shared_ptr&, const std::shared_ptr&, - const std::shared_ptr&, const std::shared_ptr& parent); public: @@ -93,7 +92,6 @@ namespace toucan static std::shared_ptr create( const std::shared_ptr&, const std::shared_ptr&, - const std::shared_ptr&, const std::shared_ptr& parent = nullptr); void setGeometry(const dtk::Box2I&) override; diff --git a/bin/toucan-view/InspectorTool.cpp b/bin/toucan-view/InspectorTool.cpp index 19da1c6..f121081 100644 --- a/bin/toucan-view/InspectorTool.cpp +++ b/bin/toucan-view/InspectorTool.cpp @@ -64,7 +64,6 @@ namespace toucan void InspectorTool::_init( const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& document, const std::shared_ptr& parent) { IToolWidget::_init(context, app, "toucan::InspectorTool", "Inspector", parent); @@ -114,20 +113,37 @@ namespace toucan } }); - _selectionObserver = dtk::ListObserver >::create( - document->getSelectionModel()->observeSelection(), - [this](const std::vector >& selection) + _documentObserver = dtk::ValueObserver >::create( + app->getDocumentsModel()->observeCurrent(), + [this](const std::shared_ptr& document) { - for (const auto& widget : _widgets) + if (document) { - widget->setParent(nullptr); + _selectionObserver = dtk::ListObserver >::create( + document->getSelectionModel()->observeSelection(), + [this](const std::vector >& selection) + { + for (const auto& widget : _widgets) + { + widget->setParent(nullptr); + } + _widgets.clear(); + auto context = _getContext().lock(); + for (const auto& item : selection) + { + auto widget = InspectorWidget::create(context, item, _scrollLayout); + _widgets.push_back(widget); + } + }); } - _widgets.clear(); - auto context = _getContext().lock(); - for (const auto& item : selection) + else { - auto widget = InspectorWidget::create(context, item, _scrollLayout); - _widgets.push_back(widget); + for (const auto& widget : _widgets) + { + widget->setParent(nullptr); + } + _widgets.clear(); + _selectionObserver.reset(); } }); } @@ -138,11 +154,10 @@ namespace toucan std::shared_ptr InspectorTool::create( const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& document, const std::shared_ptr& parent) { auto out = std::shared_ptr(new InspectorTool); - out->_init(context, app, document, parent); + out->_init(context, app, parent); return out; } diff --git a/bin/toucan-view/InspectorTool.h b/bin/toucan-view/InspectorTool.h index 7e97347..ead4ac4 100644 --- a/bin/toucan-view/InspectorTool.h +++ b/bin/toucan-view/InspectorTool.h @@ -47,7 +47,6 @@ namespace toucan void _init( const std::shared_ptr&, const std::shared_ptr&, - const std::shared_ptr&, const std::shared_ptr& parent); public: @@ -56,18 +55,20 @@ namespace toucan static std::shared_ptr create( const std::shared_ptr&, const std::shared_ptr&, - const std::shared_ptr&, const std::shared_ptr& parent = nullptr); void setGeometry(const dtk::Box2I&) override; void sizeHintEvent(const dtk::SizeHintEvent&) override; private: + std::shared_ptr _document; + std::shared_ptr _layout; std::shared_ptr _scrollWidget; std::shared_ptr _scrollLayout; std::vector > _widgets; + std::shared_ptr > > _documentObserver; std::shared_ptr > > _selectionObserver; }; } diff --git a/bin/toucan-view/MenuBar.cpp b/bin/toucan-view/MenuBar.cpp index eed3538..dc91cfd 100644 --- a/bin/toucan-view/MenuBar.cpp +++ b/bin/toucan-view/MenuBar.cpp @@ -154,6 +154,16 @@ namespace toucan _menus["File"]->addDivider(); + _actions["File/Export"] = std::make_shared( + "Export", + dtk::Key::T, + static_cast(dtk::KeyModifier::Control), + [this] { + }); + _menus["File"]->addItem(_actions["File/Export"]); + + _menus["File"]->addDivider(); + _actions["File/Exit"] = std::make_shared( "Exit", dtk::Key::Q, diff --git a/bin/toucan-view/TimelineWidget.cpp b/bin/toucan-view/TimelineWidget.cpp index 63612ea..3bd60b4 100644 --- a/bin/toucan-view/TimelineWidget.cpp +++ b/bin/toucan-view/TimelineWidget.cpp @@ -19,7 +19,6 @@ namespace toucan void TimelineWidget::_init( const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& document, const std::shared_ptr& parent) { IWidget::_init(context, "toucan::TimelineWidget", parent); @@ -27,36 +26,56 @@ namespace toucan _setMouseHoverEnabled(true); _setMousePressEnabled(true, 0, static_cast(dtk::KeyModifier::Control)); - _document = document; - _timeRange = document->getPlaybackModel()->getTimeRange(); _frameView = dtk::ObservableValue::create(true); _scrollWidget = dtk::ScrollWidget::create(context, dtk::ScrollType::Both, shared_from_this()); _scrollWidget->setScrollEventsEnabled(false); _scrollWidget->setBorder(false); - _timelineItem = TimelineItem::create( - context, - app, - document); - _scrollWidget->setWidget(_timelineItem); - - _timelineItem->setCurrentTimeCallback( - [this](const OTIO_NS::RationalTime& value) + auto appWeak = std::weak_ptr(app); + _documentObserver = dtk::ValueObserver >::create( + app->getDocumentsModel()->observeCurrent(), + [this, appWeak](const std::shared_ptr& document) { - _document->getPlaybackModel()->setCurrentTime(value); - }); + _document = document; + if (document) + { + _timeRange = document->getPlaybackModel()->getTimeRange(); + _sizeInit = true; - _currentTimeObserver = dtk::ValueObserver::create( - document->getPlaybackModel()->observeCurrentTime(), - [this](const OTIO_NS::RationalTime& value) - { - _currentTime = value; - if (_timelineItem) + _timelineItem = TimelineItem::create( + _getContext().lock(), + appWeak.lock(), + document); + _timelineItem->setCurrentTimeCallback( + [this](const OTIO_NS::RationalTime& value) + { + if (_document) + { + _document->getPlaybackModel()->setCurrentTime(value); + } + }); + _scrollWidget->setWidget(_timelineItem); + + _currentTimeObserver = dtk::ValueObserver::create( + document->getPlaybackModel()->observeCurrentTime(), + [this](const OTIO_NS::RationalTime& value) + { + _currentTime = value; + if (_timelineItem) + { + _timelineItem->setCurrentTime(value); + } + _scrollUpdate(); + }); + } + else { - _timelineItem->setCurrentTime(value); + _timeRange = OTIO_NS::TimeRange(); + _timelineItem.reset(); + _scrollWidget->setWidget(nullptr); + _currentTimeObserver.reset(); } - _scrollUpdate(); }); } @@ -66,11 +85,10 @@ namespace toucan std::shared_ptr TimelineWidget::create( const std::shared_ptr& context, const std::shared_ptr& app, - const std::shared_ptr& document, const std::shared_ptr& parent) { auto out = std::shared_ptr(new TimelineWidget); - out->_init(context, app, document, parent); + out->_init(context, app, parent); return out; } diff --git a/bin/toucan-view/TimelineWidget.h b/bin/toucan-view/TimelineWidget.h index 72ffa1b..e2c2f63 100644 --- a/bin/toucan-view/TimelineWidget.h +++ b/bin/toucan-view/TimelineWidget.h @@ -23,7 +23,6 @@ namespace toucan void _init( const std::shared_ptr&, const std::shared_ptr&, - const std::shared_ptr&, const std::shared_ptr& parent); public: @@ -32,7 +31,6 @@ namespace toucan static std::shared_ptr create( const std::shared_ptr&, const std::shared_ptr&, - const std::shared_ptr&, const std::shared_ptr& parent = nullptr); void setViewZoom(double); @@ -87,6 +85,7 @@ namespace toucan }; MouseData _mouse; + std::shared_ptr > > _documentObserver; std::shared_ptr > _currentTimeObserver; }; } diff --git a/bin/toucan-view/Viewport.cpp b/bin/toucan-view/Viewport.cpp index 2e1d0be..ca011e1 100644 --- a/bin/toucan-view/Viewport.cpp +++ b/bin/toucan-view/Viewport.cpp @@ -168,13 +168,16 @@ namespace toucan void Viewport::drawEvent(const dtk::Box2I& drawRect, const dtk::DrawEvent& event) { IWidget::drawEvent(drawRect, event); + const dtk::Box2I& g = getGeometry(); + event.render->drawRect( + g, + dtk::Color4F(0.F, 0.F, 0.F)); if (_image) { if (_frame->get()) { _frameUpdate(); } - const dtk::Box2I& g = getGeometry(); const dtk::Size2I& imageSize = _image->getSize(); dtk::M44F vm; vm = vm * dtk::translate(dtk::V3F(g.min.x, g.min.y, 0.F)); diff --git a/bin/toucan-view/Window.cpp b/bin/toucan-view/Window.cpp index 9f85b5b..6393cd7 100644 --- a/bin/toucan-view/Window.cpp +++ b/bin/toucan-view/Window.cpp @@ -5,8 +5,13 @@ #include "Window.h" #include "App.h" +#include "BottomBar.h" #include "DocumentTab.h" +#include "ExportTool.h" +#include "GraphTool.h" +#include "InspectorTool.h" #include "MenuBar.h" +#include "TimelineWidget.h" #include "ToolBar.h" #include @@ -42,10 +47,32 @@ namespace toucan _layout); _toolBarDivider = dtk::Divider::create(context, dtk::Orientation::Vertical, _layout); - _tabWidget = dtk::TabWidget::create(context, _layout); + + _vSplitter = dtk::Splitter::create(context, dtk::Orientation::Vertical, _layout); + _vSplitter->setSplit({ .7F, .3F }); + _vSplitter->setStretch(dtk::Stretch::Expanding); + _hSplitter = dtk::Splitter::create(context, dtk::Orientation::Horizontal, _vSplitter); + _hSplitter->setSplit({ .75F, .25F }); + + _tabWidget = dtk::TabWidget::create(context, _hSplitter); _tabWidget->setTabsClosable(true); _tabWidget->setVStretch(dtk::Stretch::Expanding); + _toolWidget = dtk::TabWidget::create(context, _hSplitter); + _toolWidgets.push_back(InspectorTool::create(context, app)); + _toolWidgets.push_back(GraphTool::create(context, app)); + _toolWidgets.push_back(ExportTool::create(context, app)); + for (const auto& toolWidget : _toolWidgets) + { + _toolWidget->addTab(toolWidget->getText(), toolWidget); + } + + _bottomLayout = dtk::VerticalLayout::create(context, _vSplitter); + _bottomLayout->setSpacingRole(dtk::SizeRole::None); + _bottomBar = BottomBar::create(context, app, _bottomLayout); + _timelineWidget = TimelineWidget::create(context, app, _bottomLayout); + _timelineWidget->setVStretch(dtk::Stretch::Expanding); + std::weak_ptr appWeak(app); _tabWidget->setCallback( [appWeak](int index) @@ -119,6 +146,13 @@ namespace toucan auto i = value.find(WindowControl::ToolBar); _toolBar->setVisible(i->second); _toolBarDivider->setVisible(i->second); + i = value.find(WindowControl::TimelineWidget); + _timelineWidget->setVisible(i->second); + auto j = value.find(WindowControl::BottomBar); + _bottomBar->setVisible(j->second); + _bottomLayout->setVisible(i->second || j->second); + i = value.find(WindowControl::Tools); + _toolWidget->setVisible(i->second); }); _tooltipsObserver = dtk::ValueObserver::create( diff --git a/bin/toucan-view/Window.h b/bin/toucan-view/Window.h index d771b0e..22d46ef 100644 --- a/bin/toucan-view/Window.h +++ b/bin/toucan-view/Window.h @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -15,9 +16,12 @@ namespace toucan { class App; + class BottomBar; class Document; class DocumentTab; + class IToolWidget; class MenuBar; + class TimelineWidget; class ToolBar; class Window : public dtk::Window @@ -54,8 +58,15 @@ namespace toucan std::shared_ptr _menuBar; std::shared_ptr _toolBar; std::shared_ptr _toolBarDivider; + std::shared_ptr _vSplitter; + std::shared_ptr _hSplitter; std::shared_ptr _tabWidget; std::map, std::shared_ptr > _documentTabs; + std::shared_ptr _toolWidget; + std::vector > _toolWidgets; + std::shared_ptr _bottomLayout; + std::shared_ptr _bottomBar; + std::shared_ptr _timelineWidget; std::shared_ptr > > _documentsObserver; std::shared_ptr > _addObserver;