mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
keep sub mode over mode changes
This commit is contained in:
parent
a63453846b
commit
b5005f7812
@ -27,8 +27,8 @@ int CSVRender::InstanceMode::getSubModeFromId (const std::string& id) const
|
||||
|
||||
CSVRender::InstanceMode::InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent)
|
||||
: EditMode (worldspaceWidget, QIcon (":placeholder"), Mask_Reference, "Instance editing",
|
||||
parent), mSubMode (0), mSelectionMode (0), mDragMode (DragMode_None), mDragAxis (-1),
|
||||
mLocked (false)
|
||||
parent), mSubMode (0), mSubModeId ("move"), mSelectionMode (0), mDragMode (DragMode_None),
|
||||
mDragAxis (-1), mLocked (false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -51,6 +51,8 @@ void CSVRender::InstanceMode::activate (CSVWidget::SceneToolbar *toolbar)
|
||||
"</ul>"
|
||||
"<font color=Red>Not implemented yet</font color>");
|
||||
|
||||
mSubMode->setButton (mSubModeId);
|
||||
|
||||
connect (mSubMode, SIGNAL (modeChanged (const std::string&)),
|
||||
this, SLOT (subModeChanged (const std::string&)));
|
||||
}
|
||||
@ -454,6 +456,7 @@ int CSVRender::InstanceMode::getSubMode() const
|
||||
|
||||
void CSVRender::InstanceMode::subModeChanged (const std::string& id)
|
||||
{
|
||||
mSubModeId = id;
|
||||
getWorldspaceWidget().abortDrag();
|
||||
getWorldspaceWidget().setSubMode (getSubModeFromId (id), Mask_Reference);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ namespace CSVRender
|
||||
};
|
||||
|
||||
CSVWidget::SceneToolMode *mSubMode;
|
||||
std::string mSubModeId;
|
||||
InstanceSelectionMode *mSelectionMode;
|
||||
DragMode mDragMode;
|
||||
int mDragAxis;
|
||||
|
@ -38,6 +38,27 @@ void CSVWidget::SceneToolMode::adjustToolTip (const ModeButton *activeMode)
|
||||
setToolTip (toolTip);
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolMode::setButton (std::map<ModeButton *, std::string>::iterator iter)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
CSVWidget::SceneToolMode::SceneToolMode (SceneToolbar *parent, const QString& toolTip)
|
||||
: SceneTool (parent), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()),
|
||||
mToolTip (toolTip), mFirst (0), mCurrent (0), mToolbar (parent)
|
||||
@ -101,9 +122,20 @@ std::string CSVWidget::SceneToolMode::getCurrentId() const
|
||||
return mButtons.find (mCurrent)->second;
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolMode::setButton (const std::string& id)
|
||||
{
|
||||
for (std::map<ModeButton *, std::string>::iterator iter = mButtons.begin();
|
||||
iter!=mButtons.end(); ++iter)
|
||||
if (iter->second==id)
|
||||
{
|
||||
setButton (iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWidget::SceneToolMode::selected()
|
||||
{
|
||||
std::map<ModeButton *, std::string>::const_iterator iter =
|
||||
std::map<ModeButton *, std::string>::iterator iter =
|
||||
mButtons.find (dynamic_cast<ModeButton *> (sender()));
|
||||
|
||||
if (iter!=mButtons.end())
|
||||
@ -111,22 +143,6 @@ void CSVWidget::SceneToolMode::selected()
|
||||
if (!iter->first->hasKeepOpen())
|
||||
mPanel->hide();
|
||||
|
||||
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);
|
||||
setButton (iter);
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ namespace CSVWidget
|
||||
/// items to be added, the function must return true anyway.
|
||||
virtual bool createContextMenu (QMenu *menu);
|
||||
|
||||
void setButton (std::map<ModeButton *, std::string>::iterator iter);
|
||||
|
||||
public:
|
||||
|
||||
SceneToolMode (SceneToolbar *parent, const QString& toolTip);
|
||||
@ -59,6 +61,9 @@ namespace CSVWidget
|
||||
/// Must not be called if there aren't any buttons yet.
|
||||
std::string getCurrentId() const;
|
||||
|
||||
/// Manually change the current mode
|
||||
void setButton (const std::string& id);
|
||||
|
||||
signals:
|
||||
|
||||
void modeChanged (const std::string& id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user