Merge pull request #3660 from nutty898/Merge_GUI_to_Develop

Merge gui to develop
This commit is contained in:
minggo 2013-09-17 06:25:09 -07:00
commit 5e858becf4
44 changed files with 833 additions and 1004 deletions

View File

@ -56,4 +56,9 @@ bool UIRootWidget::init()
return false;
}
const char* UIRootWidget::getDescription() const
{
return "RootWidget";
}
NS_CC_EXT_END

View File

@ -46,6 +46,11 @@ public:
* Allocates and initializes a widget.
*/
static UIRootWidget* create();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected:
//initializes state of widget.
virtual bool init();

View File

@ -1158,6 +1158,11 @@ LayoutParameter* UIWidget::getLayoutParameter()
return _layoutParameter;
}
const char* UIWidget::getDescription() const
{
return "Widget";
}
/*temp action*/
void UIWidget::setActionTag(int tag)
{

View File

@ -875,6 +875,11 @@ public:
virtual void onEnter();
virtual void onExit();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
/*temp action*/
void setActionTag(int tag);
int getActionTag();

View File

@ -425,6 +425,11 @@ const Size& Layout::getContentSize() const
return _renderer->getContentSize();
}
const char* Layout::getDescription() const
{
return "Layout";
}
RectClippingNode::RectClippingNode():
m_pInnerStencil(NULL),
_enabled(true),

View File

@ -179,6 +179,10 @@ public:
*/
virtual const Size& getContentSize() const;
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected:
//override "init" method of widget.
virtual bool init();

View File

@ -45,7 +45,6 @@ _rootWidget(NULL)
UIInputManager::~UIInputManager()
{
CCLOG("~UIInputManager");
_manageredWidget->removeAllObjects();
CC_SAFE_RELEASE_NULL(_manageredWidget);
_checkedDoubleClickWidget->removeAllObjects();
@ -177,9 +176,7 @@ void UIInputManager::onTouchEnd(Touch* touch)
{
UIWidget* hitWidget = (UIWidget*)(selectedWidgetArray->arr[i]);
hitWidget->onTouchEnded(_touchEndedPoint);
CCLOG("widget touch end");
}
CCLOG("_selectedWidgets remove widgets");
_selectedWidgets->removeAllObjects();
}

View File

@ -72,47 +72,31 @@ enum DRAGPANEL_BOUNCE_DIR
DRAGPANEL_BOUNCE_DIR_BOTTOM,
};
/**
* dragpanel berth event
*/
typedef void (Object::*SEL_DragPanelBerthToLeftBottomEvent)(Object*);
#define coco_DragPane_BerthToLeftBottom_selector(_SELECTOR) (SEL_DragPanelBerthToLeftBottomEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBerthToLeftTopEvent)(Object*);
#define coco_DragPanel_BerthToLeftTop_selector(_SELECTOR) (SEL_DragPanelBerthToLeftTopEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBerthToRightBottomEvent)(Object*);
#define coco_DragPanel_BerthToRightBottom_selector(_SELECTOR) (SEL_DragPanelBerthToRightBottomEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBerthToRightTopEvent)(Object*);
#define coco_DragPanel_BerthToRightTop_selector(_SELECTOR) (SEL_DragPanelBerthToRightTopEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBerthToLeftEvent)(Object*);
#define coco_DragPanel_BerthToLeft_selector(_SELECTOR) (SEL_DragPanelBerthToLeftEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBerthToRightEvent)(Object*);
#define coco_DragPanel_BerthToRight_selector(_SELECTOR) (SEL_DragPanelBerthToRightEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBerthToTopEvent)(Object*);
#define coco_DragPanel_BerthToTop_selector(_SELECTOR) (SEL_DragPanelBerthToTopEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBerthToBottomEvent)(Object*);
#define coco_DragPanel_BerthToBottom_selector(_SELECTOR) (SEL_DragPanelBerthToBottomEvent)(&_SELECTOR)
typedef enum
{
DRAGPANEL_EVENT_BERTH_LEFTBOTTOM,
DRAGPANEL_EVENT_BERTH_LFETTOP,
DRAGPANEL_EVENT_BERTH_RIGHTBOTTOM,
DRAGPANEL_EVENT_BERTH_RIGHTTOP,
DRAGPANEL_EVENT_BERTH_LEFT,
DRAGPANEL_EVENT_BERTH_TOP,
DRAGPANEL_EVENT_BERTH_RIGHT,
DRAGPANEL_EVENT_BERTH_BOTTOM,
DRAGPANEL_EVENT_BOUNCE_LEFTBOTTOM,
DRAGPANEL_EVENT_BOUNCE_LEFTTOP,
DRAGPANEL_EVENT_BOUNCE_RIGHTBOTTOM,
DRAGPANEL_EVENT_BOUNCE_RIGHTTOP,
DRAGPANEL_EVENT_BOUNCE_LEFT,
DRAGPANEL_EVENT_BOUNCE_TOP,
DRAGPANEL_EVENT_BOUNCE_RIGHT,
DRAGPANEL_EVENT_BOUNCE_BOTTOM,
}DragPanelEventType;
/**
* dragpanel bounce event
* dragpanel event
*/
typedef void (Object::*SEL_DragPanelBounceOverEvent)(Object*);
#define coco_DragPanel_BounceOver_selector(_SELECTOR) (SEL_DragPanelBounceOverEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToLeftBottomEvent)(Object*);
#define coco_DragPanel_BounceToLeftBottom_selector(_SELECTOR) (SEL_DragPanelBounceToLeftBottomEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToLeftTopEvent)(Object*);
#define coco_DragPanel_BounceToLeftTop_selector(_SELECTOR) (SEL_DragPanelBounceToLeftTopEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToRightBottomEvent)(Object*);
#define coco_DragPanel_BounceToRightBottom_selector(_SELECTOR) (SEL_DragPanelBounceToRightBottomEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToRightTopEvent)(Object*);
#define coco_DragPanel_BounceToRightTop_selector(_SELECTOR) (SEL_DragPanelBounceToRightTopEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToLeftEvent)(Object*);
#define coco_DragPanel_BounceToLeft_selector(_SELECTOR) (SEL_DragPanelBounceToLeftEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToTopEvent)(Object*);
#define coco_DragPanel_BounceToTop_selector(_SELECTOR) (SEL_DragPanelBounceToTopEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToRightEvent)(Object*);
#define coco_DragPanel_BounceToRight_selector(_SELECTOR) (SEL_DragPanelBounceToRightEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelBounceToBottomEvent)(Object*);
#define coco_DragPanel_BounceToBottom_selector(_SELECTOR) (SEL_DragPanelBounceToBottomEvent)(&_SELECTOR)
typedef void (Object::*SEL_DragPanelEvent)(Object*, DragPanelEventType);
#define dragpaneleventselector(_SELECTOR)(SEL_DragPanelEvent)(&_SELECTOR)
class UIDragPanel : public Layout, public UIScrollInterface
{
@ -180,16 +164,9 @@ public:
bool isBerth();
/**
* berth event by direction
* event
*/
void addBerthToLeftBottomEvent(Object* target, SEL_DragPanelBerthToLeftBottomEvent selector);
void addBerthToLeftTopEvent(Object* target, SEL_DragPanelBerthToLeftTopEvent selector);
void addBerthToRightBottomEvent(Object* target, SEL_DragPanelBerthToRightBottomEvent selector);
void addBerthToRightTopEvent(Object* target, SEL_DragPanelBerthToRightTopEvent selector);
void addBerthToLeftEvent(Object* target, SEL_DragPanelBerthToLeftEvent selector);
void addBerthToTopEvent(Object* target, SEL_DragPanelBerthToTopEvent selector);
void addBerthToRightEvent(Object* target, SEL_DragPanelBerthToRightEvent selector);
void addBerthToBottomEvent(Object* target, SEL_DragPanelBerthToBottomEvent selector);
void addEventListener(Object* target, SEL_DragPanelEvent selector);
/**
* get and set bounce enable
@ -204,18 +181,6 @@ public:
* set bounce ease rate
*/
void setBounceEaseRate(float rate);
/**
* bounce event by dircetion
*/
void addBounceOverEvent(Object* target, SEL_DragPanelBounceOverEvent selector);
void addBounceToLeftBottomEvent(Object* target, SEL_DragPanelBounceToLeftBottomEvent selector);
void addBounceToLeftTopEvent(Object* target, SEL_DragPanelBounceToLeftTopEvent selector);
void addBounceToRightBottomEvent(Object* target, SEL_DragPanelBounceToRightBottomEvent selector);
void addBounceToRightTopEvent(Object* target, SEL_DragPanelBounceToRightTopEvent selector);
void addBounceToLeftEvent(Object* target, SEL_DragPanelBounceToLeftEvent selector);
void addBounceToTopEvent(Object* target, SEL_DragPanelBounceToTopEvent selector);
void addBounceToRightEvent(Object* target, SEL_DragPanelBounceToRightEvent selector);
void addBounceToBottomEvent(Object* target, SEL_DragPanelBounceToBottomEvent selector);
/**
* Gets inner container of dragpanel.
@ -226,6 +191,11 @@ public:
*/
Layout* getInnerContainer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected:
virtual bool init();
virtual void initRenderer();
@ -286,7 +256,6 @@ protected:
void bounceToCorner();
void bounceOver();
// bounce event
void bounceOverEvent();
void bounceToLeftBottomEvent();
void bounceToRightBottomEvent();
void bounceToLeftTopEvent();
@ -318,94 +287,59 @@ protected:
/************/
virtual void setClippingEnabled(bool able){Layout::setClippingEnabled(able);};
protected:
Layout* m_pInnerContainer;
Layout* _innerContainer;
/*
DRAGPANEL_DIR m_eDirection;
DRAGPANEL_MOVE_DIR m_eMoveDirection;
*/
bool m_bTouchPressed;
bool m_bTouchMoved;
bool m_bTouchReleased;
bool m_bTouchCanceld; // check touch out of drag panel boundary
bool _touchPressed;
bool _touchMoved;
bool _touchReleased;
bool _touchCanceld; // check touch out of drag panel boundary
Point m_touchStartNodeSpace;
Point m_touchStartWorldSpace;
Point m_touchEndWorldSpace;
Point _touchStartNodeSpace;
Point _touchStartWorldSpace;
Point _touchEndWorldSpace;
float m_fSlidTime;
float _slidTime;
// move type
DRAGPANEL_MOVE_TYPE m_eMoveType;
DRAGPANEL_MOVE_TYPE _moveType;
// auto move
float m_fAutoMoveDuration;
float m_fAutoMoveEaseRate;
float _autoMoveDuration;
float _autoMoveEaseRate;
// event
Object* _eventLister;
SEL_DragPanelEvent _eventSelector;
// berth
DRAGPANEL_BERTH_DIR m_eBerthDirection;
// berth event
Object* m_pBerthToLeftListener;
SEL_DragPanelBerthToLeftEvent m_pfnBerthToLeftSelector;
Object* m_pBerthToRightListener;
SEL_DragPanelBerthToRightEvent m_pfnBerthToRightSelector;
Object* m_pBerthToTopListener;
SEL_DragPanelBerthToTopEvent m_pfnBerthToTopSelector;
Object* m_pBerthToBottomListener;
SEL_DragPanelBerthToBottomEvent m_pfnBerthToBottomSelector;
Object* m_pBerthToLeftBottomListener;
SEL_DragPanelBerthToLeftBottomEvent m_pfnBerthToLeftBottomSelector;
Object* m_pBerthToLeftTopListener;
SEL_DragPanelBerthToLeftTopEvent m_pfnBerthToLeftTopSelector;
Object* m_pBerthToRightBottomListener;
SEL_DragPanelBerthToRightBottomEvent m_pfnBerthToRightBottomSelector;
Object* m_pBerthToRightTopListener;
SEL_DragPanelBerthToRightTopEvent m_pfnBerthToRightTopSelector;
DRAGPANEL_BERTH_DIR _berthDirection;
// bounce
bool m_bBounceEnable;
DRAGPANEL_BOUNCE_DIR m_eBounceDirection;
float m_fBounceDuration;
float m_fBounceEaseRate;
// bounce event
Object* m_pBounceOverListener;
SEL_DragPanelBounceOverEvent m_pfnBounceOverSelector;
Object* m_pBounceToLeftBottomListener;
SEL_DragPanelBounceToLeftBottomEvent m_pfnBounceToLeftBottomSelector;
Object* m_pBounceToLeftTopListener;
SEL_DragPanelBounceToLeftTopEvent m_pfnBounceToLeftTopSelector;
Object* m_pBounceToRightBottomListener;
SEL_DragPanelBounceToRightBottomEvent m_pfnBounceToRightBottomSelector;
Object* m_pBounceToRightTopListener;
SEL_DragPanelBounceToRightTopEvent m_pfnBounceToRightTopSelector;
Object* m_pBounceToLeftListener;
SEL_DragPanelBounceToLeftEvent m_pfnBounceToLeftSelector;
Object* m_pBounceToTopListener;
SEL_DragPanelBounceToTopEvent m_pfnBounceToTopSelector;
Object* m_pBounceToRightListener;
SEL_DragPanelBounceToRightEvent m_pfnBounceToRightSelector;
Object* m_pBounceToBottomListener;
SEL_DragPanelBounceToBottomEvent m_pfnBounceToBottomSelector;
bool _bounceEnable;
DRAGPANEL_BOUNCE_DIR _bounceDirection;
float _bounceDuration;
float _bounceEaseRate;
float _runningAction;
int _actionType;
float m_bRunningAction;
int m_nActionType;
UIWidget* _actionWidget;
UIWidget* m_pActionWidget;
float _duration;
float _elapsed;
bool _firstTick;
float m_fDuration;
float m_elapsed;
bool m_bFirstTick;
Point _positionDelta;
Point _startPosition;
Point _previousPosition;
Point m_positionDelta;
Point m_startPosition;
Point m_previousPosition;
Point m_endPosition;
Point _endPosition;
};
NS_CC_EXT_END

