CHANGED: #1471 CCtrlScroll is now part of NELGUI, and is under the NLGUI namespace. Also added a new class CGroupSubMenuBase.

--HG--
branch : gui-refactoring
This commit is contained in:
dfighter1985 2012-06-16 02:06:53 +02:00
parent a90445fa03
commit a062e563bf
25 changed files with 1392 additions and 1277 deletions

View file

@ -0,0 +1,200 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_SCROLL_H
#define RZ_CTRL_SCROLL_H
#include "nel/misc/types_nl.h"
#include "nel/gui/ctrl_scroll_base.h"
namespace NLGUI
{
/**
* Class handling scollbar function
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CCtrlScroll : public CCtrlScrollBase, public NLMISC::ICDBNode::IPropertyObserver
{
public:
DECLARE_UI_CLASS( CCtrlScroll )
CCtrlScroll(const TCtorParam &param);
~CCtrlScroll();
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual void updateCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
void setTarget (CInterfaceGroup *pIG);
// Return the delta value the track has moved
sint32 moveTrackX (sint32 dx);
sint32 moveTrackY (sint32 dy);
/** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs.
* Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons)
*/
void moveTargetX (sint32 dx);
void moveTargetY (sint32 dy);
void setAlign (sint32 nAlign) { _Aligned = nAlign; }
// invert the factor for target
void setInverted(bool invert) { _Inverted = invert; }
void setTextureBottomOrLeft (const std::string &txName);
void setTextureMiddle (const std::string &txName);
void setTextureTopOrRight (const std::string &txName);
void setTextureBottomOrLeft (sint32 txid) { _TxIdB = txid; }
void setTextureMiddle (sint32 txid) { _TxIdM = txid; }
void setTextureMiddleTile (uint8 tile) { _TileM = tile; } // 0 - not tiled (1 BL) (2 BR) (3 TL) (4 TR)
void setTextureTopOrRight (sint32 txid) { _TxIdT = txid; }
// number scroller
sint32 getValue() const { return _IsDBLink ? _DBLink.getSInt32() : _Value; }
// NB: the value is clamped (see setMinMax) and stepped (see setStepValue())
void setValue(sint32 value);
void setMinMax(sint32 nMin, sint32 nMax) { _Min = nMin; _Max = nMax; }
void setStepValue(uint32 step) { _StepValue= step; }
void setTrackPos(sint32 pos);
sint32 getTrackPos() const { return _TrackPos; }
sint32 getTrackSize() const { return _TrackSize; }
// dummy set for track size (forlua export)
void setTrackSize(sint32 /* trackSize */) { throw NLMISC::Exception("TrackSize is read-only"); }
void setFrozen (bool state);
bool getFrozen () const { return _Frozen; }
int luaSetTarget(CLuaState &ls);
int luaEnsureVisible(CLuaState &ls);
// name
void setName(const std::string & val) {_Name = val;}
std::string getName() const {return _Name;}
// max
void setMax(sint32 max) {_Max = max;}
sint32 getMax() const {return _Max;}
REFLECT_EXPORT_START(CCtrlScroll, CCtrlScrollBase)
REFLECT_LUA_METHOD("setTarget", luaSetTarget)
REFLECT_LUA_METHOD("ensureVisible", luaEnsureVisible);
REFLECT_SINT32("value", getValue, setValue);
REFLECT_SINT32("trackPos", getTrackPos, setTrackPos);
REFLECT_SINT32("trackSize", getTrackSize, setTrackSize);
REFLECT_STRING("name", getName, setName);
REFLECT_SINT32("max", getMax, setMax);
REFLECT_EXPORT_END
/** Ensure that a child element be visible into the frame through which
* its parent group is displayed.
* Example : Had we a list of items for which we want some item 'itemPtr' to have its top position
* matching the middle of the list, we would do :
* this->ensureVisible(itemPtr, Hotspot_Tx, Hotspot_Mx);
*
* The scrollbar will be moved accordingly.
*/
void ensureVisible(CInterfaceElement *childElement, THotSpot childHotSpot, THotSpot parentHotSpot);
protected:
CInterfaceProperty _DBLink; // If this is a value scroller we can link it with db
sint32 _Value; // Or we can use a normal value
sint32 _InitialValue;
sint32 _Min, _Max;
std::string _AHOnScroll;
std::string _AHOnScrollParams;
//
std::string _AHOnScrollEnd;
std::string _AHOnScrollEndParams;
//
//
std::string _AHOnScrollCancel;
std::string _AHOnScrollCancelParams;
sint32 _Aligned; // 0-Top 1-Bottom 2-Left 3-Right
sint32 _TrackDispPos;
sint32 _TrackPos;
sint32 _TrackSize;
sint32 _TrackSizeMin;
sint32 _MouseDownOffsetX;
sint32 _MouseDownOffsetY;
sint32 _TxIdB; // Same as Left if Horizontal sb
sint32 _TxIdM;
sint32 _TxIdT; // Same as Right if Horizontal sb
uint8 _TileM;
sint32 _LastTargetHReal;
sint32 _LastTargetMaxHReal;
sint32 _LastTargetOfsY;
sint32 _LastTargetWReal;
sint32 _LastTargetMaxWReal;
sint32 _LastTargetOfsX;
bool _Vertical : 1; // true if vertical track bar
bool _IsDBLink : 1;
bool _ObserverOn : 1;
bool _Inverted : 1;
bool _MouseDown : 1;
bool _CallingAH : 1;
bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button
bool _Frozen : 1;
// For Target Scroller only: the target offset step in pixel.
sint32 _TargetStepX;
sint32 _TargetStepY;
// For Value Scroller only: indicate the step the scroll bar has. 0 or 1 means no step
uint32 _StepValue;
// Slider's name
std::string _Name;
void computeTargetOfsFromPos();
// from IPropertyObserver
virtual void update(NLMISC::ICDBNode *node);
// step the value, and clamp it
void normalizeValue(sint32 &value);
void runAH(const std::string &name, const std::string &params);
};
}
#endif // RZ_CTRL_SCROLL_H
/* End of ctrl_scroll.h */

