1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
/*!
@file
@author Albert Semenov
@date 01/2009
@module
*/
#ifndef BASE_PANEL_VIEW_CELL_H_
#define BASE_PANEL_VIEW_CELL_H_
#include <MyGUI.h>
#include "BaseLayout/BaseLayout.h"
namespace wraps
{
class BasePanelViewCell :
public BaseLayout
{
public:
BasePanelViewCell(const std::string& _layout, MyGUI::Widget* _parent) :
BaseLayout(_layout, _parent),
mTextCaption(nullptr),
mWidgetClient(nullptr),
m_minimized(false)
{
mMainWidget->setPosition(0, 0);
m_minHeight = mMainWidget->getHeight() - getClient()->getHeight();
m_maxHeight = mMainWidget->getHeight();
}
virtual ~BasePanelViewCell()
{
}
void setCaption(const MyGUI::UString& _caption)
{
if (mTextCaption)
mTextCaption->setCaption(_caption);
}
MyGUI::Widget* getClient()
{
return mWidgetClient ? mWidgetClient : mMainWidget;
}
MyGUI::Widget* getMainWidget()
{
return mMainWidget;
}
void setClientHeight(int _height, bool _smooth = true)
{
m_minHeight = mMainWidget->getHeight() - getClient()->getHeight();
m_maxHeight = m_minHeight + _height;
if (_smooth)
{
if (!m_minimized)
{
updateMinimized();
}
}
else
{
mMainWidget->setSize(mMainWidget->getWidth(), m_maxHeight);
eventUpdatePanel(this);
}
}
bool isMinimized() const
{
return m_minimized;
}
virtual void setMinimized(bool _minimized)
{
m_minimized = _minimized;
updateMinimized();
}
void setVisible(bool _visible)
{
mMainWidget->setVisible(_visible);
}
bool getVisible()
{
return mMainWidget->getVisible();
}
MyGUI::delegates::CDelegate1<BasePanelViewCell*> eventUpdatePanel;
private:
void notifyUpdateAction(MyGUI::Widget* _widget, MyGUI::ControllerItem* _controller)
{
eventUpdatePanel(this);
}
void updateMinimized()
{
const float POSITION_CONTROLLER_TIME = 0.5f;
if (!m_minimized)
{
MyGUI::IntSize size(mMainWidget->getWidth(), m_maxHeight);
MyGUI::ControllerPosition* controller = createControllerPosition(size, POSITION_CONTROLLER_TIME, MyGUI::newDelegate(MyGUI::action::inertionalMoveFunction));
controller->eventUpdateAction += newDelegate(this, &BasePanelViewCell::notifyUpdateAction);
MyGUI::ControllerManager::getInstance().addItem(mMainWidget, controller);
}
else
{
MyGUI::IntSize size(mMainWidget->getWidth(), m_minHeight);
MyGUI::ControllerPosition* controller = createControllerPosition(size, POSITION_CONTROLLER_TIME, MyGUI::newDelegate(MyGUI::action::inertionalMoveFunction));
controller->eventUpdateAction += newDelegate(this, &BasePanelViewCell::notifyUpdateAction);
MyGUI::ControllerManager::getInstance().addItem(mMainWidget, controller);
}
}
MyGUI::ControllerPosition* createControllerPosition(const MyGUI::IntSize& _size, float _time, MyGUI::ControllerPosition::FrameAction::IDelegate* _action)
{
MyGUI::ControllerItem* item = MyGUI::ControllerManager::getInstance().createItem(MyGUI::ControllerPosition::getClassTypeName());
MyGUI::ControllerPosition* controller = item->castType<MyGUI::ControllerPosition>();
controller->setSize(_size);
controller->setTime(_time);
controller->setAction(_action);
return controller;
}
protected:
MyGUI::TextBox* mTextCaption;
MyGUI::Widget* mWidgetClient;
bool m_minimized;
int m_minHeight;
int m_maxHeight;
};
} // namespace wraps
#endif // BASE_PANEL_VIEW_CELL_H_
|