View File

@ -42,10 +42,8 @@ UIListView::UIListView()
, _bePressed(false)
, _slidTime(0.0f)
, _childFocusCancelOffset(5.0f)
, _initChildListener(NULL)
, _initChildSelector(NULL)
, _updateChildListener(NULL)
, _updateChildSelector(NULL)
, _eventListener(NULL)
, _eventSelector(NULL)
, _childPool(NULL)
, _updatePool(NULL)
, _dataLength(0)
@ -1431,30 +1429,30 @@ void UIListView::updateChild()
void UIListView::initChildEvent()
{
if (_initChildListener && _initChildSelector)
if (_eventListener && _eventSelector)
{
(_initChildListener->*_initChildSelector)(this);
(_eventListener->*_eventSelector)(this, LISTVIEW_EVENT_INIT_CHILD);
}
}
void UIListView::updateChildEvent()
{
if (_updateChildListener && _updateChildSelector)
if (_eventListener && _eventSelector)
{
(_updateChildListener->*_updateChildSelector)(this);
(_eventListener->*_eventSelector)(this, LISTVIEW_EVENT_UPDATE_CHILD);
}
}
void UIListView::addInitChildEvent(Object *target, SEL_ListViewInitChildEvent seletor)
void UIListView::addEventListenter(Object *target, SEL_ListViewEvent selector)
{
_initChildListener = target;
_initChildSelector = seletor;
_eventListener = target;
_eventSelector = selector;
}
void UIListView::addUpdateChildEvent(Object *target, SEL_ListViewUpdateChildEvent selector)
const char* UIListView::getDescription() const
{
_updateChildListener = target;
_updateChildSelector = selector;
return "ListView";
}
NS_CC_EXT_END

View File