View file

@ -0,0 +1,48 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef GROUP_SUBMENU_BASE
#define GROUP_SUBMENU_BASE
#include "nel/gui/group_frame.h"
namespace NLGUI
{
class CGroupSubMenuBase : public CGroupFrame
{
public:
DECLARE_UI_CLASS( CGroupSubMenuBase )
CGroupSubMenuBase( const TCtorParam &param );
~CGroupSubMenuBase();
virtual void openSubMenu( sint32 nb );
virtual void hideSubMenus();
REFLECT_EXPORT_START( CGroupSubMenuBase, CGroupFrame )
REFLECT_EXPORT_END
protected:
private:
};
}
#endif

View file

@ -20,6 +20,9 @@
#include <string>
#include <vector>
#include <list>
#include "nel/misc/smart_ptr.h"
#include "nel/misc/rgba.h"
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_common.h"

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,47 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nel/gui/group_submenu_base.h"
namespace NLGUI
{
CGroupSubMenuBase::CGroupSubMenuBase( const NLGUI::CViewBase::TCtorParam &param ) :
CGroupFrame( param )
{
}
CGroupSubMenuBase::~CGroupSubMenuBase()
{
}
void CGroupSubMenuBase::openSubMenu( sint32 nb )
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
void CGroupSubMenuBase::hideSubMenus()
{
// Necessary because it's supposed to be an abstract class,
// however reflection requires the class to be instantiated.
nlassert( false );
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,196 +0,0 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_SCROLL_H
#define RZ_CTRL_SCROLL_H
#include "nel/misc/types_nl.h"
#include "nel/gui/ctrl_scroll_base.h"
/**
* Class handling scollbar function
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CCtrlScroll : public CCtrlScrollBase, public NLMISC::ICDBNode::IPropertyObserver
{
public:
DECLARE_UI_CLASS( CCtrlScroll )
CCtrlScroll(const TCtorParam &param);
~CCtrlScroll();
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual void updateCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
void setTarget (CInterfaceGroup *pIG);
// Return the delta value the track has moved
sint32 moveTrackX (sint32 dx);
sint32 moveTrackY (sint32 dy);
/** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs.
* Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons)
*/
void moveTargetX (sint32 dx);
void moveTargetY (sint32 dy);
void setAlign (sint32 nAlign) { _Aligned = nAlign; }
// invert the factor for target
void setInverted(bool invert) { _Inverted = invert; }
void setTextureBottomOrLeft (const std::string &txName);
void setTextureMiddle (const std::string &txName);
void setTextureTopOrRight (const std::string &txName);
void setTextureBottomOrLeft (sint32 txid) { _TxIdB = txid; }
void setTextureMiddle (sint32 txid) { _TxIdM = txid; }
void setTextureMiddleTile (uint8 tile) { _TileM = tile; } // 0 - not tiled (1 BL) (2 BR) (3 TL) (4 TR)
void setTextureTopOrRight (sint32 txid) { _TxIdT = txid; }
// number scroller
sint32 getValue() const { return _IsDBLink ? _DBLink.getSInt32() : _Value; }
// NB: the value is clamped (see setMinMax) and stepped (see setStepValue())
void setValue(sint32 value);
void setMinMax(sint32 nMin, sint32 nMax) { _Min = nMin; _Max = nMax; }
void setStepValue(uint32 step) { _StepValue= step; }
void setTrackPos(sint32 pos);
sint32 getTrackPos() const { return _TrackPos; }
sint32 getTrackSize() const { return _TrackSize; }
// dummy set for track size (forlua export)
void setTrackSize(sint32 /* trackSize */) { throw NLMISC::Exception("TrackSize is read-only"); }
void setFrozen (bool state);
bool getFrozen () const { return _Frozen; }
int luaSetTarget(CLuaState &ls);
int luaEnsureVisible(CLuaState &ls);
// name
void setName(const std::string & val) {_Name = val;}
std::string getName() const {return _Name;}
// max
void setMax(sint32 max) {_Max = max;}
sint32 getMax() const {return _Max;}
REFLECT_EXPORT_START(CCtrlScroll, CCtrlScrollBase)
REFLECT_LUA_METHOD("setTarget", luaSetTarget)
REFLECT_LUA_METHOD("ensureVisible", luaEnsureVisible);
REFLECT_SINT32("value", getValue, setValue);
REFLECT_SINT32("trackPos", getTrackPos, setTrackPos);
REFLECT_SINT32("trackSize", getTrackSize, setTrackSize);
REFLECT_STRING("name", getName, setName);
REFLECT_SINT32("max", getMax, setMax);
REFLECT_EXPORT_END
/** Ensure that a child element be visible into the frame through which
* its parent group is displayed.
* Example : Had we a list of items for which we want some item 'itemPtr' to have its top position
* matching the middle of the list, we would do :
* this->ensureVisible(itemPtr, Hotspot_Tx, Hotspot_Mx);
*
* The scrollbar will be moved accordingly.
*/
void ensureVisible(CInterfaceElement *childElement, THotSpot childHotSpot, THotSpot parentHotSpot);
protected:
CInterfaceProperty _DBLink; // If this is a value scroller we can link it with db
sint32 _Value; // Or we can use a normal value
sint32 _InitialValue;
sint32 _Min, _Max;
std::string _AHOnScroll;
std::string _AHOnScrollParams;
//
std::string _AHOnScrollEnd;
std::string _AHOnScrollEndParams;
//
//
std::string _AHOnScrollCancel;
std::string _AHOnScrollCancelParams;
sint32 _Aligned; // 0-Top 1-Bottom 2-Left 3-Right
sint32 _TrackDispPos;
sint32 _TrackPos;
sint32 _TrackSize;
sint32 _TrackSizeMin;
sint32 _MouseDownOffsetX;
sint32 _MouseDownOffsetY;
sint32 _TxIdB; // Same as Left if Horizontal sb
sint32 _TxIdM;
sint32 _TxIdT; // Same as Right if Horizontal sb
uint8 _TileM;
sint32 _LastTargetHReal;
sint32 _LastTargetMaxHReal;
sint32 _LastTargetOfsY;
sint32 _LastTargetWReal;
sint32 _LastTargetMaxWReal;
sint32 _LastTargetOfsX;
bool _Vertical : 1; // true if vertical track bar
bool _IsDBLink : 1;
bool _ObserverOn : 1;
bool _Inverted : 1;
bool _MouseDown : 1;
bool _CallingAH : 1;
bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button
bool _Frozen : 1;
// For Target Scroller only: the target offset step in pixel.
sint32 _TargetStepX;
sint32 _TargetStepY;
// For Value Scroller only: indicate the step the scroll bar has. 0 or 1 means no step
uint32 _StepValue;
// Slider's name
std::string _Name;
void computeTargetOfsFromPos();
// from IPropertyObserver
virtual void update(NLMISC::ICDBNode *node);
// step the value, and clamp it
void normalizeValue(sint32 &value);
void runAH(const std::string &name, const std::string &params);
};
#endif // RZ_CTRL_SCROLL_H
/* End of ctrl_scroll.h */

View file

@ -26,10 +26,10 @@
namespace NLGUI
{
class CCtrlBaseButton;
class CCtrlScroll;
}
// ***************************************************************************
class CCtrlScroll;
class CGroupContainer;
// ***************************************************************************

View file

@ -30,11 +30,11 @@
namespace NLGUI
{
class CCtrlButton;
class CCtrlScroll;
}
// ***************************************************************************
class CCtrlScroll;
class CHandlerListSheetTradeSelect;
class CHandlerListSheetTradeRightClick;
class CGroupContainer;

View file

@ -26,11 +26,11 @@
namespace NLGUI
{
class CCtrlButton;
class CCtrlScroll;
}
// ***************************************************************************
class CCtrlScroll;
class CHandlerListSheetTradeSelect;
class CHandlerListSheetTradeRightClick;

View file

@ -33,7 +33,7 @@
#include "group_list.h"
#include "nel/gui/ctrl_button.h"
#include "ctrl_scroll.h"
#include "nel/gui/ctrl_scroll.h"
#include "view_text.h"
#include "view_bitmap.h"
#include "../time_client.h"

View file

@ -27,10 +27,10 @@ namespace NLGUI
{
class CEventDescriptorLocalised;
class CCtrlButton;
class CCtrlScroll;
}
class CInterfaceList;
class CCtrlScroll;
class CViewText;
class COptionsContainerInsertion;
class COptionsContainerMove;

View file

@ -32,7 +32,7 @@ extern "C"
#include "group_list.h"
#include "group_container.h"
#include "view_link.h"
#include "ctrl_scroll.h"
#include "nel/gui/ctrl_scroll.h"
#include "nel/gui/ctrl_button.h"
#include "dbctrl_sheet.h"
#include "ctrl_text_button.h"

View file

@ -40,10 +40,10 @@ extern "C"
namespace NLGUI
{
class CCtrlButton;
class CCtrlScroll;
}
class CGroupList;
class CCtrlScroll;
class CDBGroupComboBox;
class CGroupParagraph;

View file

@ -112,7 +112,7 @@ void CViewTextMenu::setAlpha (sint32 a)
// ------------------------------------------------------------------------------------------------
CGroupSubMenu::CGroupSubMenu(const TCtorParam &param)
: CGroupFrame(param)
: CGroupSubMenuBase(param)
{
_SelectionView = NULL;
_GroupList = NULL;

View file

@ -21,14 +21,18 @@
#include "nel/gui/interface_group.h"
#include "nel/gui/group_modal.h"
#include "nel/gui/group_submenu_base.h"
#include "view_text.h"
#include "ctrl_text_button.h"
namespace NLGUI
{
class CCtrlScroll;
}
class CViewBitmap;
class CGroupMenu;
class CGroupList;
class CCtrlScroll;
/**
@ -92,7 +96,7 @@ private:
* \date 2002
*/
class CGroupSubMenu : public CGroupFrame
class CGroupSubMenu : public CGroupSubMenuBase
{
public:
@ -198,7 +202,7 @@ public:
int luaReset(CLuaState &ls);
int luaSetMaxVisibleLine(CLuaState &ls);
//
REFLECT_EXPORT_START(CGroupSubMenu, CGroupFrame)
REFLECT_EXPORT_START(CGroupSubMenu, CGroupSubMenuBase)
REFLECT_LUA_METHOD("getNumLine", luaGetNumLine);
REFLECT_LUA_METHOD("getLineId", luaGetLineId); // return the id of a line from its index
REFLECT_LUA_METHOD("getLineFromId", luaGetLineFromId); // return -1 if line with id is not found

View file

@ -23,7 +23,7 @@
#include "group_scrolltext.h"
#include "group_list.h"
#include "view_text.h"
#include "ctrl_scroll.h"
#include "nel/gui/ctrl_scroll.h"
#include "nel/gui/ctrl_button.h"
#include "nel/gui/action_handler.h"

View file

@ -26,10 +26,10 @@
namespace NLGUI
{
class CCtrlBaseButton;
class CCtrlScroll;
}
class CGroupList;
class CCtrlScroll;
// Can be used to build a chat window or anything that displays sequences of strings
/**

View file

@ -21,7 +21,7 @@
#include "interface_config.h"
#include "interface_manager.h"
#include "group_container.h"
#include "ctrl_scroll.h"
#include "nel/gui/ctrl_scroll.h"
using namespace NLMISC;
using namespace std;

View file

@ -51,7 +51,7 @@
#include "view_bitmap_combo.h"
#include "view_text.h"
// Ctrl
#include "ctrl_scroll.h"
#include "nel/gui/ctrl_scroll.h"
#include "nel/gui/ctrl_button.h"
#include "ctrl_text_button.h"
// DBCtrl

View file

@ -30,7 +30,7 @@
#include "view_pointer.h"
#include "nel/gui/ctrl_base.h"
#include "ctrl_scroll.h"
#include "nel/gui/ctrl_scroll.h"
#include "nel/gui/view_renderer.h"

View file

@ -52,7 +52,7 @@
#include "dbview_quantity.h"
#include "dbview_digit.h"
// Ctrl
#include "ctrl_scroll.h"
#include "nel/gui/ctrl_scroll.h"
#include "nel/gui/ctrl_button.h"
#include "ctrl_col_pick.h"
#include "ctrl_tooltip.h"

View file

@ -22,9 +22,12 @@
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlScroll;
}
class CDBCtrlSheet;
class CCtrlScroll;
// ***************************************************************************
/**

View file

@ -24,6 +24,7 @@
#include "view_text_id.h"
#include "view_bitmap.h"
#include "view_radar.h"
#include "nel/gui/group_submenu_base.h"
#include "group_menu.h"
#include "nel/gui/ctrl_base.h"
#include "nel/gui/interface_group.h"
@ -46,7 +47,7 @@
#include "dbview_bar3.h"
#include "group_list.h"
#include "nel/gui/ctrl_scroll_base.h"
#include "ctrl_scroll.h"
#include "nel/gui/ctrl_scroll.h"
#include "dbgroup_combo_box.h"
#include "group_tab.h"
#include "group_html.h"
@ -94,7 +95,8 @@ void registerInterfaceElements()
REGISTER_REFLECTABLE_CLASS(CCtrlScrollBase, CCtrlBase);
REGISTER_REFLECTABLE_CLASS(CCtrlScroll, CCtrlScrollBase);
REGISTER_REFLECTABLE_CLASS(CGroupMenu, CGroupModal)
REGISTER_REFLECTABLE_CLASS(CGroupSubMenu, CGroupFrame)
REGISTER_REFLECTABLE_CLASS(CGroupSubMenuBase, CGroupFrame)
REGISTER_REFLECTABLE_CLASS(CGroupSubMenu, CGroupSubMenuBase)
REGISTER_REFLECTABLE_CLASS(CGroupTab, CInterfaceGroup)
REGISTER_REFLECTABLE_CLASS(CGroupScrollText, CInterfaceGroup)
REGISTER_REFLECTABLE_CLASS(CGroupHTML, CGroupScrollText)

View file

@ -28,10 +28,10 @@ extern "C"
namespace NLGUI
{
class CCtrlBaseButton;
class CCtrlScroll;
}
class CGroupList;
class CCtrlScroll;
// ***************************************************************************