diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index 4a18c4244..c0537aa73 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -25,6 +25,8 @@ namespace CSVRender QPaintEngine* paintEngine() const; + protected: + void setNavigation (Navigation *navigation); ///< \attention The ownership of \a navigation is not transferred to *this. diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index c88821a62..dcd152bb3 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -1,6 +1,38 @@ #include "worldspacewidget.hpp" +#include "../world/scenetoolmode.hpp" + CSVRender::WorldspaceWidget::WorldspaceWidget (QWidget *parent) : SceneWidget (parent) -{} \ No newline at end of file +{} + +void CSVRender::WorldspaceWidget::selectNavigationMode (const std::string& mode) +{ + if (mode=="1st") + setNavigation (&m1st); + else if (mode=="free") + setNavigation (&mFree); + else if (mode=="orbit") + setNavigation (&mOrbit); +} + +void CSVRender::WorldspaceWidget::selectDefaultNavigationMode() +{ + setNavigation (&m1st); +} + +CSVWorld::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector ( + CSVWorld::SceneToolbar *parent) +{ + CSVWorld::SceneToolMode *tool = new CSVWorld::SceneToolMode (parent); + + tool->addButton (":door.png", "1st"); /// \todo replace icons + tool->addButton (":GMST.png", "free"); + tool->addButton (":Info.png", "orbit"); + + connect (tool, SIGNAL (modeChanged (const std::string&)), + this, SLOT (selectNavigationMode (const std::string&))); + + return tool; +} \ No newline at end of file diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index 1c122c935..9d9452c17 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -3,15 +3,39 @@ #include "scenewidget.hpp" +#include "navigation1st.hpp" +#include "navigationfree.hpp" +#include "navigationorbit.hpp" + +namespace CSVWorld +{ + class SceneToolMode; + class SceneToolbar; +} + namespace CSVRender { class WorldspaceWidget : public SceneWidget { Q_OBJECT + CSVRender::Navigation1st m1st; + CSVRender::NavigationFree mFree; + CSVRender::NavigationOrbit mOrbit; + public: WorldspaceWidget (QWidget *parent = 0); + + CSVWorld::SceneToolMode *makeNavigationSelector (CSVWorld::SceneToolbar *parent); + ///< \important The created tool is not added to the toolbar (via addTool). Doing that + /// is the responsibility of the calling function. + + void selectDefaultNavigationMode(); + + private slots: + + void selectNavigationMode (const std::string& mode); }; } diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 516a5db80..88b84ace5 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -33,19 +33,13 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D SceneToolbar *toolbar = new SceneToolbar (48, this); - // navigation mode - SceneToolMode *tool = new SceneToolMode (toolbar); - tool->addButton (":door.png", "1st"); /// \todo replace icons - tool->addButton (":GMST.png", "free"); - tool->addButton (":Info.png", "orbit"); + mScene = new CSVRender::WorldspaceWidget (this); + + SceneToolMode *tool = mScene->makeNavigationSelector (toolbar); toolbar->addTool (tool); - connect (tool, SIGNAL (modeChanged (const std::string&)), - this, SLOT (selectNavigationMode (const std::string&))); layout2->addWidget (toolbar, 0); - mScene = new CSVRender::WorldspaceWidget (this); - layout2->addWidget (mScene, 1); layout->insertLayout (0, layout2, 1); @@ -60,7 +54,7 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D setWidget (widget); - mScene->setNavigation (&m1st); + mScene->selectDefaultNavigationMode(); } void CSVWorld::SceneSubView::setEditLock (bool locked) @@ -79,13 +73,3 @@ void CSVWorld::SceneSubView::setStatusBar (bool show) { mBottom->setStatusBar (show); } - -void CSVWorld::SceneSubView::selectNavigationMode (const std::string& mode) -{ - if (mode=="1st") - mScene->setNavigation (&m1st); - else if (mode=="free") - mScene->setNavigation (&mFree); - else if (mode=="orbit") - mScene->setNavigation (&mOrbit); -} diff --git a/apps/opencs/view/world/scenesubview.hpp b/apps/opencs/view/world/scenesubview.hpp index f944e17c3..21b3dc204 100644 --- a/apps/opencs/view/world/scenesubview.hpp +++ b/apps/opencs/view/world/scenesubview.hpp @@ -3,10 +3,6 @@ #include "../doc/subview.hpp" -#include "../render/navigation1st.hpp" -#include "../render/navigationfree.hpp" -#include "../render/navigationorbit.hpp" - class QModelIndex; namespace CSMDoc @@ -16,7 +12,7 @@ namespace CSMDoc namespace CSVRender { - class SceneWidget; + class WorldspaceWidget; } namespace CSVWorld @@ -30,10 +26,7 @@ namespace CSVWorld Q_OBJECT TableBottomBox *mBottom; - CSVRender::SceneWidget *mScene; - CSVRender::Navigation1st m1st; - CSVRender::NavigationFree mFree; - CSVRender::NavigationOrbit mOrbit; + CSVRender::WorldspaceWidget *mScene; public: @@ -44,10 +37,6 @@ namespace CSVWorld virtual void updateEditorSetting (const QString& key, const QString& value); virtual void setStatusBar (bool show); - - private slots: - - void selectNavigationMode (const std::string& mode); }; }