mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 14:45:35 +00:00
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));
|
||||
|
||||
SceneToolbar *toolbar = new SceneToolbar (this);
|
||||
SceneToolbar *toolbar = new SceneToolbar (48, this);
|
||||
// test
|
||||
SceneToolMode *tool = new SceneToolMode (this);
|
||||
SceneToolMode *tool = new SceneToolMode (toolbar);
|
||||
tool->addButton (":door.png", "a");
|
||||
tool->addButton (":GMST.png", "b");
|
||||
tool->addButton (":Info.png", "c");
|
||||
toolbar->addTool (tool);
|
||||
toolbar->addTool (new SceneToolMode (this));
|
||||
toolbar->addTool (new SceneToolMode (this));
|
||||
toolbar->addTool (new SceneToolMode (this));
|
||||
toolbar->addTool (new SceneToolMode (toolbar));
|
||||
toolbar->addTool (new SceneToolMode (toolbar));
|
||||
toolbar->addTool (new SceneToolMode (toolbar));
|
||||
layout2->addWidget (toolbar, 0);
|
||||
|
||||
/// \todo replace with rendering widget
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
|
||||
#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));
|
||||
setFixedSize (48, 48);
|
||||
setFixedSize (parent->getButtonSize(), parent->getButtonSize());
|
||||
|
||||
connect (this, SIGNAL (clicked()), this, SLOT (openRequest()));
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class SceneToolbar;
|
||||
|
||||
///< \brief Tool base class
|
||||
class SceneTool : public QPushButton
|
||||
{
|
||||
|
@ -12,7 +14,7 @@ namespace CSVWorld
|
|||
|
||||
public:
|
||||
|
||||
SceneTool (QWidget *parent = 0);
|
||||
SceneTool (SceneToolbar *parent);
|
||||
|
||||
virtual void showPanel (const QPoint& position) = 0;
|
||||
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
|
||||
#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->setAlignment (Qt::AlignTop);
|
||||
|
@ -20,4 +21,9 @@ CSVWorld::SceneToolbar::SceneToolbar (QWidget *parent) : QWidget (parent)
|
|||
void CSVWorld::SceneToolbar::addTool (SceneTool *tool)
|
||||
{
|
||||
mLayout->addWidget (tool, 0, Qt::AlignTop);
|
||||
}
|
||||
|
||||
int CSVWorld::SceneToolbar::getButtonSize() const
|
||||
{
|
||||
return mButtonSize;
|
||||
}
|
|
@ -14,12 +14,15 @@ namespace CSVWorld
|
|||
Q_OBJECT
|
||||
|
||||
QVBoxLayout *mLayout;
|
||||
int mButtonSize;
|
||||
|
||||
public:
|
||||
|
||||
SceneToolbar (QWidget *parent);
|
||||
SceneToolbar (int buttonSize, QWidget *parent = 0);
|
||||
|
||||
void addTool (SceneTool *tool);
|
||||
|
||||
int getButtonSize() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
#include <QFrame>
|
||||
#include <QSignalMapper>
|
||||
|
||||
CSVWorld::SceneToolMode::SceneToolMode (QWidget *parent)
|
||||
: SceneTool (parent)
|
||||
#include "scenetoolbar.hpp"
|
||||
|
||||
CSVWorld::SceneToolMode::SceneToolMode (SceneToolbar *parent)
|
||||
: SceneTool (parent), mButtonSize (parent->getButtonSize())
|
||||
{
|
||||
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);
|
||||
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
button->setFixedSize (48, 48);
|
||||
button->setFixedSize (mButtonSize, mButtonSize);
|
||||
|
||||
mLayout->addWidget (button);
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ class QHBoxLayout;
|
|||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class SceneToolbar;
|
||||
|
||||
///< \brief Mode selector tool
|
||||
class SceneToolMode : public SceneTool
|
||||
{
|
||||
|
@ -17,10 +19,11 @@ namespace CSVWorld
|
|||
QWidget *mPanel;
|
||||
QHBoxLayout *mLayout;
|
||||
std::map<QPushButton *, std::string> mButtons; // widget, id
|
||||
int mButtonSize;
|
||||
|
||||
public:
|
||||
|
||||
SceneToolMode (QWidget *parent = 0);
|
||||
SceneToolMode (SceneToolbar *parent);
|
||||
|
||||
virtual void showPanel (const QPoint& position);
|
||||
|
||||
|
|
Loading…
Reference in a new issue