@ -53,13 +53,17 @@ typedef enum LISTVIEW_MOVE_DIR
LISTVIEW_MOVE_DIR_RIGHT,
}ListViewMoveDirection;
typedef enum
{
LISTVIEW_EVENT_INIT_CHILD,
LISTVIEW_EVENT_UPDATE_CHILD,
}ListViewEventType;
/**
* list view event
*/
typedef void (cocos2d::Object::*SEL_ListViewInitChildEvent)(cocos2d::Object*);
typedef void (cocos2d::Object::*SEL_ListViewUpdateChildEvent)(cocos2d::Object*);
#define coco_ListView_InitChild_selector(_SELECTOR) (SEL_ListViewInitChildEvent)(&_SELECTOR)
#define coco_ListView_UpdateChild_selector(_SELECTOR) (SEL_ListViewUpdateChildEvent)(&_SELECTOR)
typedef void (Object::*SEL_ListViewEvent)(Object*, ListViewEventType);
#define listvieweventselector(_SELECTOR)(SEL_ListViewEvent)(&_SELECTOR)
class UIListView : public Layout
{
@ -124,13 +128,9 @@ public:
* add event call-back function
*/
/**
* add init child event
* add event
*/
void addInitChildEvent(cocos2d::Object* target, SEL_ListViewInitChildEvent seletor);
/**
* add udpate child event
*/
void addUpdateChildEvent(cocos2d::Object* target, SEL_ListViewUpdateChildEvent selector);
void addEventListenter(cocos2d::Object* target, SEL_ListViewEvent selector);
/* gui mark */
/**
@ -139,6 +139,10 @@ public:
/**/
virtual void update(float dt);
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected:
virtual bool init();
@ -209,10 +213,8 @@ protected:
Point _moveChildPoint;
float _childFocusCancelOffset;
cocos2d::Object* _initChildListener;
SEL_ListViewInitChildEvent _initChildSelector;
cocos2d::Object* _updateChildListener;
SEL_ListViewUpdateChildEvent _updateChildSelector;
Object* _eventListener;
SEL_ListViewEvent _eventSelector;
Array* _childPool;
Array* _updatePool;

View File

@ -43,8 +43,8 @@ _autoScrollDistance(0.0f),
_autoScrollSpeed(0.0f),
_autoScrollDir(0),
_childFocusCancelOffset(5.0f),
_pageTurningListener(NULL),
_pageTurningSelector(NULL)
_eventListener(NULL),
_eventSelector(NULL)
{
}
@ -548,16 +548,16 @@ void UIPageView::interceptTouchEvent(int handleState, UIWidget *sender, const Po
void UIPageView::pageTurningEvent()
{
if (_pageTurningListener && _pageTurningSelector)
if (_eventListener && _eventSelector)
{
(_pageTurningListener->*_pageTurningSelector)(this);
(_eventListener->*_eventSelector)(this, PAGEVIEW_EVENT_TURNING);
}
}
void UIPageView::addPageTurningEvent(Object *target, SEL_PageViewPageTurningEvent selector)
void UIPageView::addEventListener(Object *target, SEL_PageViewEvent selector)
{
_pageTurningListener = target;
_pageTurningSelector = selector;
_eventListener = target;
_eventSelector = selector;
}
int UIPageView::getCurPageIndex() const
@ -565,4 +565,9 @@ int UIPageView::getCurPageIndex() const
return _curPageIdx;
}
const char* UIPageView::getDescription() const
{
return "PageView";
}
NS_CC_EXT_END

View File

@ -30,8 +30,13 @@
NS_CC_EXT_BEGIN
typedef void (Object::*SEL_PageViewPageTurningEvent)(Object*);
#define coco_PageView_PageTurning_selector(_SELECTOR) (SEL_PageViewPageTurningEvent)(&_SELECTOR)
typedef enum
{
PAGEVIEW_EVENT_TURNING,
}PageViewEventType;
typedef void (Object::*SEL_PageViewEvent)(Object*, PageViewEventType);
#define pagevieweventselector(_SELECTOR)(SEL_PageViewEvent)(&_SELECTOR)
typedef enum {
PAGEVIEW_TOUCHLEFT,
@ -110,8 +115,8 @@ public:
*/
int getCurPageIndex() const;
//Add call back function called when page turning.
void addPageTurningEvent(Object *target, SEL_PageViewPageTurningEvent selector);
// event
void addEventListener(Object *target, SEL_PageViewEvent selector);
//override "removeChild" method of widget.
virtual bool removeChild(UIWidget* widget);
@ -134,6 +139,10 @@ public:
//override "update" method of widget.
virtual void update(float dt);
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected:
virtual bool addChild(UIWidget* widget);
virtual bool init();
@ -170,8 +179,8 @@ protected:
float _autoScrollSpeed;
int _autoScrollDir;
float _childFocusCancelOffset;
Object* _pageTurningListener;
SEL_PageViewPageTurningEvent _pageTurningSelector;
Object* _eventListener;
SEL_PageViewEvent _eventSelector;
};
NS_CC_EXT_END

View File

@ -28,6 +28,7 @@
NS_CC_EXT_BEGIN
UIScrollView::UIScrollView():
_innerContainer(NULL),
_direction(SCROLLVIEW_DIR_VERTICAL),
_moveDirection(SCROLLVIEW_MOVE_DIR_NONE),
_touchStartLocation(0.0f),
@ -48,15 +49,8 @@ _bePressed(false),
_slidTime(0.0f),
_moveChildPoint(Point::ZERO),
_childFocusCancelOffset(5.0f),
_scrollToTopListener(NULL),
_scrollToTopSelector(NULL),
_scrollToBottomListener(NULL),
_scrollToBottomSelector(NULL),
_scrollToLeftListener(NULL),
_scrollToLeftSelector(NULL),
_scrollToRightListener(NULL),
_scrollToRightSelector(NULL),
_innerContainer(NULL)
_eventListener(NULL),
_eventSelector(NULL)
{
}
@ -609,58 +603,40 @@ void UIScrollView::checkChildInfo(int handleState,UIWidget* sender,const Point &
void UIScrollView::scrollToTopEvent()
{
if (_scrollToTopListener && _scrollToTopSelector)
if (_eventListener && _eventSelector)
{
(_scrollToTopListener->*_scrollToTopSelector)(this);
(_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_TOP);
}
}
void UIScrollView::scrollToBottomEvent()
{
if (_scrollToBottomListener && _scrollToBottomSelector)
if (_eventListener && _eventSelector)
{
(_scrollToBottomListener->*_scrollToBottomSelector)(this);
(_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM);
}
}
void UIScrollView::scrollToLeftEvent()
{
if (_scrollToLeftListener && _scrollToLeftSelector)
if (_eventListener && _eventSelector)
{
(_scrollToLeftListener->*_scrollToLeftSelector)(this);
(_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_LEFT);
}
}
void UIScrollView::scrollToRightEvent()
{
if (_scrollToRightListener && _scrollToRightSelector)
if (_eventListener && _eventSelector)
{
(_scrollToRightListener->*_scrollToRightSelector)(this);
(_eventListener->*_eventSelector)(this, SCROLLVIEW_EVENT_SCROLL_TO_RIGHT);
}
}
void UIScrollView::addScrollToTopEvent(Object *target, SEL_ScrollToTopEvent selector)
void UIScrollView::addEventListener(Object *target, SEL_ScrollViewEvent selector)
{
_scrollToTopListener = target;
_scrollToTopSelector = selector;
}
void UIScrollView::addScrollToBottomEvent(Object *target, SEL_ScrollToBottomEvent selector)
{
_scrollToBottomListener = target;
_scrollToBottomSelector = selector;
}
void UIScrollView::addScrollToLeftEvent(Object *target, SEL_ScrollToLeftEvent selector)
{
_scrollToLeftListener = target;
_scrollToLeftSelector = selector;
}
void UIScrollView::addScrollToRightEvent(Object *target, SEL_ScrollToRightEvent selector)
{
_scrollToRightListener = target;
_scrollToRightSelector = selector;
_eventListener = target;
_eventSelector = selector;
}
void UIScrollView::setDirection(SCROLLVIEW_DIR dir)
@ -698,4 +674,9 @@ LayoutExecutant* UIScrollView::getLayoutExecutant() const
return _innerContainer->getLayoutExecutant();
}
const char* UIScrollView::getDescription() const
{
return "ScrollView";
}
NS_CC_EXT_END

View File

@ -46,14 +46,16 @@ enum SCROLLVIEW_MOVE_DIR
SCROLLVIEW_MOVE_DIR_RIGHT,
};
typedef void (Object::*SEL_ScrollToTopEvent)(Object*);
typedef void (Object::*SEL_ScrollToBottomEvent)(Object*);
typedef void (Object::*SEL_ScrollToLeftEvent)(Object*);
typedef void (Object::*SEL_ScrollToRightEvent)(Object*);
#define coco_ScrollToTopSelector(_SELECTOR) (cocos2d::extension::SEL_ScrollToTopEvent)(&_SELECTOR)
#define coco_ScrollToBottomSelector(_SELECTOR) (cocos2d::extension::SEL_ScrollToBottomEvent)(&_SELECTOR)
#define coco_ScrollToLeftSelector(_SELECTOR) (cocos2d::extension::SEL_ScrollToLeftEvent)(&_SELECTOR)
#define coco_ScrollToRightSelector(_SELECTOR) (cocos2d::extension::SEL_ScrollToRightEvent)(&_SELECTOR)
typedef enum
{
SCROLLVIEW_EVENT_SCROLL_TO_TOP,
SCROLLVIEW_EVENT_SCROLL_TO_BOTTOM,
SCROLLVIEW_EVENT_SCROLL_TO_LEFT,
SCROLLVIEW_EVENT_SCROLL_TO_RIGHT,
}ScrollviewEventType;
typedef void (Object::*SEL_ScrollViewEvent)(Object*, ScrollviewEventType);
#define scrollvieweventselector(_SELECTOR) (SEL_ScrollViewEvent)(&_SELECTOR)
class UIScrollView : public Layout , public UIScrollInterface
@ -130,24 +132,9 @@ public:
const Size& getInnerContainerSize() const;
/**
* Add call back function called when scrollview scrolled to top.
* Add call back function called scrollview event triggered
*/
void addScrollToTopEvent(Object* target, SEL_ScrollToTopEvent selector);
/**
* Add call back function called when scrollview scrolled to bottom.
*/
void addScrollToBottomEvent(Object* target, SEL_ScrollToBottomEvent selector);
/**
* Add call back function called when scrollview scrolled to left.
*/
void addScrollToLeftEvent(Object* target, SEL_ScrollToLeftEvent selector);
/**
* Add call back function called when scrollview scrolled to right.
*/
void addScrollToRightEvent(Object* target, SEL_ScrollToRightEvent selector);
void addEventListener(Object* target, SEL_ScrollViewEvent selector);
//override "setLayoutExecutant" method of widget.
virtual void setLayoutExecutant(LayoutExecutant* exe);
@ -183,6 +170,11 @@ public:
virtual void onTouchLongClicked(const Point &touchPoint);
virtual void update(float dt);
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected:
virtual bool init();
virtual void initRenderer();
@ -212,6 +204,8 @@ protected:
virtual void onSizeChanged();
virtual void setClippingEnabled(bool able){Layout::setClippingEnabled(able);};
protected:
Layout* _innerContainer;
SCROLLVIEW_DIR _direction;
SCROLLVIEW_MOVE_DIR _moveDirection;
float _touchStartLocation;
@ -237,16 +231,9 @@ protected:
Point _moveChildPoint;
float _childFocusCancelOffset;
Object* _scrollToTopListener;
SEL_ScrollToTopEvent _scrollToTopSelector;
Object* _scrollToBottomListener;
SEL_ScrollToBottomEvent _scrollToBottomSelector;
Object* _scrollToLeftListener;
SEL_ScrollToLeftEvent _scrollToLeftSelector;
Object* _scrollToRightListener;
SEL_ScrollToRightEvent _scrollToRightSelector;
Object* _eventListener;
SEL_ScrollViewEvent _eventSelector;
Layout* _innerContainer;
};
NS_CC_EXT_END

