From 204473643cdca7bbaa760dc946e4fa14a3805ef2 Mon Sep 17 00:00:00 2001 From: liushuai <770722922@qq.com> Date: Mon, 25 May 2020 03:16:15 +0800 Subject: [PATCH 1/6] fix: cmake --- libfairygui/CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libfairygui/CMakeLists.txt b/libfairygui/CMakeLists.txt index abe098a..1d7b539 100644 --- a/libfairygui/CMakeLists.txt +++ b/libfairygui/CMakeLists.txt @@ -9,6 +9,7 @@ project(fairygui) # file list set(FAIRYGUI_SRC Classes/GSlider.cpp + Classes/GTree.cpp Classes/GLoader.cpp Classes/GTextInput.cpp Classes/tween/TweenManager.cpp @@ -17,6 +18,7 @@ set(FAIRYGUI_SRC Classes/GSlider.cpp Classes/tween/EaseManager.cpp Classes/tween/TweenPropType.cpp Classes/tween/GTween.cpp + Classes/tween/GPath.cpp Classes/GGroup.cpp Classes/Margin.cpp Classes/Transition.cpp @@ -24,8 +26,7 @@ set(FAIRYGUI_SRC Classes/GSlider.cpp Classes/ScrollPane.cpp Classes/GRoot.cpp Classes/UIPackage.cpp - Classes/treeview/TreeNode.cpp - Classes/treeview/TreeView.cpp + Classes/GTreeNode.cpp Classes/Window.cpp Classes/PackageItem.cpp Classes/GObjectPool.cpp @@ -64,9 +65,11 @@ set(FAIRYGUI_SRC Classes/GSlider.cpp Classes/gears/GearXY.cpp Classes/gears/GearColor.cpp Classes/gears/GearDisplay.cpp + Classes/gears/GearDisplay2.cpp Classes/gears/GearSize.cpp Classes/gears/GearLook.cpp Classes/gears/GearIcon.cpp + Classes/gears/GearFontSize.cpp Classes/GScrollBar.cpp Classes/event/EventContext.cpp Classes/event/UIEventDispatcher.cpp @@ -82,12 +85,14 @@ set(FAIRYGUI_SRC Classes/GSlider.cpp set(FAIRYGUI_HEADER Classes/GTextField.h + Classes/GTree.h Classes/GGroup.h Classes/GList.h Classes/tween/EaseManager.h Classes/tween/TweenManager.h Classes/tween/GTween.h Classes/tween/GTweener.h + Classes/tween/GPath.h Classes/tween/EaseType.h Classes/tween/TweenPropType.h Classes/tween/TweenValue.h @@ -96,8 +101,7 @@ set(FAIRYGUI_HEADER Classes/GTextField.h Classes/RelationItem.h Classes/GScrollBar.h Classes/PopupMenu.h - Classes/treeview/TreeNode.h - Classes/treeview/TreeView.h + Classes/GTreeNode.h Classes/TranslationHelper.h Classes/UIConfig.h Classes/Transition.h @@ -138,12 +142,14 @@ set(FAIRYGUI_HEADER Classes/GTextField.h Classes/gears/GearColor.h Classes/gears/GearIcon.h Classes/gears/GearDisplay.h + Classes/gears/GearDisplay2.h Classes/gears/GearText.h Classes/gears/GearXY.h Classes/gears/GearSize.h Classes/gears/GearBase.h Classes/gears/GearAnimation.h Classes/gears/GearLook.h + Classes/gears/GearFontSize.h Classes/DragDropManager.h Classes/GButton.h Classes/event/HitTest.h From 872276c0870ab9f89923b068fcfeb267cbaca417 Mon Sep 17 00:00:00 2001 From: liushuai <770722922@qq.com> Date: Tue, 26 May 2020 18:11:05 +0800 Subject: [PATCH 2/6] refine: cmake style and disable warning --- libfairygui/CMakeLists.txt | 188 ++++--------------------------------- 1 file changed, 18 insertions(+), 170 deletions(-) diff --git a/libfairygui/CMakeLists.txt b/libfairygui/CMakeLists.txt index 1d7b539..1e0d91c 100644 --- a/libfairygui/CMakeLists.txt +++ b/libfairygui/CMakeLists.txt @@ -6,181 +6,29 @@ endif() project(fairygui) -# file list - -set(FAIRYGUI_SRC Classes/GSlider.cpp - Classes/GTree.cpp - Classes/GLoader.cpp - Classes/GTextInput.cpp - Classes/tween/TweenManager.cpp - Classes/tween/TweenValue.cpp - Classes/tween/GTweener.cpp - Classes/tween/EaseManager.cpp - Classes/tween/TweenPropType.cpp - Classes/tween/GTween.cpp - Classes/tween/GPath.cpp - Classes/GGroup.cpp - Classes/Margin.cpp - Classes/Transition.cpp - Classes/DragDropManager.cpp - Classes/ScrollPane.cpp - Classes/GRoot.cpp - Classes/UIPackage.cpp - Classes/GTreeNode.cpp - Classes/Window.cpp - Classes/PackageItem.cpp - Classes/GObjectPool.cpp - Classes/utils/ByteBuffer.cpp - Classes/utils/WeakPtr.cpp - Classes/utils/UBBParser.cpp - Classes/utils/ToolSet.cpp - Classes/GLabel.cpp - Classes/UIObjectFactory.cpp - Classes/controller_action/ChangePageAction.cpp - Classes/controller_action/ControllerAction.cpp - Classes/controller_action/PlayTransitionAction.cpp - Classes/GObject.cpp - Classes/GComboBox.cpp - Classes/GComponent.cpp - Classes/GRichTextField.cpp - Classes/UIConfig.cpp - Classes/PopupMenu.cpp - Classes/GGraph.cpp - Classes/GTextField.cpp - Classes/GImage.cpp - Classes/display/FUILabel.cpp - Classes/display/BitmapFont.cpp - Classes/display/FUIContainer.cpp - Classes/display/FUIRichText.cpp - Classes/display/FUIInput.cpp - Classes/display/TextFormat.cpp - Classes/display/FUISprite.cpp - Classes/Controller.cpp - Classes/Relations.cpp - Classes/TranslationHelper.cpp - Classes/GProgressBar.cpp - Classes/gears/GearText.cpp - Classes/gears/GearAnimation.cpp - Classes/gears/GearBase.cpp - Classes/gears/GearXY.cpp - Classes/gears/GearColor.cpp - Classes/gears/GearDisplay.cpp - Classes/gears/GearDisplay2.cpp - Classes/gears/GearSize.cpp - Classes/gears/GearLook.cpp - Classes/gears/GearIcon.cpp - Classes/gears/GearFontSize.cpp - Classes/GScrollBar.cpp - Classes/event/EventContext.cpp - Classes/event/UIEventDispatcher.cpp - Classes/event/InputEvent.cpp - Classes/event/InputProcessor.cpp - Classes/event/HitTest.cpp - Classes/GMovieClip.cpp - Classes/GList.cpp - Classes/GButton.cpp - Classes/RelationItem.cpp - ) - - - -set(FAIRYGUI_HEADER Classes/GTextField.h - Classes/GTree.h - Classes/GGroup.h - Classes/GList.h - Classes/tween/EaseManager.h - Classes/tween/TweenManager.h - Classes/tween/GTween.h - Classes/tween/GTweener.h - Classes/tween/GPath.h - Classes/tween/EaseType.h - Classes/tween/TweenPropType.h - Classes/tween/TweenValue.h - Classes/UIPackage.h - Classes/Margin.h - Classes/RelationItem.h - Classes/GScrollBar.h - Classes/PopupMenu.h - Classes/GTreeNode.h - Classes/TranslationHelper.h - Classes/UIConfig.h - Classes/Transition.h - Classes/GRoot.h - Classes/GTextInput.h - Classes/GRichTextField.h - Classes/Relations.h - Classes/Window.h - Classes/UIObjectFactory.h - Classes/GMovieClip.h - Classes/utils/ByteBuffer.h - Classes/utils/ToolSet.h - Classes/utils/UBBParser.h - Classes/utils/WeakPtr.h - Classes/GComponent.h - Classes/FieldTypes.h - Classes/GImage.h - Classes/controller_action/ChangePageAction.h - Classes/controller_action/ControllerAction.h - Classes/controller_action/PlayTransitionAction.h - Classes/Controller.h - Classes/FairyGUI.h - Classes/GLabel.h - Classes/GComboBox.h - Classes/PackageItem.h - Classes/GObjectPool.h - Classes/FairyGUIMacros.h - Classes/GProgressBar.h - Classes/display/TextFormat.h - Classes/display/BitmapFont.h - Classes/display/FUIRichText.h - Classes/display/FUIContainer.h - Classes/display/FUISprite.h - Classes/display/FUILabel.h - Classes/display/FUIInput.h - Classes/GLoader.h - Classes/GSlider.h - Classes/gears/GearColor.h - Classes/gears/GearIcon.h - Classes/gears/GearDisplay.h - Classes/gears/GearDisplay2.h - Classes/gears/GearText.h - Classes/gears/GearXY.h - Classes/gears/GearSize.h - Classes/gears/GearBase.h - Classes/gears/GearAnimation.h - Classes/gears/GearLook.h - Classes/gears/GearFontSize.h - Classes/DragDropManager.h - Classes/GButton.h - Classes/event/HitTest.h - Classes/event/UIEventType.h - Classes/event/EventContext.h - Classes/event/InputProcessor.h - Classes/event/InputEvent.h - Classes/event/UIEventDispatcher.h - Classes/GGraph.h - Classes/GObject.h - Classes/ScrollPane.h - ) - -list(APPEND FAIRYGUI_SRC ${FAIRYGUI_HEADER}) - -include_directories( - ${COCOS2DX_ROOT_PATH}/cocos/audio/include/ -) - +if(MSVC) + add_compile_options(/w) +else() + add_compile_options(-w) +endif() -add_library(fairygui ${FAIRYGUI_SRC}) +# file list +file(GLOB FAIRYGUI_SRC + Classes/*.c* + Classes/controller_action/*.c* + Classes/display/*.c* + Classes/event/*.c* + Classes/gears/*.c* + Classes/tween/*.c* + Classes/utils/*.c* + ) -target_link_libraries( - fairygui - PRIVATE - cocos2d -) +add_library(${PROJECT_NAME} ${FAIRYGUI_SRC}) +target_link_libraries(${PROJECT_NAME} PRIVATE cocos2d) -target_include_directories(fairygui +target_include_directories(${PROJECT_NAME} PUBLIC $ ) From baa93d29351c881903fe34d58f572bdd0ad6b459 Mon Sep 17 00:00:00 2001 From: liushuai <770722922@qq.com> Date: Tue, 26 May 2020 18:11:48 +0800 Subject: [PATCH 3/6] feature: refine code --- libfairygui/Classes/event/UIEventDispatcher.cpp | 14 ++------------ libfairygui/Classes/event/UIEventDispatcher.h | 12 +++++------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/libfairygui/Classes/event/UIEventDispatcher.cpp b/libfairygui/Classes/event/UIEventDispatcher.cpp index fada36a..34de1be 100644 --- a/libfairygui/Classes/event/UIEventDispatcher.cpp +++ b/libfairygui/Classes/event/UIEventDispatcher.cpp @@ -41,7 +41,7 @@ EventTag & EventTag::operator=(const EventTag & other) return *this; } -EventTag & EventTag::operator=(EventTag && other) +EventTag & EventTag::operator=(EventTag && other) noexcept { if (this != &other) { @@ -63,21 +63,11 @@ EventTag & EventTag::operator=(int v) return *this; } -bool EventTag::operator!=(const EventTag & v) -{ - return _value != v._value; -} - bool EventTag::operator!=(const EventTag & v) const { return _value != v._value; } -bool EventTag::operator==(const EventTag & v) -{ - return _value == v._value; -} - bool EventTag::operator==(const EventTag & v) const { return _value == v._value; @@ -282,4 +272,4 @@ void UIEventDispatcher::doBubble(int eventType, EventContext* context) p->doBubble(eventType, context); } -NS_FGUI_END \ No newline at end of file +NS_FGUI_END diff --git a/libfairygui/Classes/event/UIEventDispatcher.h b/libfairygui/Classes/event/UIEventDispatcher.h index 3db5228..bb71548 100644 --- a/libfairygui/Classes/event/UIEventDispatcher.h +++ b/libfairygui/Classes/event/UIEventDispatcher.h @@ -16,20 +16,18 @@ class EventTag static const EventTag None; EventTag(); - explicit EventTag(void* ptr); - explicit EventTag(int value); - explicit EventTag(const EventTag& other); - explicit EventTag(EventTag&& other); + EventTag(void* ptr); + EventTag(int value); + EventTag(const EventTag& other); + EventTag(EventTag&& other); ~EventTag(); EventTag& operator= (const EventTag& other); - EventTag& operator= (EventTag&& other); + EventTag& operator= (EventTag&& other) noexcept; EventTag& operator= (void* ptr); EventTag& operator= (int v); - bool operator!= (const EventTag& v); bool operator!= (const EventTag& v) const; - bool operator== (const EventTag& v); bool operator== (const EventTag& v) const; bool isNone() const { return _value == 0; } From d858bf9fc6c531b7c784b9b3994dfa642f8ced51 Mon Sep 17 00:00:00 2001 From: liushuai <770722922@qq.com> Date: Wed, 27 May 2020 18:37:24 +0800 Subject: [PATCH 4/6] feature: support keyboard type --- libfairygui/Classes/display/FUIInput.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libfairygui/Classes/display/FUIInput.cpp b/libfairygui/Classes/display/FUIInput.cpp index 47deaa0..d952078 100644 --- a/libfairygui/Classes/display/FUIInput.cpp +++ b/libfairygui/Classes/display/FUIInput.cpp @@ -72,8 +72,8 @@ void FUIInput::setPassword(bool value) void FUIInput::setKeyboardType(int value) { - //if (!_password) - //setInputMode((ui::EditBox::InputMode)value); + if (!_password) + setInputMode((ui::EditBox::InputMode)value); } void FUIInput::openKeyboard() From 61fc6f34dc1bd8b7029d0cc9c00a234237af228d Mon Sep 17 00:00:00 2001 From: liushuai <770722922@qq.com> Date: Wed, 27 May 2020 19:56:22 +0800 Subject: [PATCH 5/6] feature: dispatch Submit on editbox return --- libfairygui/Classes/GTextInput.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libfairygui/Classes/GTextInput.cpp b/libfairygui/Classes/GTextInput.cpp index c5ee9cd..61032d3 100644 --- a/libfairygui/Classes/GTextInput.cpp +++ b/libfairygui/Classes/GTextInput.cpp @@ -117,9 +117,7 @@ void GTextInput::setTextFieldText() void GTextInput::editBoxReturn(cocos2d::ui::EditBox * editBox) { - //found that this will trigger even when focus is lost - //if (isSingleLine()) - // dispatchEvent(UIEventType::Submit); + dispatchEvent(UIEventType::Submit); } void GTextInput::editBoxTextChanged(cocos2d::ui::EditBox* editBox, const std::string& text) From 201bab42d0cf5d3661a7257069c369dda81894ee Mon Sep 17 00:00:00 2001 From: liushuai <770722922@qq.com> Date: Fri, 29 May 2020 22:16:29 +0800 Subject: [PATCH 6/6] feature: fix warning --- libfairygui/Classes/GButton.cpp | 4 ++-- libfairygui/Classes/GButton.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libfairygui/Classes/GButton.cpp b/libfairygui/Classes/GButton.cpp index 6e9b09f..dfba686 100644 --- a/libfairygui/Classes/GButton.cpp +++ b/libfairygui/Classes/GButton.cpp @@ -294,7 +294,7 @@ void GButton::constructExtension(ByteBuffer* buffer) addEventListener(UIEventType::TouchBegin, CC_CALLBACK_1(GButton::onTouchBegin, this)); addEventListener(UIEventType::TouchEnd, CC_CALLBACK_1(GButton::onTouchEnd, this)); addEventListener(UIEventType::Click, CC_CALLBACK_1(GButton::onClick, this)); - addEventListener(UIEventType::Exit, CC_CALLBACK_1(GButton::onExit, this)); + addEventListener(UIEventType::Exit, CC_CALLBACK_1(GButton::onExit2, this)); } void GButton::setup_afterAdd(ByteBuffer* buffer, int beginPos) @@ -444,7 +444,7 @@ void GButton::onClick(EventContext* context) } } -void GButton::onExit(EventContext* context) +void GButton::onExit2(EventContext* context) { if (_over) onRollOut(context); diff --git a/libfairygui/Classes/GButton.h b/libfairygui/Classes/GButton.h index e14876b..b76fe46 100644 --- a/libfairygui/Classes/GButton.h +++ b/libfairygui/Classes/GButton.h @@ -73,7 +73,7 @@ class GButton : public GComponent void onTouchBegin(EventContext* context); void onTouchEnd(EventContext* context); void onClick(EventContext* context); - void onExit(EventContext* context); + void onExit2(EventContext* context); ButtonMode _mode; GObject* _titleObject;