added edit mode button to scene toolbar

loadfix
Marc Zinnschlag 10 years ago
parent b50fcd403b
commit 2acf446f18

@ -77,7 +77,7 @@ opencs_units (view/widget
opencs_units (view/render
scenewidget worldspacewidget pagedworldspacewidget unpagedworldspacewidget
previewwidget
previewwidget editmode
)
opencs_units_noqt (view/render

@ -0,0 +1,19 @@
#include "editmode.hpp"
#include "worldspacewidget.hpp"
CSVRender::EditMode::EditMode (WorldspaceWidget *worldspaceWidget, const QIcon& icon,
unsigned int mask, const QString& tooltip, QWidget *parent)
: ModeButton (icon, tooltip, parent), mWorldspaceWidget (worldspaceWidget), mMask (mask)
{}
unsigned int CSVRender::EditMode::getInteractionMask() const
{
return mMask;
}
void CSVRender::EditMode::activate (CSVWidget::SceneToolbar *toolbar)
{
mWorldspaceWidget->setInteractionMask (mMask);
}

@ -0,0 +1,28 @@
#ifndef CSV_RENDER_EDITMODE_H
#define CSV_RENDER_EDITMODE_H
#include "../widget/modebutton.hpp"
namespace CSVRender
{
class WorldspaceWidget;
class EditMode : public CSVWidget::ModeButton
{
Q_OBJECT
WorldspaceWidget *mWorldspaceWidget;
unsigned int mMask;
public:
EditMode (WorldspaceWidget *worldspaceWidget, const QIcon& icon, unsigned int mask,
const QString& tooltip = "", QWidget *parent = 0);
unsigned int getInteractionMask() const;
virtual void activate (CSVWidget::SceneToolbar *toolbar);
};
}
#endif

@ -16,10 +16,11 @@
#include "../widget/scenetooltoggle.hpp"
#include "../widget/scenetoolrun.hpp"
#include "editmode.hpp"
#include "elements.hpp"
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
: SceneWidget (parent), mDocument(document), mSceneElements(0), mRun(0)
: SceneWidget (parent), mDocument(document), mSceneElements(0), mRun(0), mInteractionMask (0)
{
setAcceptDrops(true);
@ -162,6 +163,16 @@ CSVWidget::SceneToolRun *CSVRender::WorldspaceWidget::makeRunTool (
return mRun;
}
CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeEditModeSelector (
CSVWidget::SceneToolbar *parent)
{
CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent, "Edit Mode");
addEditModeSelectorButtons (tool);
return tool;
}
CSVRender::WorldspaceWidget::DropType CSVRender::WorldspaceWidget::getDropType (
const std::vector< CSMWorld::UniversalId >& data)
{
@ -221,6 +232,16 @@ unsigned int CSVRender::WorldspaceWidget::getVisibilityMask() const
return mSceneElements->getSelection();
}
void CSVRender::WorldspaceWidget::setInteractionMask (unsigned int mask)
{
mInteractionMask = mask | Element_CellMarker | Element_CellArrow;
}
unsigned int CSVRender::WorldspaceWidget::getInteractionMask() const
{
return mInteractionMask & getVisibilityMask();
}
void CSVRender::WorldspaceWidget::addVisibilitySelectorButtons (
CSVWidget::SceneToolToggle *tool)
{
@ -230,6 +251,17 @@ void CSVRender::WorldspaceWidget::addVisibilitySelectorButtons (
tool->addButton (":armor.png", Element_Pathgrid, ":armor.png", "Pathgrid");
}
void CSVRender::WorldspaceWidget::addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool)
{
/// \todo replace EditMode with suitable subclasses
tool->addButton (
new EditMode (this, QIcon (":armor.png"), Element_Reference, "Reference editing"),
"object");
tool->addButton (
new EditMode (this, QIcon (":armor.png"), Element_Pathgrid, "Pathgrid editing"),
"pathgrid");
}
CSMDoc::Document& CSVRender::WorldspaceWidget::getDocument()
{
return mDocument;

@ -33,6 +33,7 @@ namespace CSVRender
CSVWidget::SceneToolToggle *mSceneElements;
CSVWidget::SceneToolRun *mRun;
CSMDoc::Document& mDocument;
unsigned int mInteractionMask;
public:
@ -67,6 +68,10 @@ namespace CSVRender
/// that is the responsibility of the calling function.
CSVWidget::SceneToolRun *makeRunTool (CSVWidget::SceneToolbar *parent);
/// \attention The created tool is not added to the toolbar (via addTool). Doing
/// that is the responsibility of the calling function.
CSVWidget::SceneToolMode *makeEditModeSelector (CSVWidget::SceneToolbar *parent);
void selectDefaultNavigationMode();
static DropType getDropType(const std::vector<CSMWorld::UniversalId>& data);
@ -82,10 +87,20 @@ namespace CSVRender
virtual unsigned int getVisibilityMask() const;
/// \note This function will implicitly add elements that are independent of the
/// selected edit mode.
virtual void setInteractionMask (unsigned int mask);
/// \note This function will only return those elements that are both visible and
/// marked for interaction.
unsigned int getInteractionMask() const;
protected:
virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle *tool);
virtual void addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool);
CSMDoc::Document& getDocument();
virtual void updateOverlay();

@ -125,6 +125,9 @@ CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::Worldsp
CSVWidget::SceneToolRun *runTool = widget->makeRunTool (toolbar);
toolbar->addTool (runTool);
CSVWidget::SceneToolMode *editModeTool = widget->makeEditModeSelector (toolbar);
toolbar->addTool (editModeTool);
return toolbar;
}

Loading…
Cancel
Save