1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 12:54:00 +00:00
OpenMW/apps/openmw/mwgui/spellview.hpp
scrawl e66e9916db Merge branch 'master' of https://github.com/OpenMW/openmw into osg
Conflicts:
	apps/opencs/CMakeLists.txt
	apps/opencs/model/doc/document.cpp
	apps/opencs/model/doc/document.hpp
2015-06-07 15:23:54 +02:00

99 lines
2.6 KiB
C++

#ifndef OPENMW_GUI_SPELLVIEW_H
#define OPENMW_GUI_SPELLVIEW_H
#include <boost/tuple/tuple.hpp>
#include <MyGUI_Widget.h>
#include "spellmodel.hpp"
namespace MyGUI
{
class ScrollView;
}
namespace MWGui
{
class SpellModel;
///@brief Displays a SpellModel in a list widget
class SpellView : public MyGUI::Widget
{
MYGUI_RTTI_DERIVED(SpellView)
public:
SpellView();
/// Register needed components with MyGUI's factory manager
static void registerComponents ();
/// Should the cost/chance column be shown?
void setShowCostColumn(bool show);
void setHighlightSelected(bool highlight);
/// Takes ownership of \a model
void setModel (SpellModel* model);
SpellModel* getModel();
void update();
/// simplified update called each frame
void incrementalUpdate();
typedef MyGUI::delegates::CMultiDelegate1<SpellModel::ModelIndex> EventHandle_ModelIndex;
/// Fired when a spell was clicked
EventHandle_ModelIndex eventSpellClicked;
virtual void initialiseOverride();
virtual void setSize(const MyGUI::IntSize& _value);
virtual void setCoord(const MyGUI::IntCoord& _value);
void resetScrollbars();
private:
MyGUI::ScrollView* mScrollView;
std::auto_ptr<SpellModel> mModel;
/// tracks a row in the spell view
struct LineInfo
{
/// the widget on the left side of the row
MyGUI::Widget* mLeftWidget;
/// the widget on the left side of the row (if there is one)
MyGUI::Widget* mRightWidget;
/// index to item in mModel that row is showing information for
SpellModel::ModelIndex mSpellIndex;
LineInfo(MyGUI::Widget* leftWidget, MyGUI::Widget* rightWidget, SpellModel::ModelIndex spellIndex);
};
/// magic number indicating LineInfo does not correspond to an item in mModel
enum { NoSpellIndex = -1 };
std::vector< LineInfo > mLines;
bool mShowCostColumn;
bool mHighlightSelected;
void layoutWidgets();
void addGroup(const std::string& label1, const std::string& label2);
void adjustSpellWidget(const Spell& spell, SpellModel::ModelIndex index, MyGUI::Widget* widget);
void onSpellSelected(MyGUI::Widget* _sender);
void onMouseWheelMoved(MyGUI::Widget* _sender, int _rel);
SpellModel::ModelIndex getSpellModelIndex(MyGUI::Widget* _sender);
static const char* sSpellModelIndex;
};
}
#endif