From 2e9779a59160ef58a80f90a81ba5e999435cf25f Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Thu, 7 Jun 2012 02:54:14 +0200 Subject: [PATCH] CHANGED: #1471 CInterfaceGroup no longer depends on CCtrlScroll. Instead if depends on a new CCtrlScrollBase class. --HG-- branch : gui-refactoring --- .../client/src/interface_v3/ctrl_draggable.h | 4 ++ .../client/src/interface_v3/ctrl_scroll.cpp | 4 +- .../client/src/interface_v3/ctrl_scroll.h | 12 ++-- .../src/interface_v3/ctrl_scroll_base.cpp | 66 +++++++++++++++++++ .../src/interface_v3/ctrl_scroll_base.h | 55 ++++++++++++++++ .../src/interface_v3/interface_group.cpp | 6 +- .../register_interface_elements.cpp | 11 ++-- 7 files changed, 140 insertions(+), 18 deletions(-) create mode 100644 code/ryzom/client/src/interface_v3/ctrl_scroll_base.cpp create mode 100644 code/ryzom/client/src/interface_v3/ctrl_scroll_base.h diff --git a/code/ryzom/client/src/interface_v3/ctrl_draggable.h b/code/ryzom/client/src/interface_v3/ctrl_draggable.h index 6b59af553..120fabde6 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_draggable.h +++ b/code/ryzom/client/src/interface_v3/ctrl_draggable.h @@ -6,6 +6,8 @@ class CCtrlDraggable : public CCtrlBase { public: + DECLARE_UI_CLASS( CCtrlDraggable ) + CCtrlDraggable( const TCtorParam ¶m ); virtual ~CCtrlDraggable(){}; @@ -21,6 +23,8 @@ public: _LastDraggedSheet = NULL; } + // Necessary because of reflection, no other purpose + void draw(){} REFLECT_EXPORT_START(CCtrlDraggable, CCtrlBase) REFLECT_BOOL("dragable", isDraggable, setDraggable); diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp index da37c6764..dd25f3e28 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.cpp @@ -15,8 +15,6 @@ // along with this program. If not, see . -/* -#include "stdpch.h"*/ #include "interface_manager.h" #include "widget_manager.h" #include "ctrl_scroll.h" @@ -33,7 +31,7 @@ NLMISC_REGISTER_OBJECT(CViewBase, CCtrlScroll, std::string, "scroll"); // ------------------------------------------------------------------------------------------------ CCtrlScroll::CCtrlScroll(const TCtorParam ¶m) -: CCtrlBase(param) +: CCtrlScrollBase(param) { _Vertical = true; _Aligned = 1; diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll.h b/code/ryzom/client/src/interface_v3/ctrl_scroll.h index f7aa19b72..e4f1b4db3 100644 --- a/code/ryzom/client/src/interface_v3/ctrl_scroll.h +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll.h @@ -20,7 +20,7 @@ #define RZ_CTRL_SCROLL_H #include "nel/misc/types_nl.h" -#include "ctrl_base.h" +#include "ctrl_scroll_base.h" /** * Class handling scollbar function @@ -28,11 +28,11 @@ * \author Nevrax France * \date 2002 */ -class CCtrlScroll : public CCtrlBase, public NLMISC::ICDBNode::IPropertyObserver +class CCtrlScroll : public CCtrlScrollBase, public NLMISC::ICDBNode::IPropertyObserver { public: - + DECLARE_UI_CLASS( CCtrlScroll ) CCtrlScroll(const TCtorParam ¶m); ~CCtrlScroll(); @@ -43,9 +43,7 @@ public: virtual void draw(); virtual bool handleEvent (const NLGUI::CEventDescriptor &event); - void setTarget (CInterfaceGroup *pIG); - CInterfaceGroup *getTarget () { return _Target; } // Return the delta value the track has moved sint32 moveTrackX (sint32 dx); sint32 moveTrackY (sint32 dy); @@ -97,7 +95,7 @@ public: void setMax(sint32 max) {_Max = max;} sint32 getMax() const {return _Max;} - REFLECT_EXPORT_START(CCtrlScroll, CCtrlBase) + REFLECT_EXPORT_START(CCtrlScroll, CCtrlScrollBase) REFLECT_LUA_METHOD("setTarget", luaSetTarget) REFLECT_LUA_METHOD("ensureVisible", luaEnsureVisible); REFLECT_SINT32("value", getValue, setValue); @@ -159,8 +157,6 @@ protected: sint32 _LastTargetMaxWReal; sint32 _LastTargetOfsX; - CInterfaceGroup *_Target; // If NULL the scroller is a value scroller - bool _Vertical : 1; // true if vertical track bar bool _IsDBLink : 1; bool _ObserverOn : 1; diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll_base.cpp b/code/ryzom/client/src/interface_v3/ctrl_scroll_base.cpp new file mode 100644 index 000000000..b0cff5373 --- /dev/null +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll_base.cpp @@ -0,0 +1,66 @@ +// Ryzom - MMORPG Framework +// 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 . + +#include "ctrl_scroll_base.h" + +CCtrlScrollBase::CCtrlScrollBase( const TCtorParam ¶m ) : +CCtrlBase( param ) +{ + _Target = NULL; +} + +CCtrlScrollBase::~CCtrlScrollBase() +{ +} + +void CCtrlScrollBase::setTarget( CInterfaceGroup *pIG ) +{ + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); +} + +sint32 CCtrlScrollBase::moveTrackX( sint32 dx ) +{ + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); + + return 0; +} + +sint32 CCtrlScrollBase::moveTrackY( sint32 dy ) +{ + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); + + return 0; +} + +void CCtrlScrollBase::moveTargetX( sint32 dx ) +{ + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); +} + +void CCtrlScrollBase::moveTargetY( sint32 dy ) +{ + // Necessary because it's supposed to be an abstract class, + // however reflection requires the class to be instantiated. + nlassert( false ); +} \ No newline at end of file diff --git a/code/ryzom/client/src/interface_v3/ctrl_scroll_base.h b/code/ryzom/client/src/interface_v3/ctrl_scroll_base.h new file mode 100644 index 000000000..43b82c05a --- /dev/null +++ b/code/ryzom/client/src/interface_v3/ctrl_scroll_base.h @@ -0,0 +1,55 @@ +// Ryzom - MMORPG Framework +// 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 . + +#ifndef CTRL_SCROLL_BASE_H +#define CTRL_SCROLL_BASE_H + +#include "ctrl_base.h" + +class CInterfaceGroup; + +class CCtrlScrollBase : public CCtrlBase +{ +public: + DECLARE_UI_CLASS( CCtrlScrollBase ) + + CCtrlScrollBase( const TCtorParam ¶m ); + virtual ~CCtrlScrollBase(); + + virtual void setTarget( CInterfaceGroup *pIG ); + CInterfaceGroup* getTarget(){ return _Target; } + virtual sint32 moveTrackX( sint32 dx ); + virtual 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) + */ + virtual void moveTargetX( sint32 dx ); + virtual void moveTargetY( sint32 dy ); + + + // Necessary because of reflection, no other purpose + void draw(){} + +protected: + CInterfaceGroup *_Target; // If NULL the scroller is a value scroller + +private: + +}; + +#endif + diff --git a/code/ryzom/client/src/interface_v3/interface_group.cpp b/code/ryzom/client/src/interface_v3/interface_group.cpp index ba59626ed..8050e3872 100644 --- a/code/ryzom/client/src/interface_v3/interface_group.cpp +++ b/code/ryzom/client/src/interface_v3/interface_group.cpp @@ -24,7 +24,7 @@ #include "interface_link.h" #include "widget_manager.h" -#include "ctrl_scroll.h" +#include "ctrl_scroll_base.h" #include "group_editbox.h" #include "group_scrolltext.h" #include "lua_ihm_ryzom.h" @@ -203,7 +203,7 @@ bool CInterfaceGroup::moveSBTrackY (CInterfaceGroup *target, sint32 dy) for (itc = _Controls.begin(); itc != _Controls.end(); itc++) { CCtrlBase *pCB = *itc; - CCtrlScroll *pSB = dynamic_cast(pCB); + CCtrlScrollBase *pSB = dynamic_cast(pCB); if (pSB != NULL) { if (pSB->getTarget() == target) @@ -224,7 +224,7 @@ bool CInterfaceGroup::moveSBTargetY(CInterfaceGroup *target,sint32 dy) for (itc = _Controls.begin(); itc != _Controls.end(); itc++) { CCtrlBase *pCB = *itc; - CCtrlScroll *pSB = dynamic_cast(pCB); + CCtrlScrollBase *pSB = dynamic_cast(pCB); if (pSB != NULL) { if (pSB->getTarget() == target) diff --git a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp index e763f40ee..8848f5c41 100644 --- a/code/ryzom/client/src/interface_v3/register_interface_elements.cpp +++ b/code/ryzom/client/src/interface_v3/register_interface_elements.cpp @@ -34,6 +34,7 @@ #include "ctrl_button.h" #include "ctrl_text_button.h" #include "ctrl_col_pick.h" +#include "ctrl_draggable.h" #include "dbctrl_sheet.h" #include "dbgroup_list_sheet.h" #include "group_editbox.h" @@ -42,9 +43,9 @@ #include "dbview_bar.h" #include "dbview_bar3.h" #include "group_list.h" +#include "ctrl_scroll_base.h" #include "ctrl_scroll.h" #include "dbgroup_combo_box.h" -#include "ctrl_scroll.h" #include "group_tab.h" #include "group_html.h" #include "group_header.h" @@ -75,7 +76,8 @@ void registerInterfaceElements() REGISTER_REFLECTABLE_CLASS(CCtrlButton, CCtrlBaseButton); REGISTER_REFLECTABLE_CLASS(CCtrlTextButton, CCtrlBaseButton); REGISTER_REFLECTABLE_CLASS(CCtrlColPick, CCtrlBase); - REGISTER_REFLECTABLE_CLASS(CDBCtrlSheet, CCtrlBase); + REGISTER_REFLECTABLE_CLASS(CCtrlDraggable, CCtrlBase); + REGISTER_REFLECTABLE_CLASS(CDBCtrlSheet, CCtrlDraggable); REGISTER_REFLECTABLE_CLASS(CInterfaceGroup, CCtrlBase); REGISTER_REFLECTABLE_CLASS(CGroupFrame, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CGroupModal, CGroupFrame); @@ -84,8 +86,9 @@ void registerInterfaceElements() REGISTER_REFLECTABLE_CLASS(IListSheetBase, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CGroupEditBox, CInterfaceGroup); REGISTER_REFLECTABLE_CLASS(CGroupTree, CInterfaceGroup); - REGISTER_REFLECTABLE_CLASS(CDBGroupComboBox, CInterfaceGroup) - REGISTER_REFLECTABLE_CLASS(CCtrlScroll, CCtrlBase); + REGISTER_REFLECTABLE_CLASS(CDBGroupComboBox, CInterfaceGroup); + REGISTER_REFLECTABLE_CLASS(CCtrlScrollBase, CCtrlBase); + REGISTER_REFLECTABLE_CLASS(CCtrlScroll, CCtrlScrollBase); REGISTER_REFLECTABLE_CLASS(CGroupMenu, CGroupModal) REGISTER_REFLECTABLE_CLASS(CGroupSubMenu, CGroupFrame) REGISTER_REFLECTABLE_CLASS(CGroupTab, CInterfaceGroup)