View File

@ -431,54 +431,6 @@ void UIButton::setAnchorPoint(const Point &pt)
_titleRenderer->setPosition(Point(_size.width*(0.5f-_anchorPoint.x), _size.height*(0.5f-_anchorPoint.y)));
}
void UIButton::setNormalSpriteFrame(SpriteFrame *frame)
{
if (!frame)
{
return;
}
if (_scale9Enabled)
{
dynamic_cast<Scale9Sprite*>(_buttonNormalRenderer)->setSpriteFrame(frame);
}
else
{
dynamic_cast<Sprite*>(_buttonNormalRenderer)->setDisplayFrame(frame);
}
}
void UIButton::setPressedSpriteFrame(SpriteFrame *frame)
{
if (!frame)
{
return;
}
if (_scale9Enabled)
{
dynamic_cast<Scale9Sprite*>(_buttonClickedRenderer)->setSpriteFrame(frame);
}
else
{
dynamic_cast<Sprite*>(_buttonClickedRenderer)->setDisplayFrame(frame);
}
}
void UIButton::setDisabledSpriteFrame(SpriteFrame *frame)
{
if (!frame)
{
return;
}
if (_scale9Enabled)
{
dynamic_cast<Scale9Sprite*>(_buttonDisableRenderer)->setSpriteFrame(frame);
}
else
{
dynamic_cast<Sprite*>(_buttonDisableRenderer)->setDisplayFrame(frame);
}
}
void UIButton::onSizeChanged()
{
normalTextureScaleChangedWithSize();
@ -657,4 +609,9 @@ void UIButton::setColor(const Color3B &color)
setTitleColor(_titleColor);
}
const char* UIButton::getDescription() const
{
return "Button";
}
NS_CC_EXT_END

View File

@ -171,9 +171,10 @@ public:
void setTitleFontName(const char* fontName);
const char* getTitleFontName() const;
virtual void setNormalSpriteFrame(SpriteFrame* frame);
virtual void setPressedSpriteFrame(SpriteFrame* frame);
virtual void setDisabledSpriteFrame(SpriteFrame* frame);
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected:
virtual bool init();
virtual void initRenderer();

View File

@ -287,7 +287,7 @@ void UICheckBox::unSelectedEvent()
}
}
void UICheckBox::addSelectedStateEvent(Object *target, SEL_SelectedStateEvent selector)
void UICheckBox::addEventListener(Object *target, SEL_SelectedStateEvent selector)
{
_selectedStateEventListener = target;
_selectedStateEventSelector = selector;
@ -456,4 +456,9 @@ void UICheckBox::frontCrossDisabledTextureScaleChangedWithSize()
}
}
const char* UICheckBox::getDescription() const
{
return "CheckBox";
}
NS_CC_EXT_END

View File

@ -134,7 +134,7 @@ public:
virtual void setAnchorPoint(const Point &pt);
//add a call back function would called when checkbox is selected or unselected.
void addSelectedStateEvent(Object* target,SEL_SelectedStateEvent selector);
void addEventListener(Object* target,SEL_SelectedStateEvent selector);
//override "setFlipX" method of widget.
virtual void setFlipX(bool flipX);
@ -157,6 +157,10 @@ public:
//override "getVirtualRenderer" method of widget.
virtual Node* getVirtualRenderer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected:
virtual bool init();
virtual void initRenderer();

View File

@ -368,4 +368,9 @@ void UIImageView::imageTextureScaleChangedWithSize()
}
}
const char* UIImageView::getDescription() const
{
return "ImageView";
}
NS_CC_EXT_END

View File

@ -107,6 +107,11 @@ public:
void checkDoubleClick(float dt);
virtual const Size& getContentSize() const;
virtual Node* getVirtualRenderer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected:
virtual void initRenderer();
virtual void onSizeChanged();

View File

@ -221,7 +221,11 @@ void UILabel::labelScaleChangedWithSize()
_labelRenderer->setScaleX(scaleX);
_labelRenderer->setScaleY(scaleY);
}
}
const char* UILabel::getDescription() const
{
return "Label";
}
NS_CC_EXT_END

View File

@ -117,6 +117,11 @@ public:
//override "getVirtualRenderer" method of widget.
virtual Node* getVirtualRenderer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
void setTextAreaSize(const Size &size);
void setTextHorizontalAlignment(TextHAlignment alignment);
void setTextVerticalAlignment(TextVAlignment alignment);

View File

@ -167,4 +167,9 @@ void UILabelAtlas::labelAtlasScaleChangedWithSize()
}
}
const char* UILabelAtlas::getDescription() const
{
return "LabelAtlase";
}
NS_CC_EXT_END

View File

@ -87,6 +87,11 @@ public:
//override "getVirtualRenderer" method of widget.
virtual Node* getVirtualRenderer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected:
virtual void initRenderer();
virtual void onSizeChanged();

View File

@ -126,4 +126,10 @@ void UILabelBMFont::labelBMFontScaleChangedWithSize()
}
}
const char* UILabelBMFont::getDescription() const
{
return "LabelBMFont";
}
NS_CC_EXT_END

View File

@ -58,6 +58,11 @@ public:
virtual void setAnchorPoint(const Point &pt);
virtual const Size& getContentSize() const;
virtual Node* getVirtualRenderer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected:
virtual void initRenderer();
virtual void onSizeChanged();

View File

@ -331,4 +331,9 @@ void UILoadingBar::setScale9Scale()
dynamic_cast<Scale9Sprite*>(_barRenderer)->setPreferredSize(Size(width, _barRendererTextureSize.height));
}
const char* UILoadingBar::getDescription() const
{
return "LoadingBar";
}
NS_CC_EXT_END

View File

@ -117,6 +117,10 @@ public:
//override "getVirtualRenderer" method of widget.
virtual Node* getVirtualRenderer();
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected:
virtual void initRenderer();
virtual void onSizeChanged();

View File

@ -410,7 +410,7 @@ float UISlider::getPercentWithBallPos(float px)
return (((px-(-_barLength/2.0f))/_barLength)*100.0f);
}
void UISlider::addPercentEvent(Object *target, SEL_SlidPercentChangedEvent selector)
void UISlider::addEventListener(Object *target, SEL_SlidPercentChangedEvent selector)
{
_slidPercentListener = target;
_slidPercentSelector = selector;
@ -535,4 +535,10 @@ void UISlider::onPressStateChangedToDisabled()
_slidBallPressedRenderer->setVisible(false);
_slidBallDisabledRenderer->setVisible(true);
}
const char* UISlider::getDescription() const
{
return "Slider";
}
NS_CC_EXT_END

