forked from mirror/openmw-tes3mp
Merge branch 'toolbar'
This commit is contained in:
commit
517b27e29a
19 changed files with 414 additions and 149 deletions
|
@ -59,8 +59,17 @@ opencs_hdrs_noqt (view/doc
|
||||||
|
|
||||||
opencs_units (view/world
|
opencs_units (view/world
|
||||||
table tablesubview scriptsubview util regionmapsubview tablebottombox creator genericcreator
|
table tablesubview scriptsubview util regionmapsubview tablebottombox creator genericcreator
|
||||||
cellcreator referenceablecreator referencecreator scenesubview scenetoolbar scenetool
|
cellcreator referenceablecreator referencecreator scenesubview
|
||||||
scenetoolmode infocreator scriptedit dialoguesubview previewsubview regionmap dragrecordtable
|
infocreator scriptedit dialoguesubview previewsubview regionmap dragrecordtable
|
||||||
|
)
|
||||||
|
|
||||||
|
opencs_units_noqt (view/world
|
||||||
|
subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate
|
||||||
|
scripthighlighter idvalidator dialoguecreator
|
||||||
|
)
|
||||||
|
|
||||||
|
opencs_units (view/widget
|
||||||
|
scenetoolbar scenetool scenetoolmode pushbutton
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units (view/render
|
opencs_units (view/render
|
||||||
|
@ -73,11 +82,6 @@ opencs_units_noqt (view/render
|
||||||
lightingbright object cell
|
lightingbright object cell
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (view/world
|
|
||||||
subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate
|
|
||||||
scripthighlighter idvalidator dialoguecreator
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
opencs_units (view/tools
|
opencs_units (view/tools
|
||||||
reportsubview
|
reportsubview
|
||||||
|
|
|
@ -81,6 +81,7 @@ QWidget *CSVDoc::StartupDialogue::createTools()
|
||||||
|
|
||||||
config->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
config->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||||
config->setIcon (QIcon (":startup/configure"));
|
config->setIcon (QIcon (":startup/configure"));
|
||||||
|
config->setToolTip ("Open user settings");
|
||||||
|
|
||||||
layout->addWidget (config);
|
layout->addWidget (config);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QShortcut>
|
||||||
|
|
||||||
#include <OgreRoot.h>
|
#include <OgreRoot.h>
|
||||||
#include <OgreRenderWindow.h>
|
#include <OgreRenderWindow.h>
|
||||||
|
@ -11,7 +12,7 @@
|
||||||
#include <OgreSceneNode.h>
|
#include <OgreSceneNode.h>
|
||||||
#include <OgreViewport.h>
|
#include <OgreViewport.h>
|
||||||
|
|
||||||
#include "../world/scenetoolmode.hpp"
|
#include "../widget/scenetoolmode.hpp"
|
||||||
|
|
||||||
#include "navigation.hpp"
|
#include "navigation.hpp"
|
||||||
#include "lighting.hpp"
|
#include "lighting.hpp"
|
||||||
|
@ -51,16 +52,34 @@ namespace CSVRender
|
||||||
QTimer *timer = new QTimer (this);
|
QTimer *timer = new QTimer (this);
|
||||||
|
|
||||||
connect (timer, SIGNAL (timeout()), this, SLOT (update()));
|
connect (timer, SIGNAL (timeout()), this, SLOT (update()));
|
||||||
timer->start (20); /// \todo make this configurable
|
timer->start (20); ///< \todo make this configurable
|
||||||
|
|
||||||
|
/// \todo make shortcut configurable
|
||||||
|
QShortcut *focusToolbar = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut);
|
||||||
|
connect (focusToolbar, SIGNAL (activated()), this, SIGNAL (focusToolbarRequest()));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::SceneToolMode *SceneWidget::makeLightingSelector (CSVWorld::SceneToolbar *parent)
|
CSVWidget::SceneToolMode *SceneWidget::makeLightingSelector (CSVWidget::SceneToolbar *parent)
|
||||||
{
|
{
|
||||||
CSVWorld::SceneToolMode *tool = new CSVWorld::SceneToolMode (parent);
|
CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent, "Lighting Mode");
|
||||||
|
|
||||||
tool->addButton (":door.png", "day"); /// \todo replace icons
|
/// \todo replace icons
|
||||||
tool->addButton (":GMST.png", "night");
|
tool->addButton (":door.png", "day",
|
||||||
tool->addButton (":Info.png", "bright");
|
"Day"
|
||||||
|
"<ul><li>Cell specific ambient in interiors</li>"
|
||||||
|
"<li>Low ambient in exteriors</li>"
|
||||||
|
"<li>Strong directional light source/lir>"
|
||||||
|
"<li>This mode closely resembles day time in-game</li></ul>");
|
||||||
|
tool->addButton (":GMST.png", "night",
|
||||||
|
"Night"
|
||||||
|
"<ul><li>Cell specific ambient in interiors</li>"
|
||||||
|
"<li>Low ambient in exteriors</li>"
|
||||||
|
"<li>Weak directional light source</li>"
|
||||||
|
"<li>This mode closely resembles night time in-game</li></ul>");
|
||||||
|
tool->addButton (":Info.png", "bright",
|
||||||
|
"Bright"
|
||||||
|
"<ul><li>Maximum ambient</li>"
|
||||||
|
"<li>Strong directional light source</li></ul>");
|
||||||
|
|
||||||
connect (tool, SIGNAL (modeChanged (const std::string&)),
|
connect (tool, SIGNAL (modeChanged (const std::string&)),
|
||||||
this, SLOT (selectLightingMode (const std::string&)));
|
this, SLOT (selectLightingMode (const std::string&)));
|
||||||
|
@ -347,6 +366,9 @@ namespace CSVRender
|
||||||
|
|
||||||
mLighting = lighting;
|
mLighting = lighting;
|
||||||
mLighting->activate (mSceneMgr, mHasDefaultAmbient ? &mDefaultAmbient : 0);
|
mLighting->activate (mSceneMgr, mHasDefaultAmbient ? &mDefaultAmbient : 0);
|
||||||
|
|
||||||
|
if (mWindow)
|
||||||
|
mWindow->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneWidget::selectLightingMode (const std::string& mode)
|
void SceneWidget::selectLightingMode (const std::string& mode)
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Ogre
|
||||||
class RenderWindow;
|
class RenderWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWidget
|
||||||
{
|
{
|
||||||
class SceneToolMode;
|
class SceneToolMode;
|
||||||
class SceneToolbar;
|
class SceneToolbar;
|
||||||
|
@ -38,7 +38,7 @@ namespace CSVRender
|
||||||
|
|
||||||
QPaintEngine* paintEngine() const;
|
QPaintEngine* paintEngine() const;
|
||||||
|
|
||||||
CSVWorld::SceneToolMode *makeLightingSelector (CSVWorld::SceneToolbar *parent);
|
CSVWidget::SceneToolMode *makeLightingSelector (CSVWidget::SceneToolbar *parent);
|
||||||
///< \attention The created tool is not added to the toolbar (via addTool). Doing that
|
///< \attention The created tool is not added to the toolbar (via addTool). Doing that
|
||||||
/// is the responsibility of the calling function.
|
/// is the responsibility of the calling function.
|
||||||
|
|
||||||
|
@ -111,6 +111,10 @@ namespace CSVRender
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
void selectLightingMode (const std::string& mode);
|
void selectLightingMode (const std::string& mode);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void focusToolbarRequest();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,9 @@
|
||||||
|
|
||||||
#include <QtGui/qevent.h>
|
#include <QtGui/qevent.h>
|
||||||
|
|
||||||
#include "../world/scenetoolmode.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
#include <apps/opencs/model/world/universalid.hpp>
|
|
||||||
|
#include "../widget/scenetoolmode.hpp"
|
||||||
|
|
||||||
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
|
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
|
||||||
: SceneWidget (parent), mDocument(document)
|
: SceneWidget (parent), mDocument(document)
|
||||||
|
@ -53,14 +54,39 @@ void CSVRender::WorldspaceWidget::selectDefaultNavigationMode()
|
||||||
setNavigation (&m1st);
|
setNavigation (&m1st);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
|
CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
|
||||||
CSVWorld::SceneToolbar *parent)
|
CSVWidget::SceneToolbar *parent)
|
||||||
{
|
{
|
||||||
CSVWorld::SceneToolMode *tool = new CSVWorld::SceneToolMode (parent);
|
CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent, "Camera Mode");
|
||||||
|
|
||||||
tool->addButton (":door.png", "1st"); /// \todo replace icons
|
/// \todo replace icons
|
||||||
tool->addButton (":GMST.png", "free");
|
/// \todo consider user-defined button-mapping
|
||||||
tool->addButton (":Info.png", "orbit");
|
tool->addButton (":door.png", "1st",
|
||||||
|
"First Person"
|
||||||
|
"<ul><li>Mouse-Look while holding the left button</li>"
|
||||||
|
"<li>WASD movement keys</li>"
|
||||||
|
"<li>Mouse wheel moves the camera forawrd/backward</li>"
|
||||||
|
"<li>Stafing (also vertically) by holding the left mouse button and control</li>"
|
||||||
|
"<li>Camera is held upright</li>"
|
||||||
|
"<li>Hold shift to speed up movement</li>"
|
||||||
|
"</ul>");
|
||||||
|
tool->addButton (":GMST.png", "free",
|
||||||
|
"Free Camera"
|
||||||
|
"<ul><li>Mouse-Look while holding the left button</li>"
|
||||||
|
"<li>Stafing (also vertically) via WASD or by holding the left mouse button and control</li>"
|
||||||
|
"<li>Mouse wheel moves the camera forawrd/backward</li>"
|
||||||
|
"<li>Roll camera with Q and E keys</li>"
|
||||||
|
"<li>Hold shift to speed up movement</li>"
|
||||||
|
"</ul>");
|
||||||
|
tool->addButton (":Info.png", "orbit",
|
||||||
|
"Orbiting Camera"
|
||||||
|
"<ul><li>Always facing the centre point</li>"
|
||||||
|
"<li>Rotate around the centre point via WASD or by moving the mouse while holding the left button</li>"
|
||||||
|
"<li>Mouse wheel moves camera away or towards centre point but can not pass through it</li>"
|
||||||
|
"<li>Roll camera with Q and E keys</li>"
|
||||||
|
"<li>Stafing (also vertically) by holding the left mouse button and control (includes relocation of the centre point)</li>"
|
||||||
|
"<li>Hold shift to speed up movement</li>"
|
||||||
|
"</ul>");
|
||||||
|
|
||||||
connect (tool, SIGNAL (modeChanged (const std::string&)),
|
connect (tool, SIGNAL (modeChanged (const std::string&)),
|
||||||
this, SLOT (selectNavigationMode (const std::string&)));
|
this, SLOT (selectNavigationMode (const std::string&)));
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace CSMWorld
|
||||||
{
|
{
|
||||||
class UniversalId;
|
class UniversalId;
|
||||||
}
|
}
|
||||||
namespace CSVWorld
|
namespace CSVWidget
|
||||||
{
|
{
|
||||||
class SceneToolMode;
|
class SceneToolMode;
|
||||||
class SceneToolbar;
|
class SceneToolbar;
|
||||||
|
@ -49,7 +49,7 @@ namespace CSVRender
|
||||||
|
|
||||||
WorldspaceWidget (CSMDoc::Document& document, QWidget *parent = 0);
|
WorldspaceWidget (CSMDoc::Document& document, QWidget *parent = 0);
|
||||||
|
|
||||||
CSVWorld::SceneToolMode *makeNavigationSelector (CSVWorld::SceneToolbar *parent);
|
CSVWidget::SceneToolMode *makeNavigationSelector (CSVWidget::SceneToolbar *parent);
|
||||||
///< \attention The created tool is not added to the toolbar (via addTool). Doing that
|
///< \attention The created tool is not added to the toolbar (via addTool). Doing that
|
||||||
/// is the responsibility of the calling function.
|
/// is the responsibility of the calling function.
|
||||||
|
|
||||||
|
|
83
apps/opencs/view/widget/pushbutton.cpp
Normal file
83
apps/opencs/view/widget/pushbutton.cpp
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
|
||||||
|
#include "pushbutton.hpp"
|
||||||
|
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
|
void CSVWidget::PushButton::setExtendedToolTip (const QString& text)
|
||||||
|
{
|
||||||
|
QString tooltip = text;
|
||||||
|
|
||||||
|
if (tooltip.isEmpty())
|
||||||
|
tooltip = "(Tool tip not implemented yet)";
|
||||||
|
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case Type_TopMode:
|
||||||
|
|
||||||
|
tooltip +=
|
||||||
|
"<p>(left click to change mode)";
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Type_Mode:
|
||||||
|
|
||||||
|
tooltip +=
|
||||||
|
"<p>(left click to activate,"
|
||||||
|
"<br>shift-left click to activate and keep panel open)";
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setToolTip (tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::PushButton::keyPressEvent (QKeyEvent *event)
|
||||||
|
{
|
||||||
|
if (event->key()!=Qt::Key_Shift)
|
||||||
|
mKeepOpen = false;
|
||||||
|
|
||||||
|
QPushButton::keyPressEvent (event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::PushButton::keyReleaseEvent (QKeyEvent *event)
|
||||||
|
{
|
||||||
|
if (event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter)
|
||||||
|
{
|
||||||
|
mKeepOpen = event->modifiers() & Qt::ShiftModifier;
|
||||||
|
emit clicked();
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton::keyReleaseEvent (event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event)
|
||||||
|
{
|
||||||
|
mKeepOpen = event->button()==Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier);
|
||||||
|
QPushButton::mouseReleaseEvent (event);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWidget::PushButton::PushButton (const QIcon& icon, Type type, const QString& tooltip,
|
||||||
|
QWidget *parent)
|
||||||
|
: QPushButton (icon, "", parent), mKeepOpen (false), mType (type), mToolTip (tooltip)
|
||||||
|
{
|
||||||
|
setCheckable (type==Type_Mode);
|
||||||
|
setExtendedToolTip (tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWidget::PushButton::PushButton (Type type, const QString& tooltip, QWidget *parent)
|
||||||
|
: QPushButton (parent), mKeepOpen (false), mType (type), mToolTip (tooltip)
|
||||||
|
{
|
||||||
|
setCheckable (type==Type_Mode);
|
||||||
|
setExtendedToolTip (tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSVWidget::PushButton::hasKeepOpen() const
|
||||||
|
{
|
||||||
|
return mKeepOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSVWidget::PushButton::getBaseToolTip() const
|
||||||
|
{
|
||||||
|
return mToolTip;
|
||||||
|
}
|
55
apps/opencs/view/widget/pushbutton.hpp
Normal file
55
apps/opencs/view/widget/pushbutton.hpp
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#ifndef CSV_WIDGET_PUSHBUTTON_H
|
||||||
|
#define CSV_WIDGET_PUSHBUTTON_H
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
namespace CSVWidget
|
||||||
|
{
|
||||||
|
class PushButton : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum Type
|
||||||
|
{
|
||||||
|
Type_TopMode, // top level button for mode selector panel
|
||||||
|
Type_Mode // mode button
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool mKeepOpen;
|
||||||
|
Type mType;
|
||||||
|
QString mToolTip;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void setExtendedToolTip (const QString& text);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void keyPressEvent (QKeyEvent *event);
|
||||||
|
|
||||||
|
virtual void keyReleaseEvent (QKeyEvent *event);
|
||||||
|
|
||||||
|
virtual void mouseReleaseEvent (QMouseEvent *event);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/// \param push Do not maintain a toggle state
|
||||||
|
PushButton (const QIcon& icon, Type type, const QString& tooltip = "",
|
||||||
|
QWidget *parent = 0);
|
||||||
|
|
||||||
|
/// \param push Do not maintain a toggle state
|
||||||
|
PushButton (Type type, const QString& tooltip = "",
|
||||||
|
QWidget *parent = 0);
|
||||||
|
|
||||||
|
bool hasKeepOpen() const;
|
||||||
|
|
||||||
|
/// Return tooltip used at construction (without any button-specific modifications)
|
||||||
|
QString getBaseToolTip() const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
#include "scenetoolbar.hpp"
|
#include "scenetoolbar.hpp"
|
||||||
|
|
||||||
CSVWorld::SceneTool::SceneTool (SceneToolbar *parent) : QPushButton (parent)
|
CSVWidget::SceneTool::SceneTool (SceneToolbar *parent)
|
||||||
|
: PushButton (PushButton::Type_TopMode, "", parent)
|
||||||
{
|
{
|
||||||
setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||||
setIconSize (QSize (parent->getIconSize(), parent->getIconSize()));
|
setIconSize (QSize (parent->getIconSize(), parent->getIconSize()));
|
||||||
|
@ -12,7 +13,7 @@ CSVWorld::SceneTool::SceneTool (SceneToolbar *parent) : QPushButton (parent)
|
||||||
connect (this, SIGNAL (clicked()), this, SLOT (openRequest()));
|
connect (this, SIGNAL (clicked()), this, SLOT (openRequest()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::SceneTool::openRequest()
|
void CSVWidget::SceneTool::openRequest()
|
||||||
{
|
{
|
||||||
showPanel (parentWidget()->mapToGlobal (pos()));
|
showPanel (parentWidget()->mapToGlobal (pos()));
|
||||||
}
|
}
|
|
@ -1,14 +1,14 @@
|
||||||
#ifndef CSV_WORLD_SCENETOOL_H
|
#ifndef CSV_WIDGET_SCENETOOL_H
|
||||||
#define CSV_WORLD_SCENETOOL_H
|
#define CSV_WIDGET_SCENETOOL_H
|
||||||
|
|
||||||
#include <QPushButton>
|
#include "pushbutton.hpp"
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWidget
|
||||||
{
|
{
|
||||||
class SceneToolbar;
|
class SceneToolbar;
|
||||||
|
|
||||||
///< \brief Tool base class
|
///< \brief Tool base class
|
||||||
class SceneTool : public QPushButton
|
class SceneTool : public PushButton
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
47
apps/opencs/view/widget/scenetoolbar.cpp
Normal file
47
apps/opencs/view/widget/scenetoolbar.cpp
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
|
||||||
|
#include "scenetoolbar.hpp"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QShortcut>
|
||||||
|
|
||||||
|
#include "scenetool.hpp"
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolbar::focusInEvent (QFocusEvent *event)
|
||||||
|
{
|
||||||
|
QWidget::focusInEvent (event);
|
||||||
|
|
||||||
|
if (mLayout->count())
|
||||||
|
dynamic_cast<QWidgetItem&> (*mLayout->itemAt (0)).widget()->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWidget::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent)
|
||||||
|
: QWidget (parent), mButtonSize (buttonSize), mIconSize (buttonSize-6)
|
||||||
|
{
|
||||||
|
setFixedWidth (mButtonSize);
|
||||||
|
|
||||||
|
mLayout = new QVBoxLayout (this);
|
||||||
|
mLayout->setAlignment (Qt::AlignTop);
|
||||||
|
|
||||||
|
mLayout->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||||
|
|
||||||
|
setLayout (mLayout);
|
||||||
|
|
||||||
|
/// \todo make shortcut configurable
|
||||||
|
QShortcut *focusScene = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut);
|
||||||
|
connect (focusScene, SIGNAL (activated()), this, SIGNAL (focusSceneRequest()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolbar::addTool (SceneTool *tool)
|
||||||
|
{
|
||||||
|
mLayout->addWidget (tool, 0, Qt::AlignTop);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSVWidget::SceneToolbar::getButtonSize() const
|
||||||
|
{
|
||||||
|
return mButtonSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSVWidget::SceneToolbar::getIconSize() const
|
||||||
|
{
|
||||||
|
return mIconSize;
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef CSV_WORLD_SCENETOOLBAR_H
|
#ifndef CSV_WIDGET_SCENETOOLBAR_H
|
||||||
#define CSV_WORLD_SCENETOOLBAR_H
|
#define CSV_WIDGET_SCENETOOLBAR_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWidget
|
||||||
{
|
{
|
||||||
class SceneTool;
|
class SceneTool;
|
||||||
|
|
||||||
|
@ -17,6 +17,10 @@ namespace CSVWorld
|
||||||
int mButtonSize;
|
int mButtonSize;
|
||||||
int mIconSize;
|
int mIconSize;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual void focusInEvent (QFocusEvent *event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SceneToolbar (int buttonSize, QWidget *parent = 0);
|
SceneToolbar (int buttonSize, QWidget *parent = 0);
|
||||||
|
@ -26,6 +30,10 @@ namespace CSVWorld
|
||||||
int getButtonSize() const;
|
int getButtonSize() const;
|
||||||
|
|
||||||
int getIconSize() const;
|
int getIconSize() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void focusSceneRequest();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
86
apps/opencs/view/widget/scenetoolmode.cpp
Normal file
86
apps/opencs/view/widget/scenetoolmode.cpp
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
|
||||||
|
#include "scenetoolmode.hpp"
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QSignalMapper>
|
||||||
|
|
||||||
|
#include "scenetoolbar.hpp"
|
||||||
|
#include "pushbutton.hpp"
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolMode::adjustToolTip (const PushButton *activeMode)
|
||||||
|
{
|
||||||
|
QString toolTip = mToolTip;
|
||||||
|
|
||||||
|
toolTip += "<p>Currently selected: " + activeMode->getBaseToolTip();
|
||||||
|
|
||||||
|
toolTip += "<p>(left click to change mode)";
|
||||||
|
|
||||||
|
setToolTip (toolTip);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWidget::SceneToolMode::SceneToolMode (SceneToolbar *parent, const QString& toolTip)
|
||||||
|
: SceneTool (parent), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()),
|
||||||
|
mToolTip (toolTip), mFirst (0)
|
||||||
|
{
|
||||||
|
mPanel = new QFrame (this, Qt::Popup);
|
||||||
|
|
||||||
|
mLayout = new QHBoxLayout (mPanel);
|
||||||
|
|
||||||
|
mLayout->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||||
|
|
||||||
|
mPanel->setLayout (mLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolMode::showPanel (const QPoint& position)
|
||||||
|
{
|
||||||
|
mPanel->move (position);
|
||||||
|
mPanel->show();
|
||||||
|
|
||||||
|
if (mFirst)
|
||||||
|
mFirst->setFocus (Qt::OtherFocusReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||||
|
button->setIconSize (QSize (mIconSize, mIconSize));
|
||||||
|
button->setFixedSize (mButtonSize, mButtonSize);
|
||||||
|
|
||||||
|
mLayout->addWidget (button);
|
||||||
|
|
||||||
|
mButtons.insert (std::make_pair (button, id));
|
||||||
|
|
||||||
|
connect (button, SIGNAL (clicked()), this, SLOT (selected()));
|
||||||
|
|
||||||
|
if (mButtons.size()==1)
|
||||||
|
{
|
||||||
|
mFirst = button;
|
||||||
|
setIcon (button->icon());
|
||||||
|
button->setChecked (true);
|
||||||
|
adjustToolTip (button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolMode::selected()
|
||||||
|
{
|
||||||
|
std::map<PushButton *, std::string>::const_iterator iter =
|
||||||
|
mButtons.find (dynamic_cast<PushButton *> (sender()));
|
||||||
|
|
||||||
|
if (iter!=mButtons.end())
|
||||||
|
{
|
||||||
|
if (!iter->first->hasKeepOpen())
|
||||||
|
mPanel->hide();
|
||||||
|
|
||||||
|
for (std::map<PushButton *, std::string>::const_iterator iter2 = mButtons.begin();
|
||||||
|
iter2!=mButtons.end(); ++iter2)
|
||||||
|
iter2->first->setChecked (iter2==iter);
|
||||||
|
|
||||||
|
setIcon (iter->first->icon());
|
||||||
|
adjustToolTip (iter->first);
|
||||||
|
emit modeChanged (iter->second);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef CSV_WORLD_SCENETOOL_MODE_H
|
#ifndef CSV_WIDGET_SCENETOOL_MODE_H
|
||||||
#define CSV_WORLD_SCENETOOL_MODE_H
|
#define CSV_WIDGET_SCENETOOL_MODE_H
|
||||||
|
|
||||||
#include "scenetool.hpp"
|
#include "scenetool.hpp"
|
||||||
|
|
||||||
|
@ -7,9 +7,10 @@
|
||||||
|
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWidget
|
||||||
{
|
{
|
||||||
class SceneToolbar;
|
class SceneToolbar;
|
||||||
|
class PushButton;
|
||||||
|
|
||||||
///< \brief Mode selector tool
|
///< \brief Mode selector tool
|
||||||
class SceneToolMode : public SceneTool
|
class SceneToolMode : public SceneTool
|
||||||
|
@ -18,17 +19,22 @@ namespace CSVWorld
|
||||||
|
|
||||||
QWidget *mPanel;
|
QWidget *mPanel;
|
||||||
QHBoxLayout *mLayout;
|
QHBoxLayout *mLayout;
|
||||||
std::map<QPushButton *, std::string> mButtons; // widget, id
|
std::map<PushButton *, std::string> mButtons; // widget, id
|
||||||
int mButtonSize;
|
int mButtonSize;
|
||||||
int mIconSize;
|
int mIconSize;
|
||||||
|
QString mToolTip;
|
||||||
|
PushButton *mFirst;
|
||||||
|
|
||||||
|
void adjustToolTip (const PushButton *activeMode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SceneToolMode (SceneToolbar *parent);
|
SceneToolMode (SceneToolbar *parent, const QString& toolTip);
|
||||||
|
|
||||||
virtual void showPanel (const QPoint& position);
|
virtual void showPanel (const QPoint& position);
|
||||||
|
|
||||||
void addButton (const std::string& icon, const std::string& id);
|
void addButton (const std::string& icon, const std::string& id,
|
||||||
|
const QString& tooltip = "");
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
#include "../render/previewwidget.hpp"
|
#include "../render/previewwidget.hpp"
|
||||||
|
|
||||||
#include "scenetoolbar.hpp"
|
#include "../widget/scenetoolbar.hpp"
|
||||||
#include "scenetoolmode.hpp"
|
#include "../widget/scenetoolmode.hpp"
|
||||||
|
|
||||||
CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||||
: SubView (id)
|
: SubView (id)
|
||||||
|
@ -28,9 +28,9 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo
|
||||||
else
|
else
|
||||||
mScene = new CSVRender::PreviewWidget (document.getData(), id.getId(), true, this);
|
mScene = new CSVRender::PreviewWidget (document.getData(), id.getId(), true, this);
|
||||||
|
|
||||||
SceneToolbar *toolbar = new SceneToolbar (48+6, this);
|
CSVWidget::SceneToolbar *toolbar = new CSVWidget::SceneToolbar (48+6, this);
|
||||||
|
|
||||||
SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar);
|
CSVWidget::SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar);
|
||||||
toolbar->addTool (lightingTool);
|
toolbar->addTool (lightingTool);
|
||||||
|
|
||||||
layout->addWidget (toolbar, 0);
|
layout->addWidget (toolbar, 0);
|
||||||
|
@ -46,6 +46,8 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo
|
||||||
connect (mScene, SIGNAL (closeRequest()), this, SLOT (closeRequest()));
|
connect (mScene, SIGNAL (closeRequest()), this, SLOT (closeRequest()));
|
||||||
connect (mScene, SIGNAL (referenceableIdChanged (const std::string&)),
|
connect (mScene, SIGNAL (referenceableIdChanged (const std::string&)),
|
||||||
this, SLOT (referenceableIdChanged (const std::string&)));
|
this, SLOT (referenceableIdChanged (const std::string&)));
|
||||||
|
connect (mScene, SIGNAL (focusToolbarRequest()), toolbar, SLOT (setFocus()));
|
||||||
|
connect (toolbar, SIGNAL (focusSceneRequest()), mScene, SLOT (setFocus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::PreviewSubView::setEditLock (bool locked) {}
|
void CSVWorld::PreviewSubView::setEditLock (bool locked) {}
|
||||||
|
|
|
@ -17,9 +17,11 @@
|
||||||
#include "../render/pagedworldspacewidget.hpp"
|
#include "../render/pagedworldspacewidget.hpp"
|
||||||
#include "../render/unpagedworldspacewidget.hpp"
|
#include "../render/unpagedworldspacewidget.hpp"
|
||||||
|
|
||||||
|
#include "../widget/scenetoolbar.hpp"
|
||||||
|
#include "../widget/scenetoolmode.hpp"
|
||||||
|
|
||||||
#include "tablebottombox.hpp"
|
#include "tablebottombox.hpp"
|
||||||
#include "creator.hpp"
|
#include "creator.hpp"
|
||||||
#include "scenetoolmode.hpp"
|
|
||||||
|
|
||||||
CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||||
: SubView (id), mLayout(new QHBoxLayout), mDocument(document), mScene(NULL), mToolbar(NULL)
|
: SubView (id), mLayout(new QHBoxLayout), mDocument(document), mScene(NULL), mToolbar(NULL)
|
||||||
|
@ -95,14 +97,14 @@ void CSVWorld::SceneSubView::makeConnections (CSVRender::PagedWorldspaceWidget*
|
||||||
this, SLOT (cellSelectionChanged (const CSMWorld::CellSelection&)));
|
this, SLOT (cellSelectionChanged (const CSMWorld::CellSelection&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::WorldspaceWidget* widget, widgetType type)
|
CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::WorldspaceWidget* widget, widgetType type)
|
||||||
{
|
{
|
||||||
CSVWorld::SceneToolbar* toolbar = new SceneToolbar (48+6, this);
|
CSVWidget::SceneToolbar* toolbar = new CSVWidget::SceneToolbar (48+6, this);
|
||||||
|
|
||||||
SceneToolMode *navigationTool = widget->makeNavigationSelector (toolbar);
|
CSVWidget::SceneToolMode *navigationTool = widget->makeNavigationSelector (toolbar);
|
||||||
toolbar->addTool (navigationTool);
|
toolbar->addTool (navigationTool);
|
||||||
|
|
||||||
SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar);
|
CSVWidget::SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar);
|
||||||
toolbar->addTool (lightingTool);
|
toolbar->addTool (lightingTool);
|
||||||
|
|
||||||
/* Add buttons specific to the type. For now no need for it.
|
/* Add buttons specific to the type. For now no need for it.
|
||||||
|
@ -188,7 +190,7 @@ void CSVWorld::SceneSubView::handleDrop (const std::vector< CSMWorld::UniversalI
|
||||||
{
|
{
|
||||||
CSVRender::PagedWorldspaceWidget* pagedNewWidget = NULL;
|
CSVRender::PagedWorldspaceWidget* pagedNewWidget = NULL;
|
||||||
CSVRender::UnpagedWorldspaceWidget* unPagedNewWidget = NULL;
|
CSVRender::UnpagedWorldspaceWidget* unPagedNewWidget = NULL;
|
||||||
SceneToolbar* toolbar = NULL;
|
CSVWidget::SceneToolbar* toolbar = NULL;
|
||||||
|
|
||||||
switch (mScene->getDropRequirements(CSVRender::WorldspaceWidget::getDropType(data)))
|
switch (mScene->getDropRequirements(CSVRender::WorldspaceWidget::getDropType(data)))
|
||||||
{
|
{
|
||||||
|
@ -217,7 +219,7 @@ void CSVWorld::SceneSubView::handleDrop (const std::vector< CSMWorld::UniversalI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceWidget* widget, CSVWorld::SceneToolbar* toolbar)
|
void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceWidget* widget, CSVWidget::SceneToolbar* toolbar)
|
||||||
{
|
{
|
||||||
assert(mLayout);
|
assert(mLayout);
|
||||||
|
|
||||||
|
@ -236,8 +238,12 @@ void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceW
|
||||||
mScene = widget;
|
mScene = widget;
|
||||||
mToolbar = toolbar;
|
mToolbar = toolbar;
|
||||||
|
|
||||||
|
connect (mScene, SIGNAL (focusToolbarRequest()), mToolbar, SLOT (setFocus()));
|
||||||
|
connect (mToolbar, SIGNAL (focusSceneRequest()), mScene, SLOT (setFocus()));
|
||||||
|
|
||||||
mLayout->addWidget (mToolbar, 0);
|
mLayout->addWidget (mToolbar, 0);
|
||||||
mLayout->addWidget (mScene, 1);
|
mLayout->addWidget (mScene, 1);
|
||||||
|
|
||||||
mScene->selectDefaultNavigationMode();
|
mScene->selectDefaultNavigationMode();
|
||||||
|
setFocusProxy (mScene);
|
||||||
}
|
}
|
|
@ -4,7 +4,6 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
#include "../doc/subview.hpp"
|
#include "../doc/subview.hpp"
|
||||||
#include "scenetoolbar.hpp"
|
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
|
||||||
|
@ -25,6 +24,11 @@ namespace CSVRender
|
||||||
class UnpagedWorldspaceWidget;
|
class UnpagedWorldspaceWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace CSVWidget
|
||||||
|
{
|
||||||
|
class SceneToolbar;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
class Table;
|
class Table;
|
||||||
|
@ -39,7 +43,7 @@ namespace CSVWorld
|
||||||
CSVRender::WorldspaceWidget *mScene;
|
CSVRender::WorldspaceWidget *mScene;
|
||||||
QHBoxLayout* mLayout;
|
QHBoxLayout* mLayout;
|
||||||
CSMDoc::Document& mDocument;
|
CSMDoc::Document& mDocument;
|
||||||
SceneToolbar* mToolbar;
|
CSVWidget::SceneToolbar* mToolbar;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -59,14 +63,15 @@ namespace CSVWorld
|
||||||
|
|
||||||
void makeConnections(CSVRender::UnpagedWorldspaceWidget* widget);
|
void makeConnections(CSVRender::UnpagedWorldspaceWidget* widget);
|
||||||
|
|
||||||
void replaceToolbarAndWorldspace(CSVRender::WorldspaceWidget* widget, SceneToolbar* toolbar);
|
void replaceToolbarAndWorldspace(CSVRender::WorldspaceWidget* widget, CSVWidget::SceneToolbar* toolbar);
|
||||||
|
|
||||||
enum widgetType
|
enum widgetType
|
||||||
{
|
{
|
||||||
widget_Paged,
|
widget_Paged,
|
||||||
widget_Unpaged
|
widget_Unpaged
|
||||||
};
|
};
|
||||||
SceneToolbar* makeToolbar(CSVRender::WorldspaceWidget* widget, widgetType type);
|
|
||||||
|
CSVWidget::SceneToolbar* makeToolbar(CSVRender::WorldspaceWidget* widget, widgetType type);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
|
|
||||||
#include "scenetoolbar.hpp"
|
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
#include "scenetool.hpp"
|
|
||||||
|
|
||||||
CSVWorld::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent)
|
|
||||||
: QWidget (parent), mButtonSize (buttonSize), mIconSize (buttonSize-6)
|
|
||||||
{
|
|
||||||
setFixedWidth (mButtonSize);
|
|
||||||
|
|
||||||
mLayout = new QVBoxLayout (this);
|
|
||||||
mLayout->setAlignment (Qt::AlignTop);
|
|
||||||
|
|
||||||
mLayout->setContentsMargins (QMargins (0, 0, 0, 0));
|
|
||||||
|
|
||||||
setLayout (mLayout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVWorld::SceneToolbar::addTool (SceneTool *tool)
|
|
||||||
{
|
|
||||||
mLayout->addWidget (tool, 0, Qt::AlignTop);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CSVWorld::SceneToolbar::getButtonSize() const
|
|
||||||
{
|
|
||||||
return mButtonSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CSVWorld::SceneToolbar::getIconSize() const
|
|
||||||
{
|
|
||||||
return mIconSize;
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
|
|
||||||
#include "scenetoolmode.hpp"
|
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QFrame>
|
|
||||||
#include <QSignalMapper>
|
|
||||||
|
|
||||||
#include "scenetoolbar.hpp"
|
|
||||||
|
|
||||||
CSVWorld::SceneToolMode::SceneToolMode (SceneToolbar *parent)
|
|
||||||
: SceneTool (parent), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize())
|
|
||||||
{
|
|
||||||
mPanel = new QFrame (this, Qt::Popup);
|
|
||||||
|
|
||||||
mLayout = new QHBoxLayout (mPanel);
|
|
||||||
|
|
||||||
mLayout->setContentsMargins (QMargins (0, 0, 0, 0));
|
|
||||||
|
|
||||||
mPanel->setLayout (mLayout);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVWorld::SceneToolMode::showPanel (const QPoint& position)
|
|
||||||
{
|
|
||||||
mPanel->move (position);
|
|
||||||
mPanel->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVWorld::SceneToolMode::addButton (const std::string& icon, const std::string& id)
|
|
||||||
{
|
|
||||||
QPushButton *button = new QPushButton (QIcon (QPixmap (icon.c_str())), "", mPanel);
|
|
||||||
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
|
||||||
button->setIconSize (QSize (mIconSize, mIconSize));
|
|
||||||
button->setFixedSize (mButtonSize, mButtonSize);
|
|
||||||
|
|
||||||
mLayout->addWidget (button);
|
|
||||||
|
|
||||||
mButtons.insert (std::make_pair (button, id));
|
|
||||||
|
|
||||||
connect (button, SIGNAL (clicked()), this, SLOT (selected()));
|
|
||||||
|
|
||||||
if (mButtons.size()==1)
|
|
||||||
setIcon (button->icon());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVWorld::SceneToolMode::selected()
|
|
||||||
{
|
|
||||||
std::map<QPushButton *, std::string>::const_iterator iter =
|
|
||||||
mButtons.find (dynamic_cast<QPushButton *> (sender()));
|
|
||||||
|
|
||||||
if (iter!=mButtons.end())
|
|
||||||
{
|
|
||||||
mPanel->hide();
|
|
||||||
|
|
||||||
setIcon (iter->first->icon());
|
|
||||||
emit modeChanged (iter->second);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue