1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-24 09:53:53 +00:00
openmw/apps/opencs/view/widget/scenetooltoggle.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
1.8 KiB
C++
Raw Normal View History

2014-07-31 11:05:08 +00:00
#ifndef CSV_WIDGET_SCENETOOL_TOGGLE_H
#define CSV_WIDGET_SCENETOOL_TOGGLE_H
#include "scenetool.hpp"
#include <map>
class QHBoxLayout;
class QRect;
namespace CSVWidget
{
class SceneToolbar;
class PushButton;
///< \brief Multi-Toggle tool
class SceneToolToggle : public SceneTool
{
2022-09-22 18:26:05 +00:00
Q_OBJECT
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
struct ButtonDesc
{
unsigned int mMask;
std::string mSmallIcon;
QString mName;
int mIndex;
};
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
std::string mEmptyIcon;
QWidget* mPanel;
QHBoxLayout* mLayout;
std::map<PushButton*, ButtonDesc> mButtons; // widget, id
int mButtonSize;
int mIconSize;
QString mToolTip;
PushButton* mFirst;
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
void adjustToolTip();
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
void adjustIcon();
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
QRect getIconBox(int index) const;
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
public:
SceneToolToggle(SceneToolbar* parent, const QString& toolTip, const std::string& emptyIcon);
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
void showPanel(const QPoint& position) override;
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
/// \attention After the last button has been added, setSelection must be called at
/// least once to finalise the layout.
///
/// \note The layout algorithm can not handle more than 9 buttons. To prevent this An
/// attempt to add more will result in an exception being thrown.
/// The small icons will be sized at (x-4)/3 (where x is the main icon size).
void addButton(const std::string& icon, unsigned int mask, const std::string& smallIcon, const QString& name,
const QString& tooltip = "");
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
unsigned int getSelectionMask() const;
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
/// \param or'ed button masks. buttons that do not exist will be ignored.
void setSelectionMask(unsigned int selection);
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
signals:
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
void selectionChanged();
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
private slots:
2014-07-31 11:05:08 +00:00
2022-09-22 18:26:05 +00:00
void selected();
2014-07-31 11:05:08 +00:00
};
}
#endif