View File

@ -158,7 +158,7 @@ public:
/**
* Add call back function called when slider's percent has changed to slider.
*/
void addPercentEvent(Object* target,SEL_SlidPercentChangedEvent selector);
void addEventListener(Object* target,SEL_SlidPercentChangedEvent selector);
//override "onTouchBegan" method of widget.
virtual bool onTouchBegan(const Point &touchPoint);
@ -180,6 +180,11 @@ public:
//override "ignoreContentAdaptWithSize" method of widget.
virtual void ignoreContentAdaptWithSize(bool ignore);
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
protected:
virtual void initRenderer();
float getPercentWithBallPos(float location);

View File

@ -271,18 +271,12 @@ bool UICCTextField::getDeleteBackward()
UITextField::UITextField():
_textFieldRenderer(NULL),
_touchWidth(0.0f),
_touchHeight(0.0f),
_useTouchArea(false),
_attachWithIMEListener(NULL),
_detachWithIMEListener(NULL),
_insertTextListener(NULL),
_deleteBackwardListener(NULL),
_attachWithIMESelector(NULL),
_detachWithIMESelector(NULL),
_insertTextSelector(NULL),
_deleteBackwardSelector(NULL),
_textFieldRenderer(NULL)
_eventListener(NULL),
_eventSelector(NULL)
{
}
@ -475,58 +469,40 @@ void UITextField::setDeleteBackward(bool deleteBackward)
void UITextField::attachWithIMEEvent()
{
if (_attachWithIMEListener && _attachWithIMESelector)
if (_eventListener && _eventSelector)
{
(_attachWithIMEListener->*_attachWithIMESelector)(this);
(_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_ATTACH_WITH_IME);
}
}
void UITextField::detachWithIMEEvent()
{
if (_detachWithIMEListener && _detachWithIMESelector)
if (_eventListener && _eventSelector)
{
(_detachWithIMEListener->*_detachWithIMESelector)(this);
(_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_DETACH_WITH_IME);
}
}
void UITextField::insertTextEvent()
{
if (_insertTextListener && _insertTextSelector)
if (_eventListener && _eventSelector)
{
(_insertTextListener->*_insertTextSelector)(this);
(_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_INDERT_TEXT);
}
}
void UITextField::deleteBackwardEvent()
{
if (_deleteBackwardListener && _deleteBackwardSelector)
if (_eventListener && _eventSelector)
{
(_deleteBackwardListener->*_deleteBackwardSelector)(this);
(_eventListener->*_eventSelector)(this, TEXTFIELD_EVENT_DELETE_BACKWARD);
}
}
void UITextField::addAttachWithIMEEvent(Object *target, SEL_TextFieldAttachWithIMEEvent selecor)
void UITextField::addEventListener(Object *target, SEL_TextFieldEvent selecor)
{
_attachWithIMEListener = target;
_attachWithIMESelector = selecor;
}
void UITextField::addDetachWithIMEEvent(Object *target, SEL_TextFieldDetachWithIMEEvent selecor)
{
_detachWithIMEListener = target;
_detachWithIMESelector = selecor;
}
void UITextField::addInsertTextEvent(Object *target, SEL_TextFieldInsertTextEvent selecor)
{
_insertTextListener = target;
_insertTextSelector = selecor;
}
void UITextField::addDeleteBackwardEvent(Object *target, SEL_TextFieldDeleteBackwardEvent selecor)
{
_deleteBackwardListener = target;
_deleteBackwardSelector = selecor;
_eventListener = target;
_eventSelector = selecor;
}
void UITextField::setAnchorPoint(const Point &pt)
@ -584,4 +560,9 @@ Node* UITextField::getVirtualRenderer()
return _textFieldRenderer;
}
const char* UITextField::getDescription() const
{
return "TextField";
}
NS_CC_EXT_END

View File

@ -70,6 +70,8 @@ public:
bool getInsertText();
void setDeleteBackward(bool deleteBackward);
bool getDeleteBackward();
protected:
bool m_bMaxLengthEnabled;
int m_nMaxLength;
@ -82,14 +84,16 @@ protected:
};
typedef void (Object::*SEL_TextFieldAttachWithIMEEvent)(Object*);
#define coco_TextField_AttachWithIME_selector(_SELECTOR) (SEL_TextFieldAttachWithIMEEvent)(&_SELECTOR)
typedef void (Object::*SEL_TextFieldDetachWithIMEEvent)(Object*);
#define coco_TextField_DetachWithIME_selector(_SELECTOR) (SEL_TextFieldDetachWithIMEEvent)(&_SELECTOR)
typedef void (Object::*SEL_TextFieldInsertTextEvent)(Object*);
#define coco_TextField_InsertText_selector(_SELECTOR) (SEL_TextFieldInsertTextEvent)(&_SELECTOR)
typedef void (Object::*SEL_TextFieldDeleteBackwardEvent)(Object*);
#define coco_TextField_DeleteBackward_selector(_SELECTOR) (SEL_TextFieldDeleteBackwardEvent)(&_SELECTOR)
typedef enum
{
TEXTFIELD_EVENT_ATTACH_WITH_IME,
TEXTFIELD_EVENT_DETACH_WITH_IME,
TEXTFIELD_EVENT_INDERT_TEXT,
TEXTFIELD_EVENT_DELETE_BACKWARD,
}TextFiledEventType;
typedef void (Object::*SEL_TextFieldEvent)(Object*, TextFiledEventType);
#define textfieldeventselector(_SELECTOR) (SEL_TextFieldEvent)(&_SELECTOR)
//class UITextField : public UIWidget
class UITextField : public UIWidget
@ -124,14 +128,14 @@ public:
void setInsertText(bool insertText);
bool getDeleteBackward();
void setDeleteBackward(bool deleteBackward);
void addAttachWithIMEEvent(Object* target, SEL_TextFieldAttachWithIMEEvent selecor);
void addDetachWithIMEEvent(Object* target, SEL_TextFieldDetachWithIMEEvent selecor);
void addInsertTextEvent(Object* target, SEL_TextFieldInsertTextEvent selecor);
void addDeleteBackwardEvent(Object* target, SEL_TextFieldDeleteBackwardEvent selecor);
void addEventListener(Object* target, SEL_TextFieldEvent selecor);
virtual void setAnchorPoint(const Point &pt);
virtual void setColor(const Color3B &color);
virtual void setOpacity(int opacity);
/**
* Returns the "class name" of widget.
*/
virtual const char* getDescription() const;
/*compatibel*/
/**
* These methods will be removed
@ -150,21 +154,15 @@ protected:
virtual void onSizeChanged();
void textfieldRendererScaleChangedWithSize();
protected:
UICCTextField* _textFieldRenderer;
float _touchWidth;
float _touchHeight;
bool _useTouchArea;
Object* _attachWithIMEListener;
Object* _detachWithIMEListener;
Object* _insertTextListener;
Object* _deleteBackwardListener;
Object* _eventListener;
SEL_TextFieldEvent _eventSelector;
SEL_TextFieldAttachWithIMEEvent _attachWithIMESelector;
SEL_TextFieldDetachWithIMEEvent _detachWithIMESelector;
SEL_TextFieldInsertTextEvent _insertTextSelector;
SEL_TextFieldDeleteBackwardEvent _deleteBackwardSelector;
UICCTextField* _textFieldRenderer;
};
NS_CC_EXT_END

View File

@ -54,7 +54,7 @@ bool UICheckBoxTest::init()
"cocosgui/check_box_active_disable.png");
checkBox->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
checkBox->addSelectedStateEvent(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent));
checkBox->addEventListener(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent));
// checkBox->addSelectEvent(this, coco_selectselector(UICheckBoxTest::selectedEvent));
m_pUiLayer->addWidget(checkBox);

View File

@ -57,14 +57,7 @@ bool UIDragPanelTest::init()
(backgroundSize.width - dragPanel->getSize().width) / 2,
(widgetSize.height - backgroundSize.height) / 2 +
(backgroundSize.height - dragPanel->getSize().height) / 2));
dragPanel->addBerthToLeftBottomEvent(this, coco_DragPane_BerthToLeftBottom_selector(UIDragPanelTest::berthToLeftBottomEvent));
dragPanel->addBerthToLeftTopEvent(this, coco_DragPanel_BerthToLeftTop_selector(UIDragPanelTest::berthToLeftTopEvent));
dragPanel->addBerthToRightBottomEvent(this, coco_DragPanel_BerthToRightBottom_selector(UIDragPanelTest::berthToRightBottomEvent));
dragPanel->addBerthToRightTopEvent(this, coco_DragPanel_BerthToRightTop_selector(UIDragPanelTest::berthToRightTopEvent));
dragPanel->addBerthToLeftEvent(this, coco_DragPanel_BerthToLeft_selector(UIDragPanelTest::berthToLeftEvent));
dragPanel->addBerthToTopEvent(this, coco_DragPanel_BerthToTop_selector(UIDragPanelTest::berthToTopEvent));
dragPanel->addBerthToRightEvent(this, coco_DragPanel_BerthToRight_selector(UIDragPanelTest::berthToRightEvent));
dragPanel->addBerthToBottomEvent(this, coco_DragPanel_BerthToBottom_selector(UIDragPanelTest::berthToBottomEvent));
dragPanel->addEventListener(this, dragpaneleventselector(UIDragPanelTest::dragPanelEvent));
UIImageView* imageView = UIImageView::create();
imageView->setTouchEnabled(true);
@ -82,44 +75,45 @@ bool UIDragPanelTest::init()
return false;
}
void UIDragPanelTest::berthToLeftBottomEvent(Object *pSender)
void UIDragPanelTest::dragPanelEvent(Object *pSender, DragPanelEventType type)
{
switch (type)
{
case DRAGPANEL_EVENT_BERTH_LEFTBOTTOM:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left Bottom")->getCString());
}
break;
void UIDragPanelTest::berthToLeftTopEvent(Object *pSender)
{
case DRAGPANEL_EVENT_BERTH_LFETTOP:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left Top")->getCString());
}
break;
void UIDragPanelTest::berthToRightBottomEvent(Object *pSender)
{
case DRAGPANEL_EVENT_BERTH_RIGHTBOTTOM:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right Bottom")->getCString());
}
break;
void UIDragPanelTest::berthToRightTopEvent(Object *pSender)
{
case DRAGPANEL_EVENT_BERTH_RIGHTTOP:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right Top")->getCString());
}
break;
void UIDragPanelTest::berthToLeftEvent(Object* pSender)
{
case DRAGPANEL_EVENT_BERTH_LEFT:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Left")->getCString());
}
break;
void UIDragPanelTest::berthToTopEvent(Object *pSender)
{
case DRAGPANEL_EVENT_BERTH_TOP:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Top")->getCString());
}
break;
void UIDragPanelTest::berthToRightEvent(Object *pSender)
{
case DRAGPANEL_EVENT_BERTH_RIGHT:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Right")->getCString());
}
break;
void UIDragPanelTest::berthToBottomEvent(Object *pSender)
{
case DRAGPANEL_EVENT_BERTH_BOTTOM:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Berth To Bottom")->getCString());
break;
default:
break;
}
}
// UIDragPanelTest_Bounce
@ -171,14 +165,7 @@ bool UIDragPanelTest_Bounce::init()
(backgroundSize.width - dragPanel->getSize().width) / 2,
(widgetSize.height - backgroundSize.height) / 2 +
(backgroundSize.height - dragPanel->getSize().height) / 2));
dragPanel->addBounceToLeftBottomEvent(this, coco_DragPanel_BounceToLeftBottom_selector(UIDragPanelTest_Bounce::bounceToLeftBottomEvent));
dragPanel->addBounceToLeftTopEvent(this, coco_DragPanel_BounceToLeftTop_selector(UIDragPanelTest_Bounce::bounceToLeftTopEvent));
dragPanel->addBounceToRightBottomEvent(this, coco_DragPanel_BounceToRightBottom_selector(UIDragPanelTest_Bounce::bounceToRightBottomEvent));
dragPanel->addBounceToRightTopEvent(this, coco_DragPanel_BounceToRightTop_selector(UIDragPanelTest_Bounce::bounceToRightTopEvent));
dragPanel->addBounceToLeftEvent(this, coco_DragPanel_BounceToLeft_selector(UIDragPanelTest_Bounce::bounceToLeftEvent));
dragPanel->addBounceToTopEvent(this, coco_DragPanel_BounceToTop_selector(UIDragPanelTest_Bounce::bounceToTopEvent));
dragPanel->addBounceToRightEvent(this, coco_DragPanel_BounceToRight_selector(UIDragPanelTest_Bounce::bounceToRightEvent));
dragPanel->addBounceToBottomEvent(this, coco_DragPanel_BounceToBottom_selector(UIDragPanelTest_Bounce::bounceToBottomEvent));
dragPanel->addEventListener(this, dragpaneleventselector(UIDragPanelTest_Bounce::dragPanelEvent));
UIImageView* imageView = UIImageView::create();
imageView->setTouchEnabled(true);
@ -197,42 +184,43 @@ bool UIDragPanelTest_Bounce::init()
return false;
}
void UIDragPanelTest_Bounce::bounceToLeftBottomEvent(Object *pSender)
void UIDragPanelTest_Bounce::dragPanelEvent(Object *pSender, DragPanelEventType type)
{
switch (type)
{
case DRAGPANEL_EVENT_BOUNCE_LEFTBOTTOM:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left Bottom")->getCString());
}
break;
void UIDragPanelTest_Bounce::bounceToLeftTopEvent(Object *pSender)
{
case DRAGPANEL_EVENT_BOUNCE_LEFTTOP:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left Top")->getCString());
}
break;
void UIDragPanelTest_Bounce::bounceToRightBottomEvent(Object *pSender)
{
case DRAGPANEL_EVENT_BOUNCE_RIGHTBOTTOM:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right Bottom")->getCString());
}
break;
void UIDragPanelTest_Bounce::bounceToRightTopEvent(Object *pSender)
{
case DRAGPANEL_EVENT_BOUNCE_RIGHTTOP:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right Top")->getCString());
}
break;
void UIDragPanelTest_Bounce::bounceToLeftEvent(Object *pSender)
{
case DRAGPANEL_EVENT_BOUNCE_LEFT:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Left")->getCString());
}
break;
void UIDragPanelTest_Bounce::bounceToTopEvent(Object *pSender)
{
case DRAGPANEL_EVENT_BOUNCE_TOP:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Top")->getCString());
}
break;
void UIDragPanelTest_Bounce::bounceToRightEvent(Object *pSender)
{
case DRAGPANEL_EVENT_BOUNCE_RIGHT:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Right")->getCString());
}
break;
void UIDragPanelTest_Bounce::bounceToBottomEvent(Object *pSender)
{
case DRAGPANEL_EVENT_BOUNCE_BOTTOM:
m_pDisplayValueLabel->setText(CCString::createWithFormat("Bounce To Bottom")->getCString());
break;
default:
break;
}
}

View File

@ -33,14 +33,7 @@ public:
UIDragPanelTest();
~UIDragPanelTest();
bool init();
void berthToLeftBottomEvent(Object* pSender);
void berthToLeftTopEvent(Object* pSender);
void berthToRightBottomEvent(Object* pSender);
void berthToRightTopEvent(Object* pSender);
void berthToLeftEvent(Object* pSender);
void berthToTopEvent(Object* pSender);
void berthToRightEvent(Object* pSender);
void berthToBottomEvent(Object* pSender);
void dragPanelEvent(Object* pSender, DragPanelEventType type);
protected:
UI_SCENE_CREATE_FUNC(UIDragPanelTest)
@ -53,14 +46,7 @@ public:
UIDragPanelTest_Bounce();
~UIDragPanelTest_Bounce();
bool init();
void bounceToLeftBottomEvent(Object* pSender);
void bounceToRightBottomEvent(Object* pSender);
void bounceToLeftTopEvent(Object* pSender);
void bounceToRightTopEvent(Object* pSender);
void bounceToLeftEvent(Object* pSender);
void bounceToTopEvent(Object* pSender);
void bounceToRightEvent(Object* pSender);
void bounceToBottomEvent(Object* pSender);
void dragPanelEvent(Object* pSender, DragPanelEventType type);
protected:
UI_SCENE_CREATE_FUNC(UIDragPanelTest_Bounce)

View File

@ -90,8 +90,7 @@ bool UIListViewTest_Vertical::init()
listView->addChild(layout);
}
listView->addInitChildEvent(this, coco_ListView_InitChild_selector(UIListViewTest_Vertical::initChildEvent));
listView->addUpdateChildEvent(this, coco_ListView_UpdateChild_selector(UIListViewTest_Vertical::updateChildEvent));
listView->addEventListenter(this, listvieweventselector(UIListViewTest_Vertical::listViewEvent));
listView->initChildWithDataLength(m_array->count());
m_pUiLayer->addWidget(listView);
@ -101,8 +100,12 @@ bool UIListViewTest_Vertical::init()
return false;
}
void UIListViewTest_Vertical::initChildEvent(Object *pSender)
void UIListViewTest_Vertical::listViewEvent(Object *pSender, ListViewEventType type)
{
switch (type)
{
case LISTVIEW_EVENT_INIT_CHILD:
{
String* ccstr = static_cast<String*>(m_array->getObjectAtIndex(m_nCount));
UIListView* list = dynamic_cast<UIListView*>(pSender);
@ -111,10 +114,11 @@ void UIListViewTest_Vertical::initChildEvent(Object *pSender)
textButton->setTitleText(ccstr->getCString());
m_nCount++;
}
}
break;
void UIListViewTest_Vertical::updateChildEvent(Object *pSender)
{
case LISTVIEW_EVENT_UPDATE_CHILD:
{
UIListView* list = dynamic_cast<UIListView*>(pSender);
int index = list->getUpdateDataIndex();
@ -128,6 +132,12 @@ void UIListViewTest_Vertical::updateChildEvent(Object *pSender)
UIButton* textButton = dynamic_cast<UIButton*>(layout->getChildByName("TextButton"));
textButton->setTitleText(ccstr->getCString());
list->setUpdateSuccess(true);
}
break;
default:
break;
}
}
// UIListViewTest_Horizontal
@ -211,8 +221,7 @@ bool UIListViewTest_Horizontal::init()
listView->addChild(layout);
}
listView->addInitChildEvent(this, coco_ListView_InitChild_selector(UIListViewTest_Horizontal::initChildEvent));
listView->addUpdateChildEvent(this, coco_ListView_UpdateChild_selector(UIListViewTest_Horizontal::updateChildEvent));
listView->addEventListenter(this, listvieweventselector(UIListViewTest_Horizontal::listViewEvent));
listView->initChildWithDataLength(m_array->count());
m_pUiLayer->addWidget(listView);
@ -222,8 +231,12 @@ bool UIListViewTest_Horizontal::init()
return false;
}
void UIListViewTest_Horizontal::initChildEvent(Object *pSender)
void UIListViewTest_Horizontal::listViewEvent(Object *pSender, ListViewEventType type)
{
switch (type)
{
case LISTVIEW_EVENT_INIT_CHILD:
{
String* ccstr = static_cast<String*>(m_array->getObjectAtIndex(m_nCount));
UIListView* list = dynamic_cast<UIListView*>(pSender);
@ -232,10 +245,11 @@ void UIListViewTest_Horizontal::initChildEvent(Object *pSender)
textButton->setTitleText(ccstr->getCString());
m_nCount++;
}
}
break;
void UIListViewTest_Horizontal::updateChildEvent(Object *pSender)
{
case LISTVIEW_EVENT_UPDATE_CHILD:
{
UIListView* list = dynamic_cast<UIListView*>(pSender);
int index = list->getUpdateDataIndex();
@ -249,4 +263,10 @@ void UIListViewTest_Horizontal::updateChildEvent(Object *pSender)
UIButton* textButton = dynamic_cast<UIButton*>(layout->getChildByName("TextButton"));
textButton->setTitleText(ccstr->getCString());
list->setUpdateSuccess(true);
}
break;
default:
break;
}
}

View File

@ -33,8 +33,7 @@ public:
UIListViewTest_Vertical();
~UIListViewTest_Vertical();
bool init();
void initChildEvent(Object* pSender);
void updateChildEvent(Object* pSender);
void listViewEvent(Object* pSender, ListViewEventType type);
protected:
UI_SCENE_CREATE_FUNC(UIListViewTest_Vertical)
@ -50,8 +49,7 @@ public:
UIListViewTest_Horizontal();
~UIListViewTest_Horizontal();
bool init();
void initChildEvent(Object* pSender);
void updateChildEvent(Object* pSender);
void listViewEvent(Object* pSender, ListViewEventType type);
protected:
UI_SCENE_CREATE_FUNC(UIListViewTest_Horizontal)

View File

@ -79,8 +79,7 @@ bool UIPageViewTest::init()
pageView->addPage(layout);
}
pageView->addPageTurningEvent(this, coco_PageView_PageTurning_selector(UIPageViewTest::pageTurningEvent));
pageView->addEventListener(this, pagevieweventselector(UIPageViewTest::pageViewEvent));
m_pUiLayer->addWidget(pageView);
@ -89,10 +88,19 @@ bool UIPageViewTest::init()
return false;
}
void UIPageViewTest::pageTurningEvent(Object *pSender)
void UIPageViewTest::pageViewEvent(Object *pSender, PageViewEventType type)
{
switch (type)
{
case PAGEVIEW_EVENT_TURNING:
{
UIPageView* pageView = dynamic_cast<UIPageView*>(pSender);
CCLOG("page = %d", pageView->getCurPageIndex());
m_pDisplayValueLabel->setText(CCString::createWithFormat("page = %d", pageView->getCurPageIndex() + 1)->getCString());
}
break;
default:
break;
}
}

View File

@ -34,7 +34,7 @@ public:
~UIPageViewTest();
bool init();
void pageTurningEvent(Object* pSender);
void pageViewEvent(Object* pSender, PageViewEventType type);
protected:
UI_SCENE_CREATE_FUNC(UIPageViewTest)

View File

@ -2,6 +2,7 @@
#include "cocos-ext.h"
#include "UIScene.h"
#include "UISceneManager.h"
#include "../ExtensionsTest.h"
UIScene::UIScene()
: m_pSceneTitle(NULL)
@ -40,13 +41,16 @@ bool UIScene::init()
UIButton *right_button = dynamic_cast<UIButton*>(m_pUiLayer->getWidgetByName("right_Button"));
right_button->addTouchEventListener(this, toucheventselector(UIScene::nextCallback));
// exit button
UIButton* exit_button = UIButton::create();
exit_button->setTouchEnabled(true);
exit_button->loadTextures("CloseNormal.png", "CloseSelected.png", "");
exit_button->setPosition(Point(m_pUiLayer->getContentSize().width - exit_button->getContentSize().width, exit_button->getContentSize().height));
exit_button->addTouchEventListener(this, toucheventselector(UIScene::menuCloseCallback));
m_pUiLayer->addWidget(exit_button);
UILabel* mainMenuLabel = UILabel::create();
mainMenuLabel->setText("MainMenu");
mainMenuLabel->setFontSize(20);
mainMenuLabel->setTouchScaleChangeEnabled(true);
mainMenuLabel->setPosition(Point(430,30));
mainMenuLabel->setTouchEnabled(true);
mainMenuLabel->addTouchEventListener(this, toucheventselector(UIScene::menuCloseCallback));
m_pUiLayer->addWidget(mainMenuLabel);
return true;
}
@ -57,12 +61,10 @@ void UIScene::menuCloseCallback(Object* pSender, TouchEventType type)
{
if (type == TOUCH_EVENT_ENDED)
{
CCDirector::getInstance()->end();
auto scene = new ExtensionsTestScene();
scene->runThisTest();
scene->release();
}
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}
void UIScene::previousCallback(Object* sender, TouchEventType type)

View File

@ -52,7 +52,7 @@ bool UISliderTest::init()
slider->loadSlidBallTextures("cocosgui/sliderThumb.png", "cocosgui/sliderThumb.png", "");
slider->loadProgressBarTexture("cocosgui/sliderProgress.png");
slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
slider->addPercentEvent(this, sliderpercentchangedselector(UISliderTest::percentChangedEvent));
slider->addEventListener(this, sliderpercentchangedselector(UISliderTest::percentChangedEvent));
m_pUiLayer->addWidget(slider);
return true;
@ -116,7 +116,7 @@ bool UISliderTest_Scale9::init()
slider->setCapInsets(Rect(0, 0, 0, 0));
slider->setSize(Size(250, 10));
slider->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
slider->addPercentEvent(this, sliderpercentchangedselector(UISliderTest_Scale9::percentChangedEvent));
slider->addEventListener(this, sliderpercentchangedselector(UISliderTest_Scale9::percentChangedEvent));
m_pUiLayer->addWidget(slider);
return true;

View File

@ -51,10 +51,7 @@ bool UITextFieldTest::init()
textField->setFontSize(30);
textField->setPlaceHolder("input words here");
textField->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
textField->addAttachWithIMEEvent(this, coco_TextField_AttachWithIME_selector(UITextFieldTest::attachWithIMEEvent));
textField->addDetachWithIMEEvent(this, coco_TextField_DetachWithIME_selector(UITextFieldTest::detachWithIMEEvent));
textField->addInsertTextEvent(this, coco_TextField_InsertText_selector(UITextFieldTest::insertTextEvent));
textField->addDeleteBackwardEvent(this, coco_TextField_DeleteBackward_selector(UITextFieldTest::deleteBackwardEvent));
textField->addEventListener(this, textfieldeventselector(UITextFieldTest::textFieldEvent));
m_pUiLayer->addWidget(textField);
return true;
@ -62,31 +59,40 @@ bool UITextFieldTest::init()
return false;
}
void UITextFieldTest::attachWithIMEEvent(Object *pSender)
void UITextFieldTest::textFieldEvent(Object *pSender, TextFiledEventType type)
{
switch (type)
{
case TEXTFIELD_EVENT_ATTACH_WITH_IME:
{
UITextField* textField = dynamic_cast<UITextField*>(pSender);
Size screenSize = CCDirector::getInstance()->getWinSize();
textField->runAction(CCMoveTo::create(0.225,
Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2)));
m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME")->getCString());
}
}
break;
void UITextFieldTest::detachWithIMEEvent(Object* pSender)
{
case TEXTFIELD_EVENT_DETACH_WITH_IME:
{
UITextField* textField = dynamic_cast<UITextField*>(pSender);
Size screenSize = CCDirector::getInstance()->getWinSize();
textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f)));
m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME")->getCString());
}
}
break;
void UITextFieldTest::insertTextEvent(Object *pSender)
{
case TEXTFIELD_EVENT_INDERT_TEXT:
m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words")->getCString());
}
break;
void UITextFieldTest::deleteBackwardEvent(Object *pSender)
{
case TEXTFIELD_EVENT_DELETE_BACKWARD:
m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word")->getCString());
break;
default:
break;
}
}
// UITextFieldTest_MaxLength
@ -133,10 +139,7 @@ bool UITextFieldTest_MaxLength::init()
textField->setFontSize(30);
textField->setPlaceHolder("input words here");
textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
textField->addAttachWithIMEEvent(this, coco_TextField_AttachWithIME_selector(UITextFieldTest_MaxLength::attachWithIMEEvent));
textField->addDetachWithIMEEvent(this, coco_TextField_DetachWithIME_selector(UITextFieldTest_MaxLength::detachWithIMEEvent));
textField->addInsertTextEvent(this, coco_TextField_InsertText_selector(UITextFieldTest_MaxLength::insertTextEvent));
textField->addDeleteBackwardEvent(this, coco_TextField_DeleteBackward_selector(UITextFieldTest_MaxLength::deleteBackwardEvent));
textField->addEventListener(this, textfieldeventselector(UITextFieldTest_MaxLength::textFieldEvent));
m_pUiLayer->addWidget(textField);
return true;
@ -144,33 +147,46 @@ bool UITextFieldTest_MaxLength::init()
return false;
}
void UITextFieldTest_MaxLength::attachWithIMEEvent(Object *pSender)
void UITextFieldTest_MaxLength::textFieldEvent(Object *pSender, TextFiledEventType type)
{
switch (type)
{
case TEXTFIELD_EVENT_ATTACH_WITH_IME:
{
UITextField* textField = dynamic_cast<UITextField*>(pSender);
Size screenSize = CCDirector::getInstance()->getWinSize();
textField->runAction(CCMoveTo::create(0.225,
Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2)));
m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME max length %d", textField->getMaxLength())->getCString());
}
}
break;
void UITextFieldTest_MaxLength::detachWithIMEEvent(Object* pSender)
{
case TEXTFIELD_EVENT_DETACH_WITH_IME:
{
UITextField* textField = dynamic_cast<UITextField*>(pSender);
Size screenSize = CCDirector::getInstance()->getWinSize();
textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f)));
m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME max length %d", textField->getMaxLength())->getCString());
}
}
break;
void UITextFieldTest_MaxLength::insertTextEvent(Object *pSender)
{
case TEXTFIELD_EVENT_INDERT_TEXT:
{
UITextField* textField = dynamic_cast<UITextField*>(pSender);
m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words max length %d", textField->getMaxLength())->getCString());
}
}
break;
void UITextFieldTest_MaxLength::deleteBackwardEvent(Object *pSender)
{
case TEXTFIELD_EVENT_DELETE_BACKWARD:
{
UITextField* textField = dynamic_cast<UITextField*>(pSender);
m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word max length %d", textField->getMaxLength())->getCString());
}
break;
default:
break;
}
}
// UITextFieldTest_Password
@ -217,10 +233,7 @@ bool UITextFieldTest_Password::init()
textField->setFontSize(30);
textField->setPlaceHolder("input password here");
textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
textField->addAttachWithIMEEvent(this, coco_TextField_AttachWithIME_selector(UITextFieldTest_Password::attachWithIMEEvent));
textField->addDetachWithIMEEvent(this, coco_TextField_DetachWithIME_selector(UITextFieldTest_Password::detachWithIMEEvent));
textField->addInsertTextEvent(this, coco_TextField_InsertText_selector(UITextFieldTest_Password::insertTextEvent));
textField->addDeleteBackwardEvent(this, coco_TextField_DeleteBackward_selector(UITextFieldTest_Password::deleteBackwardEvent));
textField->addEventListener(this, textfieldeventselector(UITextFieldTest_Password::textFieldEvent));
m_pUiLayer->addWidget(textField);
return true;
@ -228,29 +241,38 @@ bool UITextFieldTest_Password::init()
return false;
}
void UITextFieldTest_Password::attachWithIMEEvent(Object *pSender)
void UITextFieldTest_Password::textFieldEvent(Object *pSender, TextFiledEventType type)
{
switch (type)
{
case TEXTFIELD_EVENT_ATTACH_WITH_IME:
{
UITextField* textField = dynamic_cast<UITextField*>(pSender);
Size screenSize = CCDirector::getInstance()->getWinSize();
textField->runAction(CCMoveTo::create(0.225,
Point(screenSize.width / 2.0f, screenSize.height / 2.0f + textField->getContentSize().height / 2)));
m_pDisplayValueLabel->setText(CCString::createWithFormat("attach with IME password")->getCString());
}
}
break;
void UITextFieldTest_Password::detachWithIMEEvent(Object* pSender)
{
case TEXTFIELD_EVENT_DETACH_WITH_IME:
{
UITextField* textField = dynamic_cast<UITextField*>(pSender);
Size screenSize = CCDirector::getInstance()->getWinSize();
textField->runAction(CCMoveTo::create(0.175, Point(screenSize.width / 2.0f, screenSize.height / 2.0f)));
m_pDisplayValueLabel->setText(CCString::createWithFormat("detach with IME password")->getCString());
}
}
break;
void UITextFieldTest_Password::insertTextEvent(Object *pSender)
{
case TEXTFIELD_EVENT_INDERT_TEXT:
m_pDisplayValueLabel->setText(CCString::createWithFormat("insert words password")->getCString());
}
break;
void UITextFieldTest_Password::deleteBackwardEvent(Object *pSender)
{
case TEXTFIELD_EVENT_DELETE_BACKWARD:
m_pDisplayValueLabel->setText(CCString::createWithFormat("delete word password")->getCString());
break;
default:
break;
}
}

View File

@ -33,10 +33,7 @@ public:
UITextFieldTest();
~UITextFieldTest();
bool init();
void attachWithIMEEvent(Object* pSender);
void detachWithIMEEvent(Object* pSender);
void insertTextEvent(Object* pSender);
void deleteBackwardEvent(Object* pSender);
void textFieldEvent(Object* pSender, TextFiledEventType type);
protected:
UI_SCENE_CREATE_FUNC(UITextFieldTest)
@ -49,10 +46,7 @@ public:
UITextFieldTest_MaxLength();
~UITextFieldTest_MaxLength();
bool init();
void attachWithIMEEvent(Object* pSender);
void detachWithIMEEvent(Object* pSender);
void insertTextEvent(Object* pSender);
void deleteBackwardEvent(Object* pSender);
void textFieldEvent(Object* pSender, TextFiledEventType type);
protected:
UI_SCENE_CREATE_FUNC(UITextFieldTest_MaxLength)
@ -65,10 +59,7 @@ public:
UITextFieldTest_Password();
~UITextFieldTest_Password();
bool init();
void attachWithIMEEvent(Object* pSender);
void detachWithIMEEvent(Object* pSender);
void insertTextEvent(Object* pSender);
void deleteBackwardEvent(Object* pSender);
void textFieldEvent(Object* pSender, TextFiledEventType type);
protected:
UI_SCENE_CREATE_FUNC(UITextFieldTest_Password)