forked from teamnwah/openmw-tes3coop
consolidated magic numbers for button size
This commit is contained in:
parent
7be1f1afc2
commit
74cee66273
7 changed files with 33 additions and 15 deletions
|
@ -29,16 +29,16 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
|
|
||||||
layout2->setContentsMargins (QMargins (0, 0, 0, 0));
|
layout2->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||||
|
|
||||||
SceneToolbar *toolbar = new SceneToolbar (this);
|
SceneToolbar *toolbar = new SceneToolbar (48, this);
|
||||||
// test
|
// test
|
||||||
SceneToolMode *tool = new SceneToolMode (this);
|
SceneToolMode *tool = new SceneToolMode (toolbar);
|
||||||
tool->addButton (":door.png", "a");
|
tool->addButton (":door.png", "a");
|
||||||
tool->addButton (":GMST.png", "b");
|
tool->addButton (":GMST.png", "b");
|
||||||
tool->addButton (":Info.png", "c");
|
tool->addButton (":Info.png", "c");
|
||||||
toolbar->addTool (tool);
|
toolbar->addTool (tool);
|
||||||
toolbar->addTool (new SceneToolMode (this));
|
toolbar->addTool (new SceneToolMode (toolbar));
|
||||||
toolbar->addTool (new SceneToolMode (this));
|
toolbar->addTool (new SceneToolMode (toolbar));
|
||||||
toolbar->addTool (new SceneToolMode (this));
|
toolbar->addTool (new SceneToolMode (toolbar));
|
||||||
layout2->addWidget (toolbar, 0);
|
layout2->addWidget (toolbar, 0);
|
||||||
|
|
||||||
/// \todo replace with rendering widget
|
/// \todo replace with rendering widget
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
|
|
||||||
#include "scenetool.hpp"
|
#include "scenetool.hpp"
|
||||||
|
|
||||||
CSVWorld::SceneTool::SceneTool (QWidget *parent) : QPushButton (parent)
|
#include "scenetoolbar.hpp"
|
||||||
|
|
||||||
|
CSVWorld::SceneTool::SceneTool (SceneToolbar *parent) : QPushButton (parent)
|
||||||
{
|
{
|
||||||
setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||||
setFixedSize (48, 48);
|
setFixedSize (parent->getButtonSize(), parent->getButtonSize());
|
||||||
|
|
||||||
connect (this, SIGNAL (clicked()), this, SLOT (openRequest()));
|
connect (this, SIGNAL (clicked()), this, SLOT (openRequest()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
|
class SceneToolbar;
|
||||||
|
|
||||||
///< \brief Tool base class
|
///< \brief Tool base class
|
||||||
class SceneTool : public QPushButton
|
class SceneTool : public QPushButton
|
||||||
{
|
{
|
||||||
|
@ -12,7 +14,7 @@ namespace CSVWorld
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SceneTool (QWidget *parent = 0);
|
SceneTool (SceneToolbar *parent);
|
||||||
|
|
||||||
virtual void showPanel (const QPoint& position) = 0;
|
virtual void showPanel (const QPoint& position) = 0;
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,10 @@
|
||||||
|
|
||||||
#include "scenetool.hpp"
|
#include "scenetool.hpp"
|
||||||
|
|
||||||
CSVWorld::SceneToolbar::SceneToolbar (QWidget *parent) : QWidget (parent)
|
CSVWorld::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent)
|
||||||
|
: QWidget (parent), mButtonSize (buttonSize)
|
||||||
{
|
{
|
||||||
setFixedWidth (48);
|
setFixedWidth (mButtonSize);
|
||||||
|
|
||||||
mLayout = new QVBoxLayout (this);
|
mLayout = new QVBoxLayout (this);
|
||||||
mLayout->setAlignment (Qt::AlignTop);
|
mLayout->setAlignment (Qt::AlignTop);
|
||||||
|
@ -20,4 +21,9 @@ CSVWorld::SceneToolbar::SceneToolbar (QWidget *parent) : QWidget (parent)
|
||||||
void CSVWorld::SceneToolbar::addTool (SceneTool *tool)
|
void CSVWorld::SceneToolbar::addTool (SceneTool *tool)
|
||||||
{
|
{
|
||||||
mLayout->addWidget (tool, 0, Qt::AlignTop);
|
mLayout->addWidget (tool, 0, Qt::AlignTop);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSVWorld::SceneToolbar::getButtonSize() const
|
||||||
|
{
|
||||||
|
return mButtonSize;
|
||||||
}
|
}
|
|
@ -14,12 +14,15 @@ namespace CSVWorld
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QVBoxLayout *mLayout;
|
QVBoxLayout *mLayout;
|
||||||
|
int mButtonSize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SceneToolbar (QWidget *parent);
|
SceneToolbar (int buttonSize, QWidget *parent = 0);
|
||||||
|
|
||||||
void addTool (SceneTool *tool);
|
void addTool (SceneTool *tool);
|
||||||
|
|
||||||
|
int getButtonSize() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
|
|
||||||
CSVWorld::SceneToolMode::SceneToolMode (QWidget *parent)
|
#include "scenetoolbar.hpp"
|
||||||
: SceneTool (parent)
|
|
||||||
|
CSVWorld::SceneToolMode::SceneToolMode (SceneToolbar *parent)
|
||||||
|
: SceneTool (parent), mButtonSize (parent->getButtonSize())
|
||||||
{
|
{
|
||||||
mPanel = new QFrame (this, Qt::Popup);
|
mPanel = new QFrame (this, Qt::Popup);
|
||||||
|
|
||||||
|
@ -27,7 +29,7 @@ void CSVWorld::SceneToolMode::addButton (const std::string& icon, const std::str
|
||||||
{
|
{
|
||||||
QPushButton *button = new QPushButton (QIcon (QPixmap (icon.c_str())), "", mPanel);
|
QPushButton *button = new QPushButton (QIcon (QPixmap (icon.c_str())), "", mPanel);
|
||||||
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||||
button->setFixedSize (48, 48);
|
button->setFixedSize (mButtonSize, mButtonSize);
|
||||||
|
|
||||||
mLayout->addWidget (button);
|
mLayout->addWidget (button);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ class QHBoxLayout;
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
|
class SceneToolbar;
|
||||||
|
|
||||||
///< \brief Mode selector tool
|
///< \brief Mode selector tool
|
||||||
class SceneToolMode : public SceneTool
|
class SceneToolMode : public SceneTool
|
||||||
{
|
{
|
||||||
|
@ -17,10 +19,11 @@ namespace CSVWorld
|
||||||
QWidget *mPanel;
|
QWidget *mPanel;
|
||||||
QHBoxLayout *mLayout;
|
QHBoxLayout *mLayout;
|
||||||
std::map<QPushButton *, std::string> mButtons; // widget, id
|
std::map<QPushButton *, std::string> mButtons; // widget, id
|
||||||
|
int mButtonSize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SceneToolMode (QWidget *parent = 0);
|
SceneToolMode (SceneToolbar *parent);
|
||||||
|
|
||||||
virtual void showPanel (const QPoint& position);
|
virtual void showPanel (const QPoint& position);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue