forked from mirror/openmw-tes3mp
delegated editing and selection functions to mode objects
This commit is contained in:
parent
9bf27c7e37
commit
981a8a2cc2
6 changed files with 88 additions and 13 deletions
|
@ -85,7 +85,7 @@ opencs_units (view/widget
|
||||||
|
|
||||||
opencs_units (view/render
|
opencs_units (view/render
|
||||||
scenewidget worldspacewidget pagedworldspacewidget unpagedworldspacewidget
|
scenewidget worldspacewidget pagedworldspacewidget unpagedworldspacewidget
|
||||||
previewwidget editmode
|
previewwidget editmode instancemode
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (view/render
|
opencs_units_noqt (view/render
|
||||||
|
|
|
@ -26,3 +26,9 @@ void CSVRender::EditMode::setEditLock (bool locked)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::EditMode::primaryEditPressed (osg::ref_ptr<TagBase> tag) {}
|
||||||
|
|
||||||
|
void CSVRender::EditMode::secondaryEditPressed (osg::ref_ptr<TagBase> tag) {}
|
||||||
|
|
||||||
|
void CSVRender::EditMode::selectPressed (osg::ref_ptr<TagBase> tag) {}
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
#ifndef CSV_RENDER_EDITMODE_H
|
#ifndef CSV_RENDER_EDITMODE_H
|
||||||
#define CSV_RENDER_EDITMODE_H
|
#define CSV_RENDER_EDITMODE_H
|
||||||
|
|
||||||
|
#include <osg/ref_ptr>
|
||||||
|
|
||||||
#include "../widget/modebutton.hpp"
|
#include "../widget/modebutton.hpp"
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
class WorldspaceWidget;
|
class WorldspaceWidget;
|
||||||
|
class TagBase;
|
||||||
|
|
||||||
class EditMode : public CSVWidget::ModeButton
|
class EditMode : public CSVWidget::ModeButton
|
||||||
{
|
{
|
||||||
|
@ -28,6 +31,15 @@ namespace CSVRender
|
||||||
|
|
||||||
/// Default-implementation: Ignored.
|
/// Default-implementation: Ignored.
|
||||||
virtual void setEditLock (bool locked);
|
virtual void setEditLock (bool locked);
|
||||||
|
|
||||||
|
/// Default-implementation: Ignored.
|
||||||
|
virtual void primaryEditPressed (osg::ref_ptr<TagBase> tag);
|
||||||
|
|
||||||
|
/// Default-implementation: Ignored.
|
||||||
|
virtual void secondaryEditPressed (osg::ref_ptr<TagBase> tag);
|
||||||
|
|
||||||
|
/// Default-implementation: Ignored.
|
||||||
|
virtual void selectPressed (osg::ref_ptr<TagBase> tag);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
35
apps/opencs/view/render/instancemode.cpp
Normal file
35
apps/opencs/view/render/instancemode.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
#include "instancemode.hpp"
|
||||||
|
|
||||||
|
#include "elements.hpp"
|
||||||
|
#include "object.hpp"
|
||||||
|
|
||||||
|
CSVRender::InstanceMode::InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent)
|
||||||
|
: EditMode (worldspaceWidget, QIcon (":placeholder"), Element_Reference, "Instance editing",
|
||||||
|
parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::InstanceMode::primaryEditPressed (osg::ref_ptr<TagBase> tag)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::InstanceMode::secondaryEditPressed (osg::ref_ptr<TagBase> tag)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVRender::InstanceMode::selectPressed (osg::ref_ptr<TagBase> tag)
|
||||||
|
{
|
||||||
|
if (tag)
|
||||||
|
{
|
||||||
|
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (tag.get()))
|
||||||
|
{
|
||||||
|
// hit an Object, toggle its selection state
|
||||||
|
CSVRender::Object* object = objectTag->mObject;
|
||||||
|
object->setSelected (!object->getSelected());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
apps/opencs/view/render/instancemode.hpp
Normal file
24
apps/opencs/view/render/instancemode.hpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef CSV_RENDER_INSTANCEMODE_H
|
||||||
|
#define CSV_RENDER_INSTANCEMODE_H
|
||||||
|
|
||||||
|
#include "editmode.hpp"
|
||||||
|
|
||||||
|
namespace CSVRender
|
||||||
|
{
|
||||||
|
class InstanceMode : public EditMode
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent = 0);
|
||||||
|
|
||||||
|
virtual void primaryEditPressed (osg::ref_ptr<TagBase> tag);
|
||||||
|
|
||||||
|
virtual void secondaryEditPressed (osg::ref_ptr<TagBase> tag);
|
||||||
|
|
||||||
|
virtual void selectPressed (osg::ref_ptr<TagBase> tag);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -28,6 +28,7 @@
|
||||||
#include "object.hpp"
|
#include "object.hpp"
|
||||||
#include "elements.hpp"
|
#include "elements.hpp"
|
||||||
#include "editmode.hpp"
|
#include "editmode.hpp"
|
||||||
|
#include "instancemode.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -302,9 +303,7 @@ void CSVRender::WorldspaceWidget::addVisibilitySelectorButtons (
|
||||||
void CSVRender::WorldspaceWidget::addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool)
|
void CSVRender::WorldspaceWidget::addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool)
|
||||||
{
|
{
|
||||||
/// \todo replace EditMode with suitable subclasses
|
/// \todo replace EditMode with suitable subclasses
|
||||||
tool->addButton (
|
tool->addButton (new InstanceMode (this, tool), "object");
|
||||||
new EditMode (this, QIcon (":placeholder"), Element_Reference, "Instance editing"),
|
|
||||||
"object");
|
|
||||||
tool->addButton (
|
tool->addButton (
|
||||||
new EditMode (this, QIcon (":placeholder"), Element_Pathgrid, "Pathgrid editing"),
|
new EditMode (this, QIcon (":placeholder"), Element_Pathgrid, "Pathgrid editing"),
|
||||||
"pathgrid");
|
"pathgrid");
|
||||||
|
@ -515,15 +514,14 @@ void CSVRender::WorldspaceWidget::mousePressEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<TagBase> tag = mousePick (event);
|
osg::ref_ptr<TagBase> tag = mousePick (event);
|
||||||
|
|
||||||
if (tag)
|
EditMode& editMode = dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent());
|
||||||
{
|
|
||||||
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (tag.get()))
|
if (button=="p-edit")
|
||||||
{
|
editMode.primaryEditPressed (tag);
|
||||||
// hit an Object, toggle its selection state
|
else if (button=="s-edit")
|
||||||
CSVRender::Object* object = objectTag->mObject;
|
editMode.secondaryEditPressed (tag);
|
||||||
object->setSelected (!object->getSelected());
|
else if (button=="select")
|
||||||
}
|
editMode.selectPressed (tag);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue