mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:23:53 +00:00
Merge branch 'mode'
Conflicts: apps/opencs/view/render/pagedworldspacewidget.cpp apps/opencs/view/render/worldspacewidget.cpp apps/opencs/view/render/worldspacewidget.hpp
This commit is contained in:
commit
a60e4c036f
14 changed files with 221 additions and 24 deletions
|
@ -72,12 +72,12 @@ opencs_units_noqt (view/world
|
|||
)
|
||||
|
||||
opencs_units (view/widget
|
||||
scenetoolbar scenetool scenetoolmode pushbutton scenetooltoggle scenetoolrun
|
||||
scenetoolbar scenetool scenetoolmode pushbutton scenetooltoggle scenetoolrun modebutton
|
||||
)
|
||||
|
||||
opencs_units (view/render
|
||||
scenewidget worldspacewidget pagedworldspacewidget unpagedworldspacewidget
|
||||
previewwidget
|
||||
previewwidget editmode
|
||||
)
|
||||
|
||||
opencs_units_noqt (view/render
|
||||
|
|
19
apps/opencs/view/render/editmode.cpp
Normal file
19
apps/opencs/view/render/editmode.cpp
Normal file
|
@ -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);
|
||||
}
|
28
apps/opencs/view/render/editmode.hpp
Normal file
28
apps/opencs/view/render/editmode.hpp
Normal file
|
@ -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
|
|
@ -21,7 +21,9 @@
|
|||
#include "../../model/world/idtable.hpp"
|
||||
|
||||
#include "../widget/scenetooltoggle.hpp"
|
||||
#include "../widget/scenetoolmode.hpp"
|
||||
|
||||
#include "editmode.hpp"
|
||||
#include "elements.hpp"
|
||||
|
||||
bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
||||
|
@ -210,6 +212,26 @@ void CSVRender::PagedWorldspaceWidget::mouseDoubleClickEvent (QMouseEvent *event
|
|||
WorldspaceWidget::mouseDoubleClickEvent(event);
|
||||
}
|
||||
|
||||
void CSVRender::PagedWorldspaceWidget::addEditModeSelectorButtons (
|
||||
CSVWidget::SceneToolMode *tool)
|
||||
{
|
||||
WorldspaceWidget::addEditModeSelectorButtons (tool);
|
||||
|
||||
/// \todo replace EditMode with suitable subclasses
|
||||
tool->addButton (
|
||||
new EditMode (this, QIcon (":armor.png"), Element_Reference, "Terrain shape editing"),
|
||||
"terrain-shape");
|
||||
tool->addButton (
|
||||
new EditMode (this, QIcon (":armor.png"), Element_Reference, "Terrain texture editing"),
|
||||
"terrain-texture");
|
||||
tool->addButton (
|
||||
new EditMode (this, QIcon (":armor.png"), Element_Reference, "Terrain vertex paint editing"),
|
||||
"terrain-vertex");
|
||||
tool->addButton (
|
||||
new EditMode (this, QIcon (":armor.png"), Element_Reference, "Terrain movement"),
|
||||
"terrain-move");
|
||||
}
|
||||
|
||||
void CSVRender::PagedWorldspaceWidget::updateOverlay()
|
||||
{
|
||||
if(getCamera()->getViewport())
|
||||
|
@ -445,9 +467,9 @@ CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::g
|
|||
}
|
||||
}
|
||||
|
||||
unsigned int CSVRender::PagedWorldspaceWidget::getElementMask() const
|
||||
unsigned int CSVRender::PagedWorldspaceWidget::getVisibilityMask() const
|
||||
{
|
||||
return WorldspaceWidget::getElementMask() | mControlElements->getSelection();
|
||||
return WorldspaceWidget::getVisibilityMask() | mControlElements->getSelection();
|
||||
}
|
||||
|
||||
CSVWidget::SceneToolToggle *CSVRender::PagedWorldspaceWidget::makeControlVisibilitySelector (
|
||||
|
|
|
@ -75,10 +75,12 @@ namespace CSVRender
|
|||
virtual CSVWidget::SceneToolToggle *makeControlVisibilitySelector (
|
||||
CSVWidget::SceneToolbar *parent);
|
||||
|
||||
virtual unsigned int getElementMask() const;
|
||||
virtual unsigned int getVisibilityMask() const;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool);
|
||||
|
||||
virtual void updateOverlay();
|
||||
|
||||
virtual void mousePressEvent (QMouseEvent *event);
|
||||
|
|
|
@ -20,9 +20,11 @@
|
|||
#include "../world/physicssystem.hpp"
|
||||
|
||||
#include "elements.hpp"
|
||||
#include "editmode.hpp"
|
||||
|
||||
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
|
||||
: SceneWidget (parent), mDocument(document), mSceneElements(0), mRun(0), mPhysics(0), mMouse(0)
|
||||
: SceneWidget (parent), mDocument(document), mSceneElements(0), mRun(0), mPhysics(0), mMouse(0),
|
||||
mInteractionMask (0)
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
|
||||
|
@ -178,6 +180,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)
|
||||
{
|
||||
|
@ -232,11 +244,21 @@ bool CSVRender::WorldspaceWidget::handleDrop (const std::vector<CSMWorld::Univer
|
|||
return false;
|
||||
}
|
||||
|
||||
unsigned int CSVRender::WorldspaceWidget::getElementMask() const
|
||||
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)
|
||||
{
|
||||
|
@ -246,6 +268,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;
|
||||
|
@ -327,7 +360,7 @@ void CSVRender::WorldspaceWidget::debugProfileAboutToBeRemoved (const QModelInde
|
|||
|
||||
void CSVRender::WorldspaceWidget::elementSelectionChanged()
|
||||
{
|
||||
setVisibilityMask (getElementMask());
|
||||
setVisibilityMask (getVisibilityMask());
|
||||
flagAsModified();
|
||||
updateOverlay();
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace CSVRender
|
|||
CSMDoc::Document& mDocument;
|
||||
CSVWorld::PhysicsSystem *mPhysics;
|
||||
MouseState *mMouse;
|
||||
unsigned int mInteractionMask;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -77,6 +78,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);
|
||||
|
@ -90,12 +95,22 @@ namespace CSVRender
|
|||
virtual bool handleDrop (const std::vector<CSMWorld::UniversalId>& data,
|
||||
DropType type);
|
||||
|
||||
virtual unsigned int getElementMask() const;
|
||||
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();
|
||||
|
|
10
apps/opencs/view/widget/modebutton.cpp
Normal file
10
apps/opencs/view/widget/modebutton.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
#include "modebutton.hpp"
|
||||
|
||||
CSVWidget::ModeButton::ModeButton (const QIcon& icon, const QString& tooltip, QWidget *parent)
|
||||
: PushButton (icon, Type_Mode, tooltip, parent)
|
||||
{}
|
||||
|
||||
void CSVWidget::ModeButton::activate (SceneToolbar *toolbar) {}
|
||||
|
||||
void CSVWidget::ModeButton::deactivate (SceneToolbar *toolbar) {}
|
28
apps/opencs/view/widget/modebutton.hpp
Normal file
28
apps/opencs/view/widget/modebutton.hpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef CSV_WIDGET_MODEBUTTON_H
|
||||
#define CSV_WIDGET_MODEBUTTON_H
|
||||
|
||||
#include "pushbutton.hpp"
|
||||
|
||||
namespace CSVWidget
|
||||
{
|
||||
class SceneToolbar;
|
||||
|
||||
/// \brief Specialist PushButton of Type_Mode for use in SceneToolMode
|
||||
class ModeButton : public PushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
ModeButton (const QIcon& icon, const QString& tooltip = "",
|
||||
QWidget *parent = 0);
|
||||
|
||||
/// Default-Implementation: do nothing
|
||||
virtual void activate (SceneToolbar *toolbar);
|
||||
|
||||
/// Default-Implementation: do nothing
|
||||
virtual void deactivate (SceneToolbar *toolbar);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -31,9 +31,20 @@ CSVWidget::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent)
|
|||
connect (focusScene, SIGNAL (activated()), this, SIGNAL (focusSceneRequest()));
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolbar::addTool (SceneTool *tool)
|
||||
void CSVWidget::SceneToolbar::addTool (SceneTool *tool, SceneTool *insertPoint)
|
||||
{
|
||||
mLayout->addWidget (tool, 0, Qt::AlignTop);
|
||||
if (!insertPoint)
|
||||
mLayout->addWidget (tool, 0, Qt::AlignTop);
|
||||
else
|
||||
{
|
||||
int index = mLayout->indexOf (insertPoint);
|
||||
mLayout->insertWidget (index+1, tool, 0, Qt::AlignTop);
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolbar::removeTool (SceneTool *tool)
|
||||
{
|
||||
mLayout->removeWidget (tool);
|
||||
}
|
||||
|
||||
int CSVWidget::SceneToolbar::getButtonSize() const
|
||||
|
|
|
@ -25,7 +25,11 @@ namespace CSVWidget
|
|||
|
||||
SceneToolbar (int buttonSize, QWidget *parent = 0);
|
||||
|
||||
void addTool (SceneTool *tool);
|
||||
/// If insertPoint==0, insert \a tool at the end of the scrollbar. Otherwise
|
||||
/// insert tool after \a insertPoint.
|
||||
void addTool (SceneTool *tool, SceneTool *insertPoint = 0);
|
||||
|
||||
void removeTool (SceneTool *tool);
|
||||
|
||||
int getButtonSize() const;
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#include <QSignalMapper>
|
||||
|
||||
#include "scenetoolbar.hpp"
|
||||
#include "pushbutton.hpp"
|
||||
#include "modebutton.hpp"
|
||||
|
||||
void CSVWidget::SceneToolMode::adjustToolTip (const PushButton *activeMode)
|
||||
void CSVWidget::SceneToolMode::adjustToolTip (const ModeButton *activeMode)
|
||||
{
|
||||
QString toolTip = mToolTip;
|
||||
|
||||
|
@ -21,7 +21,7 @@ void CSVWidget::SceneToolMode::adjustToolTip (const PushButton *activeMode)
|
|||
|
||||
CSVWidget::SceneToolMode::SceneToolMode (SceneToolbar *parent, const QString& toolTip)
|
||||
: SceneTool (parent), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()),
|
||||
mToolTip (toolTip), mFirst (0)
|
||||
mToolTip (toolTip), mFirst (0), mCurrent (0), mToolbar (parent)
|
||||
{
|
||||
mPanel = new QFrame (this, Qt::Popup);
|
||||
|
||||
|
@ -44,8 +44,14 @@ void CSVWidget::SceneToolMode::showPanel (const QPoint& position)
|
|||
void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id,
|
||||
const QString& tooltip)
|
||||
{
|
||||
PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), PushButton::Type_Mode,
|
||||
tooltip, mPanel);
|
||||
ModeButton *button = new ModeButton (QIcon (QPixmap (icon.c_str())), tooltip, mPanel);
|
||||
addButton (button, id);
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolMode::addButton (ModeButton *button, const std::string& id)
|
||||
{
|
||||
button->setParent (mPanel);
|
||||
|
||||
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
button->setIconSize (QSize (mIconSize, mIconSize));
|
||||
button->setFixedSize (mButtonSize, mButtonSize);
|
||||
|
@ -58,29 +64,40 @@ void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::st
|
|||
|
||||
if (mButtons.size()==1)
|
||||
{
|
||||
mFirst = button;
|
||||
mFirst = mCurrent = button;
|
||||
setIcon (button->icon());
|
||||
button->setChecked (true);
|
||||
adjustToolTip (button);
|
||||
mCurrent->activate (mToolbar);
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolMode::selected()
|
||||
{
|
||||
std::map<PushButton *, std::string>::const_iterator iter =
|
||||
mButtons.find (dynamic_cast<PushButton *> (sender()));
|
||||
std::map<ModeButton *, std::string>::const_iterator iter =
|
||||
mButtons.find (dynamic_cast<ModeButton *> (sender()));
|
||||
|
||||
if (iter!=mButtons.end())
|
||||
{
|
||||
if (!iter->first->hasKeepOpen())
|
||||
mPanel->hide();
|
||||
|
||||
for (std::map<PushButton *, std::string>::const_iterator iter2 = mButtons.begin();
|
||||
for (std::map<ModeButton *, std::string>::const_iterator iter2 = mButtons.begin();
|
||||
iter2!=mButtons.end(); ++iter2)
|
||||
iter2->first->setChecked (iter2==iter);
|
||||
|
||||
setIcon (iter->first->icon());
|
||||
adjustToolTip (iter->first);
|
||||
|
||||
if (mCurrent!=iter->first)
|
||||
{
|
||||
if (mCurrent)
|
||||
mCurrent->deactivate (mToolbar);
|
||||
|
||||
mCurrent = iter->first;
|
||||
mCurrent->activate (mToolbar);
|
||||
}
|
||||
|
||||
emit modeChanged (iter->second);
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ class QHBoxLayout;
|
|||
namespace CSVWidget
|
||||
{
|
||||
class SceneToolbar;
|
||||
class PushButton;
|
||||
class ModeButton;
|
||||
|
||||
///< \brief Mode selector tool
|
||||
class SceneToolMode : public SceneTool
|
||||
|
@ -19,13 +19,15 @@ namespace CSVWidget
|
|||
|
||||
QWidget *mPanel;
|
||||
QHBoxLayout *mLayout;
|
||||
std::map<PushButton *, std::string> mButtons; // widget, id
|
||||
std::map<ModeButton *, std::string> mButtons; // widget, id
|
||||
int mButtonSize;
|
||||
int mIconSize;
|
||||
QString mToolTip;
|
||||
PushButton *mFirst;
|
||||
ModeButton *mCurrent;
|
||||
SceneToolbar *mToolbar;
|
||||
|
||||
void adjustToolTip (const PushButton *activeMode);
|
||||
void adjustToolTip (const ModeButton *activeMode);
|
||||
|
||||
public:
|
||||
|
||||
|
@ -36,6 +38,9 @@ namespace CSVWidget
|
|||
void addButton (const std::string& icon, const std::string& id,
|
||||
const QString& tooltip = "");
|
||||
|
||||
/// The ownership of \a button is transferred to *this.
|
||||
void addButton (ModeButton *button, const std::string& id);
|
||||
|
||||
signals:
|
||||
|
||||
void modeChanged (const std::string& id);
|
||||
|
|
|
@ -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…
Reference in a new issue