mirror of https://github.com/axmolengine/axmol.git
commit
c75466f555
40
AUTHORS
40
AUTHORS
|
@ -49,12 +49,20 @@ Developers:
|
||||||
Asynchronous Image loading for Emscripten
|
Asynchronous Image loading for Emscripten
|
||||||
|
|
||||||
DarraghCoy
|
DarraghCoy
|
||||||
Fix a potential crash SimpleAudioEngineOpenSL::playEffect
|
Fixed a potential crash SimpleAudioEngineOpenSL::playEffect
|
||||||
Fix some bugs with Set class
|
Fixed some bugs with Set class
|
||||||
Add ccDrawSolidCircle
|
Added ccDrawSolidCircle
|
||||||
Add Rect::unionWithRect
|
Added Rect::unionWithRect
|
||||||
Fix a memory leak in Set::removeAllObjects.
|
Fixed a memory leak in Set::removeAllObjects
|
||||||
Fixed potential crashes in event dispatch while using SceneGraphPriroity listeners and added helper function to check it
|
Fixed for unaligned memory access crash in CCBReader::readFloat()
|
||||||
|
Fixed for loading custom fonts on iOS when referenced from a CCB file
|
||||||
|
Fixed CCUserDefault.cpp compiling on Android.
|
||||||
|
Fixed CCFileUtils 'createXXXXWithContentsOfFile' path lookup issue
|
||||||
|
Added CCDirector::popToSceneStackLevel(int level)
|
||||||
|
Fixed a bug that custom font can't be loaded correctly if using full path of filename on android
|
||||||
|
Fixed potential crashes in EventDispatch while using SceneGraphPriroity listeners and added helper function to check it
|
||||||
|
Fixed a protential crash in EventDispatch while unregistering listener right after it was registered
|
||||||
|
Adding an extra verification in Node's destructor
|
||||||
|
|
||||||
silverscania
|
silverscania
|
||||||
Pass correct parameter to glPixelStorei when creating a texture
|
Pass correct parameter to glPixelStorei when creating a texture
|
||||||
|
@ -116,13 +124,6 @@ Developers:
|
||||||
Jimmy Sambuo
|
Jimmy Sambuo
|
||||||
fix the bug that SimpleAudioEngine::playEffect() and playBackgroundMusic() play twice on linux
|
fix the bug that SimpleAudioEngine::playEffect() and playBackgroundMusic() play twice on linux
|
||||||
|
|
||||||
DarraghCoy
|
|
||||||
fix for loading custom fonts on iOS when referenced from a CCB file
|
|
||||||
Fix CCUserDefault.cpp compiling on Android.
|
|
||||||
Fixing CCFileUtils 'createXXXXWithContentsOfFile' path lookup issue.
|
|
||||||
Add CCDirector::popToSceneStackLevel(int level).
|
|
||||||
Fixing a bug that custom font can't be loaded correctly if using full path of filename on android.
|
|
||||||
|
|
||||||
Waiter
|
Waiter
|
||||||
fix an error that OpenSLEngine can't load resources from SD card
|
fix an error that OpenSLEngine can't load resources from SD card
|
||||||
add CCRemoveSelf action
|
add CCRemoveSelf action
|
||||||
|
@ -349,9 +350,6 @@ Developers:
|
||||||
Fixing a logical error in CCDrawNode::drawPolygon.
|
Fixing a logical error in CCDrawNode::drawPolygon.
|
||||||
Fixing a bug that Jsb function getCPBody return type is not right.
|
Fixing a bug that Jsb function getCPBody return type is not right.
|
||||||
|
|
||||||
DarraghCoy
|
|
||||||
Fix for unaligned memory access crash in CCBReader::readFloat().
|
|
||||||
|
|
||||||
Sergej Tatarincev (SevInf)
|
Sergej Tatarincev (SevInf)
|
||||||
Making ScriptingCore.cpp compiled fine with C++11 on iOS.
|
Making ScriptingCore.cpp compiled fine with C++11 on iOS.
|
||||||
Using shared NodeLoaderLibrary in CCBReader bindings.
|
Using shared NodeLoaderLibrary in CCBReader bindings.
|
||||||
|
@ -801,6 +799,16 @@ Developers:
|
||||||
|
|
||||||
zukkun
|
zukkun
|
||||||
Fixed incorrect function invocation in PhysicsBody::setAngularVelocityLimit
|
Fixed incorrect function invocation in PhysicsBody::setAngularVelocityLimit
|
||||||
|
|
||||||
|
dbaack
|
||||||
|
Fixed a bug that removing and re-adding an event listener will trigger assert
|
||||||
|
|
||||||
|
zakmandhro
|
||||||
|
A typo fix in RELEASE_NOTES.md
|
||||||
|
|
||||||
|
mgcL
|
||||||
|
A potential memory leak fix in value's default constructor
|
||||||
|
Added ScriptHandlerMgr::destroyInstance to avoid memory leak
|
||||||
|
|
||||||
Retired Core Developers:
|
Retired Core Developers:
|
||||||
WenSheng Yang
|
WenSheng Yang
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
95d810c2ae2b7e8792a1557f75ee452b54d2e49e
|
b78af2958c35d67fd0d06f1ca9fd7fce58799235
|
|
@ -393,7 +393,10 @@ void Director::setOpenGLView(GLView *openGLView)
|
||||||
|
|
||||||
CHECK_GL_ERROR_DEBUG();
|
CHECK_GL_ERROR_DEBUG();
|
||||||
|
|
||||||
// _touchDispatcher->setDispatchEvents(true);
|
if (_eventDispatcher)
|
||||||
|
{
|
||||||
|
_eventDispatcher->setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,9 +750,11 @@ void Director::purgeDirector()
|
||||||
// cleanup scheduler
|
// cleanup scheduler
|
||||||
getScheduler()->unscheduleAll();
|
getScheduler()->unscheduleAll();
|
||||||
|
|
||||||
// don't release the event handlers
|
// Disable event dispatching
|
||||||
// They are needed in case the director is run again
|
if (_eventDispatcher)
|
||||||
// _touchDispatcher->removeAllDelegates();
|
{
|
||||||
|
_eventDispatcher->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (_runningScene)
|
if (_runningScene)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "CCEventListenerKeyboard.h"
|
#include "CCEventListenerKeyboard.h"
|
||||||
#include "CCEventListenerCustom.h"
|
#include "CCEventListenerCustom.h"
|
||||||
|
|
||||||
#include "CCNode.h"
|
#include "CCScene.h"
|
||||||
#include "CCDirector.h"
|
#include "CCDirector.h"
|
||||||
#include "CCEventType.h"
|
#include "CCEventType.h"
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ void EventDispatcher::EventListenerVector::clear()
|
||||||
|
|
||||||
EventDispatcher::EventDispatcher()
|
EventDispatcher::EventDispatcher()
|
||||||
: _inDispatch(0)
|
: _inDispatch(0)
|
||||||
, _isEnabled(true)
|
, _isEnabled(false)
|
||||||
, _nodePriorityIndex(0)
|
, _nodePriorityIndex(0)
|
||||||
{
|
{
|
||||||
_toAddedListeners.reserve(50);
|
_toAddedListeners.reserve(50);
|
||||||
|
@ -340,6 +340,27 @@ void EventDispatcher::removeEventListenersForTarget(Node* target, bool recursive
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bug fix: ensure there are no references to the node in the list of listeners to be added.
|
||||||
|
// If we find any listeners associated with the destroyed node in this list then remove them.
|
||||||
|
// This is to catch the scenario where the node gets destroyed before it's listener
|
||||||
|
// is added into the event dispatcher fully. This could happen if a node registers a listener
|
||||||
|
// and gets destroyed while we are dispatching an event (touch etc.)
|
||||||
|
for (auto iter = _toAddedListeners.begin(); iter != _toAddedListeners.end(); )
|
||||||
|
{
|
||||||
|
EventListener * listener = *iter;
|
||||||
|
|
||||||
|
if (listener->getSceneGraphPriority() == target)
|
||||||
|
{
|
||||||
|
listener->setRegistered(false);
|
||||||
|
listener->release();
|
||||||
|
iter = _toAddedListeners.erase(iter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (recursive)
|
if (recursive)
|
||||||
{
|
{
|
||||||
const auto& children = target->getChildren();
|
const auto& children = target->getChildren();
|
||||||
|
@ -637,6 +658,7 @@ void EventDispatcher::removeEventListener(EventListener* listener)
|
||||||
{
|
{
|
||||||
if (*iter == listener)
|
if (*iter == listener)
|
||||||
{
|
{
|
||||||
|
listener->setRegistered(false);
|
||||||
listener->release();
|
listener->release();
|
||||||
_toAddedListeners.erase(iter);
|
_toAddedListeners.erase(iter);
|
||||||
break;
|
break;
|
||||||
|
@ -1103,6 +1125,9 @@ void EventDispatcher::sortEventListeners(const EventListener::ListenerID& listen
|
||||||
|
|
||||||
if (dirtyFlag != DirtyFlag::NONE)
|
if (dirtyFlag != DirtyFlag::NONE)
|
||||||
{
|
{
|
||||||
|
// Clear the dirty flag first, if `rootNode` is nullptr, then set its dirty flag of scene graph priority
|
||||||
|
dirtyIter->second = DirtyFlag::NONE;
|
||||||
|
|
||||||
if ((int)dirtyFlag & (int)DirtyFlag::FIXED_PRIORITY)
|
if ((int)dirtyFlag & (int)DirtyFlag::FIXED_PRIORITY)
|
||||||
{
|
{
|
||||||
sortEventListenersOfFixedPriority(listenerID);
|
sortEventListenersOfFixedPriority(listenerID);
|
||||||
|
@ -1110,14 +1135,20 @@ void EventDispatcher::sortEventListeners(const EventListener::ListenerID& listen
|
||||||
|
|
||||||
if ((int)dirtyFlag & (int)DirtyFlag::SCENE_GRAPH_PRIORITY)
|
if ((int)dirtyFlag & (int)DirtyFlag::SCENE_GRAPH_PRIORITY)
|
||||||
{
|
{
|
||||||
sortEventListenersOfSceneGraphPriority(listenerID);
|
auto rootNode = Director::getInstance()->getRunningScene();
|
||||||
|
if (rootNode)
|
||||||
|
{
|
||||||
|
sortEventListenersOfSceneGraphPriority(listenerID, rootNode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dirtyIter->second = DirtyFlag::SCENE_GRAPH_PRIORITY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dirtyIter->second = DirtyFlag::NONE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcher::sortEventListenersOfSceneGraphPriority(const EventListener::ListenerID& listenerID)
|
void EventDispatcher::sortEventListenersOfSceneGraphPriority(const EventListener::ListenerID& listenerID, Node* rootNode)
|
||||||
{
|
{
|
||||||
auto listeners = getListeners(listenerID);
|
auto listeners = getListeners(listenerID);
|
||||||
|
|
||||||
|
@ -1127,8 +1158,7 @@ void EventDispatcher::sortEventListenersOfSceneGraphPriority(const EventListener
|
||||||
|
|
||||||
if (sceneGraphListeners == nullptr)
|
if (sceneGraphListeners == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Node* rootNode = (Node*)Director::getInstance()->getRunningScene();
|
|
||||||
// Reset priority index
|
// Reset priority index
|
||||||
_nodePriorityIndex = 0;
|
_nodePriorityIndex = 0;
|
||||||
_nodePriorityMap.clear();
|
_nodePriorityMap.clear();
|
||||||
|
@ -1136,7 +1166,6 @@ void EventDispatcher::sortEventListenersOfSceneGraphPriority(const EventListener
|
||||||
visitTarget(rootNode, true);
|
visitTarget(rootNode, true);
|
||||||
|
|
||||||
// After sort: priority < 0, > 0
|
// After sort: priority < 0, > 0
|
||||||
|
|
||||||
std::sort(sceneGraphListeners->begin(), sceneGraphListeners->end(), [this](const EventListener* l1, const EventListener* l2) {
|
std::sort(sceneGraphListeners->begin(), sceneGraphListeners->end(), [this](const EventListener* l1, const EventListener* l2) {
|
||||||
return _nodePriorityMap[l1->getSceneGraphPriority()] > _nodePriorityMap[l2->getSceneGraphPriority()];
|
return _nodePriorityMap[l1->getSceneGraphPriority()] > _nodePriorityMap[l2->getSceneGraphPriority()];
|
||||||
});
|
});
|
||||||
|
@ -1252,6 +1281,7 @@ void EventDispatcher::removeEventListenersForListenerID(const EventListener::Lis
|
||||||
{
|
{
|
||||||
if ((*iter)->getListenerID() == listenerID)
|
if ((*iter)->getListenerID() == listenerID)
|
||||||
{
|
{
|
||||||
|
(*iter)->setRegistered(false);
|
||||||
(*iter)->release();
|
(*iter)->release();
|
||||||
iter = _toAddedListeners.erase(iter);
|
iter = _toAddedListeners.erase(iter);
|
||||||
}
|
}
|
||||||
|
@ -1328,7 +1358,6 @@ void EventDispatcher::setEnabled(bool isEnabled)
|
||||||
_isEnabled = isEnabled;
|
_isEnabled = isEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EventDispatcher::isEnabled() const
|
bool EventDispatcher::isEnabled() const
|
||||||
{
|
{
|
||||||
return _isEnabled;
|
return _isEnabled;
|
||||||
|
|
|
@ -207,7 +207,7 @@ protected:
|
||||||
void sortEventListeners(const EventListener::ListenerID& listenerID);
|
void sortEventListeners(const EventListener::ListenerID& listenerID);
|
||||||
|
|
||||||
/** Sorts the listeners of specified type by scene graph priority */
|
/** Sorts the listeners of specified type by scene graph priority */
|
||||||
void sortEventListenersOfSceneGraphPriority(const EventListener::ListenerID& listenerID);
|
void sortEventListenersOfSceneGraphPriority(const EventListener::ListenerID& listenerID, Node* rootNode);
|
||||||
|
|
||||||
/** Sorts the listeners of specified type by fixed priority */
|
/** Sorts the listeners of specified type by fixed priority */
|
||||||
void sortEventListenersOfFixedPriority(const EventListener::ListenerID& listenerID);
|
void sortEventListenersOfFixedPriority(const EventListener::ListenerID& listenerID);
|
||||||
|
|
|
@ -184,6 +184,7 @@ Node::~Node()
|
||||||
_eventDispatcher->debugCheckNodeHasNoEventListenersOnDestruction(this);
|
_eventDispatcher->debugCheckNodeHasNoEventListenersOnDestruction(this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
CCASSERT(!_running, "Node still marked as running on node destruction! Was base class onExit() called in derived class onExit() implementations?");
|
||||||
CC_SAFE_RELEASE(_eventDispatcher);
|
CC_SAFE_RELEASE(_eventDispatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -500,7 +500,9 @@ void FileUtils::purgeCachedEntries()
|
||||||
|
|
||||||
static Data getData(const std::string& filename, bool forString)
|
static Data getData(const std::string& filename, bool forString)
|
||||||
{
|
{
|
||||||
CCASSERT(!filename.empty(), "Invalid filename!");
|
// getData is used indirectly in Image::initWithImageFileThreadSafe(), but CCASSERT is not thread-safe
|
||||||
|
// CCASSERT(!filename.empty(), "Invalid filename!");
|
||||||
|
assert(!(filename.empty()));
|
||||||
|
|
||||||
Data ret;
|
Data ret;
|
||||||
unsigned char* buffer = nullptr;
|
unsigned char* buffer = nullptr;
|
||||||
|
|
|
@ -112,7 +112,10 @@ bool FileUtilsWin32::isFileExistInternal(const std::string& strFilePath) const
|
||||||
WCHAR utf16Buf[CC_MAX_PATH] = {0};
|
WCHAR utf16Buf[CC_MAX_PATH] = {0};
|
||||||
MultiByteToWideChar(CP_UTF8, 0, strPath.c_str(), -1, utf16Buf, sizeof(utf16Buf)/sizeof(utf16Buf[0]));
|
MultiByteToWideChar(CP_UTF8, 0, strPath.c_str(), -1, utf16Buf, sizeof(utf16Buf)/sizeof(utf16Buf[0]));
|
||||||
|
|
||||||
return GetFileAttributesW(utf16Buf) != -1 ? true : false;
|
DWORD attr = GetFileAttributesW(utf16Buf);
|
||||||
|
if(attr == INVALID_FILE_ATTRIBUTES || (attr & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
|
return false; // not a file
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileUtilsWin32::isAbsolutePath(const std::string& strPath) const
|
bool FileUtilsWin32::isAbsolutePath(const std::string& strPath) const
|
||||||
|
|
|
@ -52,7 +52,6 @@ public:
|
||||||
//TODO use material to decide if it is translucent
|
//TODO use material to decide if it is translucent
|
||||||
inline bool isTranslucent() const { return true; }
|
inline bool isTranslucent() const { return true; }
|
||||||
|
|
||||||
void generateMaterialID();
|
|
||||||
inline uint32_t getMaterialID() const { return _materialID; }
|
inline uint32_t getMaterialID() const { return _materialID; }
|
||||||
|
|
||||||
inline GLuint getTextureID() const { return _textureID; }
|
inline GLuint getTextureID() const { return _textureID; }
|
||||||
|
@ -67,6 +66,9 @@ public:
|
||||||
|
|
||||||
inline const kmMat4& getModelView() const { return _mv; }
|
inline const kmMat4& getModelView() const { return _mv; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void generateMaterialID();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32_t _materialID;
|
uint32_t _materialID;
|
||||||
|
|
||||||
|
|
|
@ -359,6 +359,12 @@ void Renderer::render()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::clean()
|
||||||
|
{
|
||||||
|
// Clear render group
|
||||||
for (size_t j = 0 ; j < _renderGroups.size(); j++)
|
for (size_t j = 0 ; j < _renderGroups.size(); j++)
|
||||||
{
|
{
|
||||||
//commands are owned by nodes
|
//commands are owned by nodes
|
||||||
|
@ -368,12 +374,18 @@ void Renderer::render()
|
||||||
// }
|
// }
|
||||||
_renderGroups[j].clear();
|
_renderGroups[j].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Clear the stack incase gl view hasn't been initialized yet
|
// Clear batch quad commands
|
||||||
|
_batchedQuadCommands.clear();
|
||||||
|
_numQuads = 0;
|
||||||
|
|
||||||
|
// Clear the stack incase gl view hasn't been initialized yet
|
||||||
while(!_renderStack.empty())
|
while(!_renderStack.empty())
|
||||||
{
|
{
|
||||||
_renderStack.pop();
|
_renderStack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset render stack
|
||||||
RenderStackElement element = {DEFAULT_RENDER_QUEUE, 0};
|
RenderStackElement element = {DEFAULT_RENDER_QUEUE, 0};
|
||||||
_renderStack.push(element);
|
_renderStack.push(element);
|
||||||
_lastMaterialID = 0;
|
_lastMaterialID = 0;
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
|
|
||||||
//TODO manage GLView inside Render itself
|
//TODO manage GLView inside Render itself
|
||||||
void initGLView();
|
void initGLView();
|
||||||
|
|
||||||
/** Adds a `RenderComamnd` into the renderer */
|
/** Adds a `RenderComamnd` into the renderer */
|
||||||
void addCommand(RenderCommand* command);
|
void addCommand(RenderCommand* command);
|
||||||
|
|
||||||
|
@ -98,6 +98,9 @@ public:
|
||||||
/** Renders into the GLView all the queued `RenderCommand` objects */
|
/** Renders into the GLView all the queued `RenderCommand` objects */
|
||||||
void render();
|
void render();
|
||||||
|
|
||||||
|
/** Cleans all `RenderCommand`s in the queue */
|
||||||
|
void clean();
|
||||||
|
|
||||||
/* returns the number of drawn batches in the last frame */
|
/* returns the number of drawn batches in the last frame */
|
||||||
ssize_t getDrawnBatches() const { return _drawnBatches; }
|
ssize_t getDrawnBatches() const { return _drawnBatches; }
|
||||||
/* RenderCommands (except) QuadCommand should update this value */
|
/* RenderCommands (except) QuadCommand should update this value */
|
||||||
|
|
|
@ -765,6 +765,8 @@ void Console::commandTouch(int fd, const std::string& args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char invalid_filename_char[] = {':', '/', '\\', '?', '%', '*', '<', '>', '"', '|', '\r', '\n', '\t'};
|
||||||
|
|
||||||
void Console::commandUpload(int fd)
|
void Console::commandUpload(int fd)
|
||||||
{
|
{
|
||||||
ssize_t n, rc;
|
ssize_t n, rc;
|
||||||
|
@ -775,11 +777,20 @@ void Console::commandUpload(int fd)
|
||||||
{
|
{
|
||||||
if( (rc = recv(fd, &c, 1, 0)) ==1 )
|
if( (rc = recv(fd, &c, 1, 0)) ==1 )
|
||||||
{
|
{
|
||||||
*ptr++ = c;
|
for(char x : invalid_filename_char)
|
||||||
|
{
|
||||||
|
if(c == x)
|
||||||
|
{
|
||||||
|
const char err[] = "upload: invalid file name!\n";
|
||||||
|
send(fd, err, sizeof(err),0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(c == ' ')
|
if(c == ' ')
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*ptr++ = c;
|
||||||
}
|
}
|
||||||
else if( rc == 0 )
|
else if( rc == 0 )
|
||||||
{
|
{
|
||||||
|
@ -875,10 +886,10 @@ bool Console::parseCommand(int fd)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char err[] = "Unknown Command!\n";
|
const char err[] = "upload: invalid args! Type 'help' for options\n";
|
||||||
sendPrompt(fd);
|
|
||||||
send(fd, err, sizeof(err),0);
|
send(fd, err, sizeof(err),0);
|
||||||
return false;
|
sendPrompt(fd);
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -909,7 +920,7 @@ bool Console::parseCommand(int fd)
|
||||||
const char err[] = "Unknown command. Type 'help' for options\n";
|
const char err[] = "Unknown command. Type 'help' for options\n";
|
||||||
send(fd, err, sizeof(err),0);
|
send(fd, err, sizeof(err),0);
|
||||||
sendPrompt(fd);
|
sendPrompt(fd);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto it = _commands.find(trim(args[0]));
|
auto it = _commands.find(trim(args[0]));
|
||||||
|
|
|
@ -31,9 +31,9 @@ NS_CC_BEGIN
|
||||||
const Value Value::Null;
|
const Value Value::Null;
|
||||||
|
|
||||||
Value::Value()
|
Value::Value()
|
||||||
: _vectorData(new ValueVector())
|
: _vectorData(nullptr)
|
||||||
, _mapData(new ValueMap())
|
, _mapData(nullptr)
|
||||||
, _intKeyMapData(new ValueMapIntKey())
|
, _intKeyMapData(nullptr)
|
||||||
, _type(Type::NONE)
|
, _type(Type::NONE)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -41,75 +41,30 @@ namespace cocostudio
|
||||||
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
||||||
|
|
||||||
|
|
||||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
|
||||||
|
|
||||||
Button* button = static_cast<Button*>(widget);
|
Button* button = static_cast<Button*>(widget);
|
||||||
bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable");
|
bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable");
|
||||||
button->setScale9Enabled(scale9Enable);
|
button->setScale9Enabled(scale9Enable);
|
||||||
|
|
||||||
|
|
||||||
const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "normalData");
|
const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "normalData");
|
||||||
int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType");
|
int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType");
|
||||||
switch (normalType)
|
std::string normalTexturePath = this->getResourcePath(normalDic, "path", (TextureResType)normalType);
|
||||||
{
|
button->loadTextureNormal(normalTexturePath, (TextureResType)normalType);
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_n = jsonPath;
|
|
||||||
const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path");
|
|
||||||
const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr;
|
|
||||||
button->loadTextureNormal(normalFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path");
|
|
||||||
button->loadTextureNormal(normalFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "pressedData");
|
const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "pressedData");
|
||||||
int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType");
|
int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType");
|
||||||
switch (pressedType)
|
|
||||||
{
|
std::string pressedTexturePath = this->getResourcePath(pressedDic, "path", (TextureResType)pressedType);
|
||||||
case 0:
|
button->loadTexturePressed(pressedTexturePath, (TextureResType)pressedType);
|
||||||
{
|
|
||||||
std::string tp_p = jsonPath;
|
|
||||||
const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path");
|
|
||||||
const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr;
|
|
||||||
button->loadTexturePressed(pressedFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path");
|
|
||||||
button->loadTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "disabledData");
|
const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "disabledData");
|
||||||
int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType");
|
int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType");
|
||||||
switch (disabledType)
|
|
||||||
{
|
std::string disabledTexturePath = this->getResourcePath(disabledDic, "path", (TextureResType)disabledType);
|
||||||
case 0:
|
button->loadTextureDisabled(disabledTexturePath, (TextureResType)disabledType);
|
||||||
{
|
|
||||||
std::string tp_d = jsonPath;
|
|
||||||
const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path");
|
|
||||||
const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr;
|
|
||||||
button->loadTextureDisabled(disabledFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path");
|
|
||||||
button->loadTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (scale9Enable)
|
if (scale9Enable)
|
||||||
{
|
{
|
||||||
float cx = DICTOOL->getFloatValue_json(options, "capInsetsX");
|
float cx = DICTOOL->getFloatValue_json(options, "capInsetsX");
|
||||||
|
|
|
@ -40,7 +40,9 @@ namespace cocostudio
|
||||||
static ButtonReader* getInstance();
|
static ButtonReader* getInstance();
|
||||||
static void purge();
|
static void purge();
|
||||||
|
|
||||||
virtual void setPropsFromJsonDictionary(cocos2d::ui::Widget* widget, const rapidjson::Value& options);
|
virtual void setPropsFromJsonDictionary(cocos2d::ui::Widget* widget,
|
||||||
|
const rapidjson::Value& options);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,120 +35,38 @@ namespace cocostudio
|
||||||
{
|
{
|
||||||
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
||||||
|
|
||||||
|
|
||||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
|
||||||
|
|
||||||
CheckBox* checkBox = static_cast<CheckBox*>(widget);
|
CheckBox* checkBox = static_cast<CheckBox*>(widget);
|
||||||
|
|
||||||
|
|
||||||
|
//load background image
|
||||||
const rapidjson::Value& backGroundDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxData");
|
const rapidjson::Value& backGroundDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxData");
|
||||||
int backGroundType = DICTOOL->getIntValue_json(backGroundDic, "resourceType");
|
int backGroundType = DICTOOL->getIntValue_json(backGroundDic, "resourceType");
|
||||||
switch (backGroundType)
|
std::string backGroundTexturePath = this->getResourcePath(backGroundDic, "path", (TextureResType)backGroundType);
|
||||||
{
|
checkBox->loadTextureBackGround(backGroundTexturePath, (TextureResType)backGroundType);
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_b = jsonPath;
|
|
||||||
const char* backGroundFileName = DICTOOL->getStringValue_json(backGroundDic, "path");
|
|
||||||
const char* backGroundFileName_tp = (backGroundFileName && (strcmp(backGroundFileName, "") != 0))?tp_b.append(backGroundFileName).c_str():nullptr;
|
|
||||||
checkBox->loadTextureBackGround(backGroundFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* backGroundFileName = DICTOOL->getStringValue_json(backGroundDic, "path");
|
|
||||||
checkBox->loadTextureBackGround(backGroundFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//load background selected image
|
||||||
const rapidjson::Value& backGroundSelectedDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxSelectedData");
|
const rapidjson::Value& backGroundSelectedDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxSelectedData");
|
||||||
int backGroundSelectedType = DICTOOL->getIntValue_json(backGroundSelectedDic, "resourceType");
|
int backGroundSelectedType = DICTOOL->getIntValue_json(backGroundSelectedDic, "resourceType");
|
||||||
switch (backGroundSelectedType)
|
std::string backGroundSelectedTexturePath = this->getResourcePath(backGroundSelectedDic, "path", (TextureResType)backGroundSelectedType);
|
||||||
{
|
checkBox->loadTextureBackGroundSelected(backGroundSelectedTexturePath, (TextureResType)backGroundSelectedType);
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_bs = jsonPath;
|
|
||||||
const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(backGroundSelectedDic, "path");
|
|
||||||
const char* backGroundSelectedFileName_tp = (backGroundSelectedFileName && (strcmp(backGroundSelectedFileName, "") != 0))?tp_bs.append(backGroundSelectedFileName).c_str():nullptr;
|
|
||||||
checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* backGroundSelectedFileName = DICTOOL->getStringValue_json(backGroundSelectedDic, "path");
|
|
||||||
checkBox->loadTextureBackGroundSelected(backGroundSelectedFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//load frontCross image
|
||||||
const rapidjson::Value& frontCrossDic = DICTOOL->getSubDictionary_json(options, "frontCrossData");
|
const rapidjson::Value& frontCrossDic = DICTOOL->getSubDictionary_json(options, "frontCrossData");
|
||||||
int frontCrossType = DICTOOL->getIntValue_json(frontCrossDic, "resourceType");
|
int frontCrossType = DICTOOL->getIntValue_json(frontCrossDic, "resourceType");
|
||||||
switch (frontCrossType)
|
std::string frontCrossFileName = this->getResourcePath(frontCrossDic, "path", (TextureResType)frontCrossType);
|
||||||
{
|
checkBox->loadTextureFrontCross(frontCrossFileName, (TextureResType)frontCrossType);
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_c = jsonPath;
|
|
||||||
const char* frontCrossFileName = DICTOOL->getStringValue_json(frontCrossDic, "path");
|
|
||||||
const char* frontCrossFileName_tp = (frontCrossFileName && (strcmp(frontCrossFileName, "") != 0))?tp_c.append(frontCrossFileName).c_str():nullptr;
|
|
||||||
checkBox->loadTextureFrontCross(frontCrossFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* frontCrossFileName = DICTOOL->getStringValue_json(frontCrossDic, "path");
|
|
||||||
checkBox->loadTextureFrontCross(frontCrossFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//load backGroundBoxDisabledData
|
||||||
const rapidjson::Value& backGroundDisabledDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxDisabledData");
|
const rapidjson::Value& backGroundDisabledDic = DICTOOL->getSubDictionary_json(options, "backGroundBoxDisabledData");
|
||||||
int backGroundDisabledType = DICTOOL->getIntValue_json(backGroundDisabledDic, "resourceType");
|
int backGroundDisabledType = DICTOOL->getIntValue_json(backGroundDisabledDic, "resourceType");
|
||||||
switch (backGroundDisabledType)
|
std::string backGroundDisabledFileName = this->getResourcePath(backGroundDisabledDic, "path", (TextureResType)backGroundDisabledType);
|
||||||
{
|
checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName, (TextureResType)backGroundDisabledType);
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_bd = jsonPath;
|
|
||||||
const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(backGroundDisabledDic, "path");
|
|
||||||
const char* backGroundDisabledFileName_tp = (backGroundDisabledFileName && (strcmp(backGroundDisabledFileName, "") != 0))?tp_bd.append(backGroundDisabledFileName).c_str():nullptr;
|
|
||||||
checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* backGroundDisabledFileName = DICTOOL->getStringValue_json(backGroundDisabledDic, "path");
|
|
||||||
checkBox->loadTextureBackGroundDisabled(backGroundDisabledFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
///load frontCrossDisabledData
|
||||||
const rapidjson::Value& frontCrossDisabledDic = DICTOOL->getSubDictionary_json(options, "frontCrossDisabledData");
|
const rapidjson::Value& frontCrossDisabledDic = DICTOOL->getSubDictionary_json(options, "frontCrossDisabledData");
|
||||||
int frontCrossDisabledType = DICTOOL->getIntValue_json(frontCrossDisabledDic, "resourceType");
|
int frontCrossDisabledType = DICTOOL->getIntValue_json(frontCrossDisabledDic, "resourceType");
|
||||||
switch (frontCrossDisabledType)
|
std::string frontCrossDisabledFileName = this->getResourcePath(frontCrossDisabledDic, "path", (TextureResType)frontCrossDisabledType);
|
||||||
{
|
checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName, (TextureResType)frontCrossDisabledType);
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_cd = jsonPath;
|
|
||||||
const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "path");
|
|
||||||
const char* frontCrossDisabledFileName_tp = (frontCrossDisabledFileName && (strcmp(frontCrossDisabledFileName, "") != 0))?tp_cd.append(frontCrossDisabledFileName).c_str():nullptr;
|
|
||||||
checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* frontCrossDisabledFileName = DICTOOL->getStringValue_json(options, "path");
|
|
||||||
checkBox->loadTextureFrontCrossDisabled(frontCrossDisabledFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
|
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
|
||||||
|
|
|
@ -36,35 +36,14 @@ namespace cocostudio
|
||||||
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
||||||
|
|
||||||
|
|
||||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
|
||||||
|
|
||||||
ImageView* imageView = static_cast<ImageView*>(widget);
|
ImageView* imageView = static_cast<ImageView*>(widget);
|
||||||
|
|
||||||
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "fileNameData");
|
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "fileNameData");
|
||||||
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
|
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
|
||||||
switch (imageFileNameType)
|
std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType);
|
||||||
{
|
imageView->loadTexture(imageFileName, (TextureResType)imageFileNameType);
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_i = jsonPath;
|
|
||||||
const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path");
|
|
||||||
const char* imageFileName_tp = nullptr;
|
|
||||||
if (imageFileName && (strcmp(imageFileName, "") != 0))
|
|
||||||
{
|
|
||||||
imageFileName_tp = tp_i.append(imageFileName).c_str();
|
|
||||||
imageView->loadTexture(imageFileName_tp);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path");
|
|
||||||
imageView->loadTexture(imageFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, "scale9Enable");
|
bool scale9EnableExist = DICTOOL->checkObjectExist_json(options, "scale9Enable");
|
||||||
bool scale9Enable = false;
|
bool scale9Enable = false;
|
||||||
|
|
|
@ -35,9 +35,6 @@ namespace cocostudio
|
||||||
{
|
{
|
||||||
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
||||||
|
|
||||||
|
|
||||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
|
||||||
|
|
||||||
Layout* panel = static_cast<Layout*>(widget);
|
Layout* panel = static_cast<Layout*>(widget);
|
||||||
|
|
||||||
/* adapt screen gui */
|
/* adapt screen gui */
|
||||||
|
@ -86,25 +83,9 @@ namespace cocostudio
|
||||||
|
|
||||||
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "backGroundImageData");
|
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "backGroundImageData");
|
||||||
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
|
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
|
||||||
switch (imageFileNameType)
|
std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType);
|
||||||
{
|
panel->setBackGroundImage(imageFileName, (TextureResType)imageFileNameType);
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_b = jsonPath;
|
|
||||||
const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path");
|
|
||||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr;
|
|
||||||
panel->setBackGroundImage(imageFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path");
|
|
||||||
panel->setBackGroundImage(imageFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (backGroundScale9Enable)
|
if (backGroundScale9Enable)
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,35 +36,13 @@ namespace cocostudio
|
||||||
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
||||||
|
|
||||||
|
|
||||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
|
||||||
|
|
||||||
LoadingBar* loadingBar = static_cast<LoadingBar*>(widget);
|
LoadingBar* loadingBar = static_cast<LoadingBar*>(widget);
|
||||||
|
|
||||||
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "textureData");
|
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "textureData");
|
||||||
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
|
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
|
||||||
switch (imageFileNameType)
|
std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType);
|
||||||
{
|
loadingBar->loadTexture(imageFileName, (TextureResType)imageFileNameType);
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_i = jsonPath;
|
|
||||||
const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path");
|
|
||||||
const char* imageFileName_tp = nullptr;
|
|
||||||
if (imageFileName && (strcmp(imageFileName, "") != 0))
|
|
||||||
{
|
|
||||||
imageFileName_tp = tp_i.append(imageFileName).c_str();
|
|
||||||
loadingBar->loadTexture(imageFileName_tp);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path");
|
|
||||||
loadingBar->loadTexture(imageFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* gui mark add load bar scale9 parse */
|
/* gui mark add load bar scale9 parse */
|
||||||
bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable");
|
bool scale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable");
|
||||||
|
|
|
@ -35,159 +35,55 @@ namespace cocostudio
|
||||||
{
|
{
|
||||||
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
||||||
|
|
||||||
|
|
||||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
|
||||||
|
|
||||||
Slider* slider = static_cast<Slider*>(widget);
|
Slider* slider = static_cast<Slider*>(widget);
|
||||||
|
|
||||||
bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable");
|
bool barTextureScale9Enable = DICTOOL->getBooleanValue_json(options, "scale9Enable");
|
||||||
slider->setScale9Enabled(barTextureScale9Enable);
|
slider->setScale9Enabled(barTextureScale9Enable);
|
||||||
|
|
||||||
|
slider->setPercent(DICTOOL->getIntValue_json(options, "percent"));
|
||||||
|
|
||||||
|
|
||||||
bool bt = DICTOOL->checkObjectExist_json(options, "barFileName");
|
bool bt = DICTOOL->checkObjectExist_json(options, "barFileName");
|
||||||
float barLength = DICTOOL->getFloatValue_json(options, "length");
|
float barLength = DICTOOL->getFloatValue_json(options, "length");
|
||||||
if (bt)
|
if (bt)
|
||||||
{
|
{
|
||||||
|
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData");
|
||||||
|
int imageFileNameType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
|
||||||
|
std::string imageFileName = this->getResourcePath(imageFileNameDic, "path", (TextureResType)imageFileNameType);
|
||||||
|
slider->loadBarTexture(imageFileName, (TextureResType)imageFileNameType);
|
||||||
|
|
||||||
if (barTextureScale9Enable)
|
if (barTextureScale9Enable)
|
||||||
{
|
{
|
||||||
|
|
||||||
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData");
|
|
||||||
int imageFileType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
|
|
||||||
switch (imageFileType)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_b = jsonPath;
|
|
||||||
const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path");
|
|
||||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr;
|
|
||||||
slider->loadBarTexture(imageFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path");
|
|
||||||
slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
slider->setSize(Size(barLength, slider->getContentSize().height));
|
slider->setSize(Size(barLength, slider->getContentSize().height));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
const rapidjson::Value& imageFileNameDic = DICTOOL->getSubDictionary_json(options, "barFileNameData");
|
|
||||||
int imageFileType = DICTOOL->getIntValue_json(imageFileNameDic, "resourceType");
|
|
||||||
switch (imageFileType)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_b = jsonPath;
|
|
||||||
const char*imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path");
|
|
||||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr;
|
|
||||||
slider->loadBarTexture(imageFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char*imageFileName = DICTOOL->getStringValue_json(imageFileNameDic, "path");
|
|
||||||
slider->loadBarTexture(imageFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//loading normal slider ball texture
|
||||||
const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "ballNormalData");
|
const rapidjson::Value& normalDic = DICTOOL->getSubDictionary_json(options, "ballNormalData");
|
||||||
int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType");
|
int normalType = DICTOOL->getIntValue_json(normalDic, "resourceType");
|
||||||
switch (normalType)
|
std::string imageFileName = this->getResourcePath(normalDic, "path", (TextureResType)normalType);
|
||||||
{
|
slider->loadSlidBallTextureNormal(imageFileName, (TextureResType)normalType);
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_n = jsonPath;
|
|
||||||
const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path");
|
|
||||||
const char* normalFileName_tp = (normalFileName && (strcmp(normalFileName, "") != 0))?tp_n.append(normalFileName).c_str():nullptr;
|
|
||||||
slider->loadSlidBallTextureNormal(normalFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* normalFileName = DICTOOL->getStringValue_json(normalDic, "path");
|
|
||||||
slider->loadSlidBallTextureNormal(normalFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
//loading slider ball press texture
|
||||||
const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "ballPressedData");
|
const rapidjson::Value& pressedDic = DICTOOL->getSubDictionary_json(options, "ballPressedData");
|
||||||
int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType");
|
int pressedType = DICTOOL->getIntValue_json(pressedDic, "resourceType");
|
||||||
switch (pressedType)
|
std::string pressedFileName = this->getResourcePath(pressedDic, "path", (TextureResType)pressedType);
|
||||||
{
|
slider->loadSlidBallTexturePressed(pressedFileName, (TextureResType)pressedType);
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_p = jsonPath;
|
|
||||||
const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path");
|
|
||||||
const char* pressedFileName_tp = (pressedFileName && (strcmp(pressedFileName, "") != 0))?tp_p.append(pressedFileName).c_str():nullptr;
|
|
||||||
slider->loadSlidBallTexturePressed(pressedFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* pressedFileName = DICTOOL->getStringValue_json(pressedDic, "path");
|
|
||||||
slider->loadSlidBallTexturePressed(pressedFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//loading silder ball disable texture
|
||||||
const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "ballDisabledData");
|
const rapidjson::Value& disabledDic = DICTOOL->getSubDictionary_json(options, "ballDisabledData");
|
||||||
int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType");
|
int disabledType = DICTOOL->getIntValue_json(disabledDic, "resourceType");
|
||||||
switch (disabledType)
|
std::string disabledFileName = this->getResourcePath(disabledDic, "path", (TextureResType)disabledType);
|
||||||
{
|
slider->loadSlidBallTextureDisabled(disabledFileName, (TextureResType)disabledType);
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_d = jsonPath;
|
|
||||||
const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path");
|
|
||||||
const char* disabledFileName_tp = (disabledFileName && (strcmp(disabledFileName, "") != 0))?tp_d.append(disabledFileName).c_str():nullptr;
|
|
||||||
slider->loadSlidBallTextureDisabled(disabledFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* disabledFileName = DICTOOL->getStringValue_json(disabledDic, "path");
|
|
||||||
slider->loadSlidBallTextureDisabled(disabledFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
slider->setPercent(DICTOOL->getIntValue_json(options, "percent"));
|
|
||||||
|
|
||||||
|
//load slider progress texture
|
||||||
const rapidjson::Value& progressBarDic = DICTOOL->getSubDictionary_json(options, "progressBarData");
|
const rapidjson::Value& progressBarDic = DICTOOL->getSubDictionary_json(options, "progressBarData");
|
||||||
int progressBarType = DICTOOL->getIntValue_json(progressBarDic, "resourceType");
|
int progressBarType = DICTOOL->getIntValue_json(progressBarDic, "resourceType");
|
||||||
switch (progressBarType)
|
std::string progressBarFileName = this->getResourcePath(progressBarDic, "path", (TextureResType)progressBarType);
|
||||||
{
|
slider->loadProgressBarTexture(progressBarFileName, (TextureResType)progressBarType);
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
std::string tp_b = jsonPath;
|
|
||||||
const char* imageFileName = DICTOOL->getStringValue_json(progressBarDic, "path");
|
|
||||||
const char* imageFileName_tp = (imageFileName && (strcmp(imageFileName, "") != 0))?tp_b.append(imageFileName).c_str():nullptr;
|
|
||||||
slider->loadProgressBarTexture(imageFileName_tp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
const char* imageFileName = DICTOOL->getStringValue_json(progressBarDic, "path");
|
|
||||||
slider->loadProgressBarTexture(imageFileName,UI_TEX_TYPE_PLIST);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
|
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
|
||||||
|
|
|
@ -172,4 +172,26 @@ namespace cocostudio
|
||||||
widget->setFlippedX(flipX);
|
widget->setFlippedX(flipX);
|
||||||
widget->setFlippedY(flipY);
|
widget->setFlippedY(flipY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string WidgetReader::getResourcePath(const rapidjson::Value &dict,
|
||||||
|
const std::string &key,
|
||||||
|
cocos2d::ui::TextureResType texType)
|
||||||
|
{
|
||||||
|
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
||||||
|
const char* imageFileName = DICTOOL->getStringValue_json(dict, key.c_str());
|
||||||
|
std::string imageFileName_tp;
|
||||||
|
if (nullptr != imageFileName)
|
||||||
|
{
|
||||||
|
if (texType == UI_TEX_TYPE_LOCAL) {
|
||||||
|
imageFileName_tp = jsonPath + imageFileName;
|
||||||
|
}
|
||||||
|
else if(texType == UI_TEX_TYPE_PLIST){
|
||||||
|
imageFileName_tp = imageFileName;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
CCASSERT(0, "invalid TextureResType!!!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return imageFileName_tp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,16 @@ namespace cocostudio
|
||||||
static WidgetReader* getInstance();
|
static WidgetReader* getInstance();
|
||||||
static void purge();
|
static void purge();
|
||||||
|
|
||||||
virtual void setPropsFromJsonDictionary(cocos2d::ui::Widget* widget, const rapidjson::Value& options);
|
virtual void setPropsFromJsonDictionary(cocos2d::ui::Widget* widget,
|
||||||
virtual void setColorPropsFromJsonDictionary(cocos2d::ui::Widget* widget, const rapidjson::Value& options);
|
const rapidjson::Value& options);
|
||||||
|
|
||||||
|
virtual void setColorPropsFromJsonDictionary(cocos2d::ui::Widget* widget,
|
||||||
|
const rapidjson::Value& options);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::string getResourcePath(const rapidjson::Value& dict,
|
||||||
|
const std::string& key,
|
||||||
|
cocos2d::ui::TextureResType texType);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Button] loadTextureDisabled
|
-- @function [parent=#Button] loadTextureDisabled
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
@ -57,13 +57,13 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Button] loadTexturePressed
|
-- @function [parent=#Button] loadTexturePressed
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Button] setTitleFontName
|
-- @function [parent=#Button] setTitleFontName
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Button] getCapInsetsNormalRenderer
|
-- @function [parent=#Button] getCapInsetsNormalRenderer
|
||||||
|
@ -78,9 +78,9 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Button] loadTextures
|
-- @function [parent=#Button] loadTextures
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Button] loadTextureNormal
|
-- @function [parent=#Button] loadTextureNormal
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Button] getTitleFontName
|
-- @function [parent=#Button] getTitleFontName
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @return char#char ret (return value: char)
|
-- @return string#string ret (return value: string)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Button] getTitleColor
|
-- @function [parent=#Button] getTitleColor
|
||||||
|
@ -120,10 +120,18 @@
|
||||||
-- @param #bool bool
|
-- @param #bool bool
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Button] create
|
-- overload function: create(string, string, string, ccui.TextureResType)
|
||||||
|
--
|
||||||
|
-- overload function: create()
|
||||||
|
--
|
||||||
|
-- @function [parent=#Button] create
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @return Button#Button ret (return value: ccui.Button)
|
-- @param #string str
|
||||||
|
-- @param #string str
|
||||||
|
-- @param #string str
|
||||||
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
-- @return Button#Button ret (retunr value: ccui.Button)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Button] createInstance
|
-- @function [parent=#Button] createInstance
|
||||||
-- @param self
|
-- @param self
|
||||||
|
|
|
@ -11,35 +11,35 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#CheckBox] loadTextureBackGroundSelected
|
-- @function [parent=#CheckBox] loadTextureBackGroundSelected
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#CheckBox] loadTextureBackGroundDisabled
|
-- @function [parent=#CheckBox] loadTextureBackGroundDisabled
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#CheckBox] loadTextureFrontCross
|
-- @function [parent=#CheckBox] loadTextureFrontCross
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#CheckBox] loadTextures
|
-- @function [parent=#CheckBox] loadTextures
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#CheckBox] loadTextureBackGround
|
-- @function [parent=#CheckBox] loadTextureBackGround
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
@ -50,14 +50,24 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#CheckBox] loadTextureFrontCrossDisabled
|
-- @function [parent=#CheckBox] loadTextureFrontCrossDisabled
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#CheckBox] create
|
-- overload function: create(string, string, string, string, string, ccui.TextureResType)
|
||||||
|
--
|
||||||
|
-- overload function: create()
|
||||||
|
--
|
||||||
|
-- @function [parent=#CheckBox] create
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @return CheckBox#CheckBox ret (return value: ccui.CheckBox)
|
-- @param #string str
|
||||||
|
-- @param #string str
|
||||||
|
-- @param #string str
|
||||||
|
-- @param #string str
|
||||||
|
-- @param #string str
|
||||||
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
-- @return CheckBox#CheckBox ret (retunr value: ccui.CheckBox)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#CheckBox] createInstance
|
-- @function [parent=#CheckBox] createInstance
|
||||||
-- @param self
|
-- @param self
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#ImageView] loadTexture
|
-- @function [parent=#ImageView] loadTexture
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
@ -35,10 +35,16 @@
|
||||||
-- @return bool#bool ret (return value: bool)
|
-- @return bool#bool ret (return value: bool)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#ImageView] create
|
-- overload function: create(string, ccui.TextureResType)
|
||||||
|
--
|
||||||
|
-- overload function: create()
|
||||||
|
--
|
||||||
|
-- @function [parent=#ImageView] create
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @return ImageView#ImageView ret (return value: ccui.ImageView)
|
-- @param #string str
|
||||||
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
-- @return ImageView#ImageView ret (retunr value: ccui.ImageView)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#ImageView] createInstance
|
-- @function [parent=#ImageView] createInstance
|
||||||
-- @param self
|
-- @param self
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Layout] setBackGroundImage
|
-- @function [parent=#Layout] setBackGroundImage
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#LoadingBar] loadTexture
|
-- @function [parent=#LoadingBar] loadTexture
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
@ -50,10 +50,16 @@
|
||||||
-- @return int#int ret (return value: int)
|
-- @return int#int ret (return value: int)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#LoadingBar] create
|
-- overload function: create(string, int)
|
||||||
|
--
|
||||||
|
-- overload function: create()
|
||||||
|
--
|
||||||
|
-- @function [parent=#LoadingBar] create
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @return LoadingBar#LoadingBar ret (return value: ccui.LoadingBar)
|
-- @param #string str
|
||||||
|
-- @param #int int
|
||||||
|
-- @return LoadingBar#LoadingBar ret (retunr value: ccui.LoadingBar)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#LoadingBar] createInstance
|
-- @function [parent=#LoadingBar] createInstance
|
||||||
-- @param self
|
-- @param self
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
-- @param #float float
|
-- @param #float float
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- overload function: initWithSpriteFrameName(char)
|
-- overload function: initWithSpriteFrameName(string)
|
||||||
--
|
--
|
||||||
-- overload function: initWithSpriteFrameName(char, rect_table)
|
-- overload function: initWithSpriteFrameName(string, rect_table)
|
||||||
--
|
--
|
||||||
-- @function [parent=#Scale9Sprite] initWithSpriteFrameName
|
-- @function [parent=#Scale9Sprite] initWithSpriteFrameName
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #rect_table rect
|
-- @param #rect_table rect
|
||||||
-- @return bool#bool ret (retunr value: bool)
|
-- @return bool#bool ret (retunr value: bool)
|
||||||
|
|
||||||
|
@ -88,17 +88,17 @@
|
||||||
-- @return size_table#size_table ret (return value: size_table)
|
-- @return size_table#size_table ret (return value: size_table)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- overload function: initWithFile(char, rect_table)
|
-- overload function: initWithFile(string, rect_table)
|
||||||
--
|
--
|
||||||
-- overload function: initWithFile(char, rect_table, rect_table)
|
-- overload function: initWithFile(string, rect_table, rect_table)
|
||||||
--
|
--
|
||||||
-- overload function: initWithFile(rect_table, char)
|
-- overload function: initWithFile(rect_table, string)
|
||||||
--
|
--
|
||||||
-- overload function: initWithFile(char)
|
-- overload function: initWithFile(string)
|
||||||
--
|
--
|
||||||
-- @function [parent=#Scale9Sprite] initWithFile
|
-- @function [parent=#Scale9Sprite] initWithFile
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #rect_table rect
|
-- @param #rect_table rect
|
||||||
-- @param #rect_table rect
|
-- @param #rect_table rect
|
||||||
-- @return bool#bool ret (retunr value: bool)
|
-- @return bool#bool ret (retunr value: bool)
|
||||||
|
@ -145,31 +145,31 @@
|
||||||
-- @param #float float
|
-- @param #float float
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- overload function: create(char, rect_table, rect_table)
|
-- overload function: create(string, rect_table, rect_table)
|
||||||
--
|
--
|
||||||
-- overload function: create()
|
-- overload function: create()
|
||||||
--
|
--
|
||||||
-- overload function: create(rect_table, char)
|
-- overload function: create(rect_table, string)
|
||||||
--
|
--
|
||||||
-- overload function: create(char, rect_table)
|
-- overload function: create(string, rect_table)
|
||||||
--
|
--
|
||||||
-- overload function: create(char)
|
-- overload function: create(string)
|
||||||
--
|
--
|
||||||
-- @function [parent=#Scale9Sprite] create
|
-- @function [parent=#Scale9Sprite] create
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #rect_table rect
|
-- @param #rect_table rect
|
||||||
-- @param #rect_table rect
|
-- @param #rect_table rect
|
||||||
-- @return Scale9Sprite#Scale9Sprite ret (retunr value: cc.Scale9Sprite)
|
-- @return Scale9Sprite#Scale9Sprite ret (retunr value: cc.Scale9Sprite)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- overload function: createWithSpriteFrameName(char, rect_table)
|
-- overload function: createWithSpriteFrameName(string, rect_table)
|
||||||
--
|
--
|
||||||
-- overload function: createWithSpriteFrameName(char)
|
-- overload function: createWithSpriteFrameName(string)
|
||||||
--
|
--
|
||||||
-- @function [parent=#Scale9Sprite] createWithSpriteFrameName
|
-- @function [parent=#Scale9Sprite] createWithSpriteFrameName
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #rect_table rect
|
-- @param #rect_table rect
|
||||||
-- @return Scale9Sprite#Scale9Sprite ret (retunr value: cc.Scale9Sprite)
|
-- @return Scale9Sprite#Scale9Sprite ret (retunr value: cc.Scale9Sprite)
|
||||||
|
|
||||||
|
|
|
@ -11,33 +11,33 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Slider] loadSlidBallTextureDisabled
|
-- @function [parent=#Slider] loadSlidBallTextureDisabled
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Slider] loadSlidBallTextureNormal
|
-- @function [parent=#Slider] loadSlidBallTextureNormal
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Slider] loadBarTexture
|
-- @function [parent=#Slider] loadBarTexture
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Slider] loadProgressBarTexture
|
-- @function [parent=#Slider] loadProgressBarTexture
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Slider] loadSlidBallTextures
|
-- @function [parent=#Slider] loadSlidBallTextures
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Slider] loadSlidBallTexturePressed
|
-- @function [parent=#Slider] loadSlidBallTexturePressed
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
-- @param #ccui.TextureResType texturerestype
|
-- @param #ccui.TextureResType texturerestype
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
|
@ -79,10 +79,17 @@
|
||||||
-- @param #size_table size
|
-- @param #size_table size
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Text] create
|
-- overload function: create(string, string, int)
|
||||||
|
--
|
||||||
|
-- overload function: create()
|
||||||
|
--
|
||||||
|
-- @function [parent=#Text] create
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @return Text#Text ret (return value: ccui.Text)
|
-- @param #string str
|
||||||
|
-- @param #string str
|
||||||
|
-- @param #int int
|
||||||
|
-- @return Text#Text ret (retunr value: ccui.Text)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#Text] createInstance
|
-- @function [parent=#Text] createInstance
|
||||||
-- @param self
|
-- @param self
|
||||||
|
|
|
@ -23,10 +23,19 @@
|
||||||
-- @param #string str
|
-- @param #string str
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#TextAtlas] create
|
-- overload function: create(string, string, int, int, string)
|
||||||
|
--
|
||||||
|
-- overload function: create()
|
||||||
|
--
|
||||||
|
-- @function [parent=#TextAtlas] create
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @return TextAtlas#TextAtlas ret (return value: ccui.TextAtlas)
|
-- @param #string str
|
||||||
|
-- @param #string str
|
||||||
|
-- @param #int int
|
||||||
|
-- @param #int int
|
||||||
|
-- @param #string str
|
||||||
|
-- @return TextAtlas#TextAtlas ret (retunr value: ccui.TextAtlas)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#TextAtlas] createInstance
|
-- @function [parent=#TextAtlas] createInstance
|
||||||
-- @param self
|
-- @param self
|
||||||
|
|
|
@ -6,23 +6,29 @@
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#TextBMFont] setFntFile
|
-- @function [parent=#TextBMFont] setFntFile
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#TextBMFont] getStringValue
|
-- @function [parent=#TextBMFont] getStringValue
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @return char#char ret (return value: char)
|
-- @return string#string ret (return value: string)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#TextBMFont] setText
|
-- @function [parent=#TextBMFont] setText
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @param #char char
|
-- @param #string str
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#TextBMFont] create
|
-- overload function: create(string, string)
|
||||||
|
--
|
||||||
|
-- overload function: create()
|
||||||
|
--
|
||||||
|
-- @function [parent=#TextBMFont] create
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @return TextBMFont#TextBMFont ret (return value: ccui.TextBMFont)
|
-- @param #string str
|
||||||
|
-- @param #string str
|
||||||
|
-- @return TextBMFont#TextBMFont ret (retunr value: ccui.TextBMFont)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#TextBMFont] createInstance
|
-- @function [parent=#TextBMFont] createInstance
|
||||||
-- @param self
|
-- @param self
|
||||||
|
|
|
@ -168,10 +168,17 @@
|
||||||
-- @return size_table#size_table ret (return value: size_table)
|
-- @return size_table#size_table ret (return value: size_table)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#TextField] create
|
-- overload function: create(string, string, int)
|
||||||
|
--
|
||||||
|
-- overload function: create()
|
||||||
|
--
|
||||||
|
-- @function [parent=#TextField] create
|
||||||
-- @param self
|
-- @param self
|
||||||
-- @return TextField#TextField ret (return value: ccui.TextField)
|
-- @param #string str
|
||||||
|
-- @param #string str
|
||||||
|
-- @param #int int
|
||||||
|
-- @return TextField#TextField ret (retunr value: ccui.TextField)
|
||||||
|
|
||||||
--------------------------------
|
--------------------------------
|
||||||
-- @function [parent=#TextField] createInstance
|
-- @function [parent=#TextField] createInstance
|
||||||
-- @param self
|
-- @param self
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
cfd5546826cceb88f4a37396516b6863abb122c6
|
427b621d028746e72000086b320b1b9b3adf7a19
|
|
@ -1 +1 @@
|
||||||
d608beef525313b9c497786a1dd7b2460ff65d84
|
a1f2ceee65fe7b4bdae2cd2c32ff84fa332a6b50
|
|
@ -124,10 +124,11 @@ ScriptHandlerMgr::ScriptHandlerMgr()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptHandlerMgr::~ScriptHandlerMgr()
|
ScriptHandlerMgr::~ScriptHandlerMgr()
|
||||||
{
|
{
|
||||||
CC_SAFE_DELETE(_scriptHandlerMgr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptHandlerMgr* ScriptHandlerMgr::getInstance()
|
ScriptHandlerMgr* ScriptHandlerMgr::getInstance()
|
||||||
{
|
{
|
||||||
if (NULL == _scriptHandlerMgr)
|
if (NULL == _scriptHandlerMgr)
|
||||||
|
@ -138,6 +139,11 @@ ScriptHandlerMgr* ScriptHandlerMgr::getInstance()
|
||||||
return _scriptHandlerMgr;
|
return _scriptHandlerMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptHandlerMgr::destroyInstance()
|
||||||
|
{
|
||||||
|
CC_SAFE_DELETE(_scriptHandlerMgr);
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptHandlerMgr::init()
|
void ScriptHandlerMgr::init()
|
||||||
{
|
{
|
||||||
_mapObjectHandlers.clear();
|
_mapObjectHandlers.clear();
|
||||||
|
|
|
@ -173,7 +173,8 @@ public:
|
||||||
ScriptHandlerMgr(void);
|
ScriptHandlerMgr(void);
|
||||||
virtual ~ScriptHandlerMgr(void);
|
virtual ~ScriptHandlerMgr(void);
|
||||||
static ScriptHandlerMgr* getInstance(void);
|
static ScriptHandlerMgr* getInstance(void);
|
||||||
|
static void destroyInstance(void);
|
||||||
|
|
||||||
void addObjectHandler(void* object,int handler,ScriptHandlerMgr::HandlerType handlerType);
|
void addObjectHandler(void* object,int handler,ScriptHandlerMgr::HandlerType handlerType);
|
||||||
void removeObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType);
|
void removeObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType);
|
||||||
int getObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType);
|
int getObjectHandler(void* object,ScriptHandlerMgr::HandlerType handlerType);
|
||||||
|
|
|
@ -83,6 +83,38 @@ Button* Button::create()
|
||||||
CC_SAFE_DELETE(widget);
|
CC_SAFE_DELETE(widget);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Button* Button::create(const std::string &normalImage,
|
||||||
|
const std::string& selectedImage ,
|
||||||
|
const std::string& disableImage,
|
||||||
|
TextureResType texType)
|
||||||
|
{
|
||||||
|
Button *btn = new Button;
|
||||||
|
if (btn && btn->init(normalImage,selectedImage,disableImage,texType)) {
|
||||||
|
btn->autorelease();
|
||||||
|
return btn;
|
||||||
|
}
|
||||||
|
CC_SAFE_DELETE(btn);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Button::init(const std::string &normalImage,
|
||||||
|
const std::string& selectedImage ,
|
||||||
|
const std::string& disableImage,
|
||||||
|
TextureResType texType)
|
||||||
|
{
|
||||||
|
bool ret = true;
|
||||||
|
do {
|
||||||
|
if (!Widget::init()) {
|
||||||
|
ret = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTouchEnabled(true);
|
||||||
|
this->loadTextures(normalImage, selectedImage, disableImage,texType);
|
||||||
|
} while (0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
bool Button::init()
|
bool Button::init()
|
||||||
{
|
{
|
||||||
|
@ -135,9 +167,9 @@ void Button::setScale9Enabled(bool able)
|
||||||
_buttonDisableRenderer = Sprite::create();
|
_buttonDisableRenderer = Sprite::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadTextureNormal(_normalFileName.c_str(), _normalTexType);
|
loadTextureNormal(_normalFileName, _normalTexType);
|
||||||
loadTexturePressed(_clickedFileName.c_str(), _pressedTexType);
|
loadTexturePressed(_clickedFileName, _pressedTexType);
|
||||||
loadTextureDisabled(_disabledFileName.c_str(), _disabledTexType);
|
loadTextureDisabled(_disabledFileName, _disabledTexType);
|
||||||
addProtectedChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1);
|
addProtectedChild(_buttonNormalRenderer, NORMAL_RENDERER_Z, -1);
|
||||||
addProtectedChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1);
|
addProtectedChild(_buttonClickedRenderer, PRESSED_RENDERER_Z, -1);
|
||||||
addProtectedChild(_buttonDisableRenderer, DISABLED_RENDERER_Z, -1);
|
addProtectedChild(_buttonDisableRenderer, DISABLED_RENDERER_Z, -1);
|
||||||
|
@ -171,16 +203,19 @@ void Button::ignoreContentAdaptWithSize(bool ignore)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::loadTextures(const char* normal,const char* selected,const char* disabled,TextureResType texType)
|
void Button::loadTextures(const std::string& normal,
|
||||||
|
const std::string& selected,
|
||||||
|
const std::string& disabled,
|
||||||
|
TextureResType texType)
|
||||||
{
|
{
|
||||||
loadTextureNormal(normal,texType);
|
loadTextureNormal(normal,texType);
|
||||||
loadTexturePressed(selected,texType);
|
loadTexturePressed(selected,texType);
|
||||||
loadTextureDisabled(disabled,texType);
|
loadTextureDisabled(disabled,texType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::loadTextureNormal(const char* normal,TextureResType texType)
|
void Button::loadTextureNormal(const std::string& normal,TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!normal || strcmp(normal, "") == 0)
|
if (normal.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -226,9 +261,9 @@ void Button::loadTextureNormal(const char* normal,TextureResType texType)
|
||||||
_normalTextureLoaded = true;
|
_normalTextureLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::loadTexturePressed(const char* selected,TextureResType texType)
|
void Button::loadTexturePressed(const std::string& selected,TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!selected || strcmp(selected, "") == 0)
|
if (selected.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -274,9 +309,9 @@ void Button::loadTexturePressed(const char* selected,TextureResType texType)
|
||||||
_pressedTextureLoaded = true;
|
_pressedTextureLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::loadTextureDisabled(const char* disabled,TextureResType texType)
|
void Button::loadTextureDisabled(const std::string& disabled,TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!disabled || strcmp(disabled, "") == 0)
|
if (disabled.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -662,14 +697,14 @@ float Button::getTitleFontSize() const
|
||||||
return _titleRenderer->getFontSize();
|
return _titleRenderer->getFontSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::setTitleFontName(const char* fontName)
|
void Button::setTitleFontName(const std::string& fontName)
|
||||||
{
|
{
|
||||||
_titleRenderer->setFontName(fontName);
|
_titleRenderer->setFontName(fontName);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Button::getTitleFontName() const
|
const std::string& Button::getTitleFontName() const
|
||||||
{
|
{
|
||||||
return _titleRenderer->getFontName().c_str();
|
return _titleRenderer->getFontName();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Button::getDescription() const
|
std::string Button::getDescription() const
|
||||||
|
@ -710,9 +745,9 @@ void Button::copySpecialProperties(Widget *widget)
|
||||||
{
|
{
|
||||||
_prevIgnoreSize = button->_prevIgnoreSize;
|
_prevIgnoreSize = button->_prevIgnoreSize;
|
||||||
setScale9Enabled(button->_scale9Enabled);
|
setScale9Enabled(button->_scale9Enabled);
|
||||||
loadTextureNormal(button->_normalFileName.c_str(), button->_normalTexType);
|
loadTextureNormal(button->_normalFileName, button->_normalTexType);
|
||||||
loadTexturePressed(button->_clickedFileName.c_str(), button->_pressedTexType);
|
loadTexturePressed(button->_clickedFileName, button->_pressedTexType);
|
||||||
loadTextureDisabled(button->_disabledFileName.c_str(), button->_disabledTexType);
|
loadTextureDisabled(button->_disabledFileName, button->_disabledTexType);
|
||||||
setCapInsetsNormalRenderer(button->_capInsetsNormal);
|
setCapInsetsNormalRenderer(button->_capInsetsNormal);
|
||||||
setCapInsetsPressedRenderer(button->_capInsetsPressed);
|
setCapInsetsPressedRenderer(button->_capInsetsPressed);
|
||||||
setCapInsetsDisabledRenderer(button->_capInsetsDisabled);
|
setCapInsetsDisabledRenderer(button->_capInsetsDisabled);
|
||||||
|
|
|
@ -55,19 +55,35 @@ public:
|
||||||
* Allocates and initializes.
|
* Allocates and initializes.
|
||||||
*/
|
*/
|
||||||
static Button* create();
|
static Button* create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a button with custom textures
|
||||||
|
* @normalImage normal state texture name
|
||||||
|
* @selectedImage selected state texture name
|
||||||
|
* @disableImage disabled state texture name
|
||||||
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
|
*/
|
||||||
|
static Button* create(const std::string& normalImage,
|
||||||
|
const std::string& selectedImage = "",
|
||||||
|
const std::string& disableImage = "",
|
||||||
|
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load textures for button.
|
* Load textures for button.
|
||||||
*
|
*
|
||||||
* @param normal normal state texture.
|
* @param normal normal state texture name.
|
||||||
*
|
*
|
||||||
* @param selected selected state texture.
|
* @param selected selected state texture name.
|
||||||
*
|
*
|
||||||
* @param disabled dark state texture.
|
* @param disabled disabled state texture name.
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadTextures(const char* normal,const char* selected,const char* disabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadTextures(const std::string& normal,
|
||||||
|
const std::string& selected,
|
||||||
|
const std::string& disabled = "",
|
||||||
|
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load normal state texture for button.
|
* Load normal state texture for button.
|
||||||
|
@ -76,7 +92,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadTextureNormal(const char* normal, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadTextureNormal(const std::string& normal, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load selected state texture for button.
|
* Load selected state texture for button.
|
||||||
|
@ -85,7 +101,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadTexturePressed(const char* selected, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadTexturePressed(const std::string& selected, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load dark state texture for button.
|
* Load dark state texture for button.
|
||||||
|
@ -94,7 +110,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadTextureDisabled(const char* disabled, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadTextureDisabled(const std::string& disabled, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets capinsets for button, if button is using scale9 renderer.
|
* Sets capinsets for button, if button is using scale9 renderer.
|
||||||
|
@ -169,11 +185,16 @@ public:
|
||||||
const Color3B& getTitleColor() const;
|
const Color3B& getTitleColor() const;
|
||||||
void setTitleFontSize(float size);
|
void setTitleFontSize(float size);
|
||||||
float getTitleFontSize() const;
|
float getTitleFontSize() const;
|
||||||
void setTitleFontName(const char* fontName);
|
void setTitleFontName(const std::string& fontName);
|
||||||
const char* getTitleFontName() const;
|
const std::string& getTitleFontName() const;
|
||||||
|
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
virtual bool init() override;
|
virtual bool init() override;
|
||||||
|
virtual bool init(const std::string& normalImage,
|
||||||
|
const std::string& selectedImage = "",
|
||||||
|
const std::string& disableImage = "",
|
||||||
|
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void initRenderer() override;
|
virtual void initRenderer() override;
|
||||||
|
|
|
@ -75,6 +75,49 @@ CheckBox* CheckBox::create()
|
||||||
CC_SAFE_DELETE(widget);
|
CC_SAFE_DELETE(widget);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckBox* CheckBox::create(const std::string& backGround,
|
||||||
|
const std::string& backGroundSeleted,
|
||||||
|
const std::string& cross,
|
||||||
|
const std::string& backGroundDisabled,
|
||||||
|
const std::string& frontCrossDisabled,
|
||||||
|
TextureResType texType)
|
||||||
|
{
|
||||||
|
CheckBox *pWidget = new CheckBox;
|
||||||
|
if (pWidget && pWidget->init(backGround,
|
||||||
|
backGroundSeleted,
|
||||||
|
cross,
|
||||||
|
backGroundDisabled,
|
||||||
|
frontCrossDisabled,
|
||||||
|
texType))
|
||||||
|
{
|
||||||
|
pWidget->autorelease();
|
||||||
|
return pWidget;
|
||||||
|
}
|
||||||
|
CC_SAFE_DELETE(pWidget);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CheckBox::init(const std::string& backGround,
|
||||||
|
const std::string& backGroundSeleted,
|
||||||
|
const std::string& cross,
|
||||||
|
const std::string& backGroundDisabled,
|
||||||
|
const std::string& frontCrossDisabled,
|
||||||
|
TextureResType texType)
|
||||||
|
{
|
||||||
|
bool ret = true;
|
||||||
|
do {
|
||||||
|
if (!Widget::init()) {
|
||||||
|
ret = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelectedState(false);
|
||||||
|
setTouchEnabled(true);
|
||||||
|
loadTextures(backGround, backGroundSeleted, cross, backGroundDisabled, frontCrossDisabled,texType);
|
||||||
|
} while (0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
bool CheckBox::init()
|
bool CheckBox::init()
|
||||||
{
|
{
|
||||||
|
@ -102,7 +145,12 @@ void CheckBox::initRenderer()
|
||||||
addProtectedChild(_frontCrossDisabledRenderer, FRONTCROSSDISABLED_RENDERER_Z, -1);
|
addProtectedChild(_frontCrossDisabledRenderer, FRONTCROSSDISABLED_RENDERER_Z, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckBox::loadTextures(const char *backGround, const char *backGroundSelected, const char *cross,const char* backGroundDisabled,const char* frontCrossDisabled,TextureResType texType)
|
void CheckBox::loadTextures(const std::string& backGround,
|
||||||
|
const std::string& backGroundSelected,
|
||||||
|
const std::string& cross,
|
||||||
|
const std::string& backGroundDisabled,
|
||||||
|
const std::string& frontCrossDisabled,
|
||||||
|
TextureResType texType)
|
||||||
{
|
{
|
||||||
loadTextureBackGround(backGround,texType);
|
loadTextureBackGround(backGround,texType);
|
||||||
loadTextureBackGroundSelected(backGroundSelected,texType);
|
loadTextureBackGroundSelected(backGroundSelected,texType);
|
||||||
|
@ -111,9 +159,9 @@ void CheckBox::loadTextures(const char *backGround, const char *backGroundSelect
|
||||||
loadTextureFrontCrossDisabled(frontCrossDisabled,texType);
|
loadTextureFrontCrossDisabled(frontCrossDisabled,texType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckBox::loadTextureBackGround(const char *backGround,TextureResType texType)
|
void CheckBox::loadTextureBackGround(const std::string& backGround,TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!backGround || strcmp(backGround, "") == 0)
|
if (backGround.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -137,9 +185,9 @@ void CheckBox::loadTextureBackGround(const char *backGround,TextureResType texTy
|
||||||
updateRGBAToRenderer(_backGroundBoxRenderer);
|
updateRGBAToRenderer(_backGroundBoxRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckBox::loadTextureBackGroundSelected(const char *backGroundSelected,TextureResType texType)
|
void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!backGroundSelected || strcmp(backGroundSelected, "") == 0)
|
if (backGroundSelected.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -163,9 +211,9 @@ void CheckBox::loadTextureBackGroundSelected(const char *backGroundSelected,Text
|
||||||
updateRGBAToRenderer(_backGroundSelectedBoxRenderer);
|
updateRGBAToRenderer(_backGroundSelectedBoxRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckBox::loadTextureFrontCross(const char *cross,TextureResType texType)
|
void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!cross || strcmp(cross, "") == 0)
|
if (cross.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -189,9 +237,9 @@ void CheckBox::loadTextureFrontCross(const char *cross,TextureResType texType)
|
||||||
updateRGBAToRenderer(_frontCrossRenderer);
|
updateRGBAToRenderer(_frontCrossRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckBox::loadTextureBackGroundDisabled(const char *backGroundDisabled,TextureResType texType)
|
void CheckBox::loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!backGroundDisabled || strcmp(backGroundDisabled, "") == 0)
|
if (backGroundDisabled.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -215,9 +263,9 @@ void CheckBox::loadTextureBackGroundDisabled(const char *backGroundDisabled,Text
|
||||||
updateRGBAToRenderer(_backGroundBoxDisabledRenderer);
|
updateRGBAToRenderer(_backGroundBoxDisabledRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckBox::loadTextureFrontCrossDisabled(const char *frontCrossDisabled,TextureResType texType)
|
void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!frontCrossDisabled || strcmp(frontCrossDisabled, "") == 0)
|
if (frontCrossDisabled.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -526,11 +574,11 @@ void CheckBox::copySpecialProperties(Widget *widget)
|
||||||
CheckBox* checkBox = dynamic_cast<CheckBox*>(widget);
|
CheckBox* checkBox = dynamic_cast<CheckBox*>(widget);
|
||||||
if (checkBox)
|
if (checkBox)
|
||||||
{
|
{
|
||||||
loadTextureBackGround(checkBox->_backGroundFileName.c_str(), checkBox->_backGroundTexType);
|
loadTextureBackGround(checkBox->_backGroundFileName, checkBox->_backGroundTexType);
|
||||||
loadTextureBackGroundSelected(checkBox->_backGroundSelectedFileName.c_str(), checkBox->_backGroundSelectedTexType);
|
loadTextureBackGroundSelected(checkBox->_backGroundSelectedFileName, checkBox->_backGroundSelectedTexType);
|
||||||
loadTextureFrontCross(checkBox->_frontCrossFileName.c_str(), checkBox->_frontCrossTexType);
|
loadTextureFrontCross(checkBox->_frontCrossFileName, checkBox->_frontCrossTexType);
|
||||||
loadTextureBackGroundDisabled(checkBox->_backGroundDisabledFileName.c_str(), checkBox->_backGroundDisabledTexType);
|
loadTextureBackGroundDisabled(checkBox->_backGroundDisabledFileName, checkBox->_backGroundDisabledTexType);
|
||||||
loadTextureFrontCrossDisabled(checkBox->_frontCrossDisabledFileName.c_str(), checkBox->_frontCrossDisabledTexType);
|
loadTextureFrontCrossDisabled(checkBox->_frontCrossDisabledFileName, checkBox->_frontCrossDisabledTexType);
|
||||||
setSelectedState(checkBox->_isSelected);
|
setSelectedState(checkBox->_isSelected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,26 @@ public:
|
||||||
* Allocates and initializes.
|
* Allocates and initializes.
|
||||||
*/
|
*/
|
||||||
static CheckBox* create();
|
static CheckBox* create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create an checkbox
|
||||||
|
*
|
||||||
|
* @param backGround backGround texture.
|
||||||
|
*
|
||||||
|
* @param backGroundSelected backGround selected state texture.
|
||||||
|
*
|
||||||
|
* @param cross cross texture.
|
||||||
|
*
|
||||||
|
* @param frontCrossDisabled cross dark state texture.
|
||||||
|
*
|
||||||
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
|
*/
|
||||||
|
static CheckBox* create(const std::string& backGround,
|
||||||
|
const std::string& backGroundSeleted,
|
||||||
|
const std::string& cross,
|
||||||
|
const std::string& backGroundDisabled,
|
||||||
|
const std::string& frontCrossDisabled,
|
||||||
|
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load textures for checkbox.
|
* Load textures for checkbox.
|
||||||
|
@ -78,7 +98,12 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadTextures(const char* backGround,const char* backGroundSelected,const char* cross,const char* backGroundDisabled,const char* frontCrossDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadTextures(const std::string& backGround,
|
||||||
|
const std::string& backGroundSelected,
|
||||||
|
const std::string& cross,
|
||||||
|
const std::string& backGroundDisabled,
|
||||||
|
const std::string& frontCrossDisabled,
|
||||||
|
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load backGround texture for checkbox.
|
* Load backGround texture for checkbox.
|
||||||
|
@ -87,7 +112,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadTextureBackGround(const char* backGround,TextureResType type = UI_TEX_TYPE_LOCAL);
|
void loadTextureBackGround(const std::string& backGround,TextureResType type = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load backGroundSelected texture for checkbox.
|
* Load backGroundSelected texture for checkbox.
|
||||||
|
@ -96,7 +121,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadTextureBackGroundSelected(const char* backGroundSelected,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load cross texture for checkbox.
|
* Load cross texture for checkbox.
|
||||||
|
@ -105,7 +130,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadTextureFrontCross(const char* cross,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadTextureFrontCross(const std::string&,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load backGroundDisabled texture for checkbox.
|
* Load backGroundDisabled texture for checkbox.
|
||||||
|
@ -114,7 +139,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadTextureBackGroundDisabled(const char* backGroundDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadTextureBackGroundDisabled(const std::string& backGroundDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load frontCrossDisabled texture for checkbox.
|
* Load frontCrossDisabled texture for checkbox.
|
||||||
|
@ -123,7 +148,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadTextureFrontCrossDisabled(const char* frontCrossDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets selcted state for checkbox.
|
* Sets selcted state for checkbox.
|
||||||
|
@ -161,6 +186,12 @@ public:
|
||||||
|
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
virtual bool init() override;
|
virtual bool init() override;
|
||||||
|
virtual bool init(const std::string& backGround,
|
||||||
|
const std::string& backGroundSeleted,
|
||||||
|
const std::string& cross,
|
||||||
|
const std::string& backGroundDisabled,
|
||||||
|
const std::string& frontCrossDisabled,
|
||||||
|
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void initRenderer() override;
|
virtual void initRenderer() override;
|
||||||
|
|
|
@ -53,6 +53,17 @@ ImageView::~ImageView()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageView* ImageView::create(const std::string &imageFileName, TextureResType texType)
|
||||||
|
{
|
||||||
|
ImageView *widget = new ImageView;
|
||||||
|
if (widget && widget->init(imageFileName, texType)) {
|
||||||
|
widget->autorelease();
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
CC_SAFE_DELETE(widget);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
ImageView* ImageView::create()
|
ImageView* ImageView::create()
|
||||||
{
|
{
|
||||||
|
@ -65,6 +76,33 @@ ImageView* ImageView::create()
|
||||||
CC_SAFE_DELETE(widget);
|
CC_SAFE_DELETE(widget);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ImageView::init()
|
||||||
|
{
|
||||||
|
bool ret = true;
|
||||||
|
do {
|
||||||
|
if (!Widget::init()) {
|
||||||
|
ret = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_imageTexType = UI_TEX_TYPE_LOCAL;
|
||||||
|
} while (0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ImageView::init(const std::string &imageFileName, TextureResType texType)
|
||||||
|
{
|
||||||
|
bool bRet = true;
|
||||||
|
do {
|
||||||
|
if (!Widget::init()) {
|
||||||
|
bRet = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->loadTexture(imageFileName, texType);
|
||||||
|
} while (0);
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
void ImageView::initRenderer()
|
void ImageView::initRenderer()
|
||||||
{
|
{
|
||||||
|
@ -72,9 +110,9 @@ void ImageView::initRenderer()
|
||||||
addProtectedChild(_imageRenderer, IMAGE_RENDERER_Z, -1);
|
addProtectedChild(_imageRenderer, IMAGE_RENDERER_Z, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageView::loadTexture(const char *fileName, TextureResType texType)
|
void ImageView::loadTexture(const std::string& fileName, TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!fileName || strcmp(fileName, "") == 0)
|
if (fileName.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +214,7 @@ void ImageView::setScale9Enabled(bool able)
|
||||||
{
|
{
|
||||||
_imageRenderer = Sprite::create();
|
_imageRenderer = Sprite::create();
|
||||||
}
|
}
|
||||||
loadTexture(_textureFile.c_str(),_imageTexType);
|
loadTexture(_textureFile,_imageTexType);
|
||||||
addProtectedChild(_imageRenderer, IMAGE_RENDERER_Z, -1);
|
addProtectedChild(_imageRenderer, IMAGE_RENDERER_Z, -1);
|
||||||
if (_scale9Enabled)
|
if (_scale9Enabled)
|
||||||
{
|
{
|
||||||
|
@ -306,7 +344,7 @@ void ImageView::copySpecialProperties(Widget *widget)
|
||||||
{
|
{
|
||||||
_prevIgnoreSize = imageView->_prevIgnoreSize;
|
_prevIgnoreSize = imageView->_prevIgnoreSize;
|
||||||
setScale9Enabled(imageView->_scale9Enabled);
|
setScale9Enabled(imageView->_scale9Enabled);
|
||||||
loadTexture(imageView->_textureFile.c_str(), imageView->_imageTexType);
|
loadTexture(imageView->_textureFile, imageView->_imageTexType);
|
||||||
setCapInsets(imageView->_capInsets);
|
setCapInsets(imageView->_capInsets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,16 @@ public:
|
||||||
* Allocates and initializes.
|
* Allocates and initializes.
|
||||||
*/
|
*/
|
||||||
static ImageView* create();
|
static ImageView* create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a imageview
|
||||||
|
*
|
||||||
|
* @param fileName file name of texture.
|
||||||
|
*
|
||||||
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
|
*/
|
||||||
|
static ImageView* create(const std::string& imageFileName, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load texture for imageview.
|
* Load texture for imageview.
|
||||||
|
@ -63,7 +73,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadTexture(const char* fileName,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadTexture(const std::string& fileName,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the texture rect of the ImageView in points.
|
* Updates the texture rect of the ImageView in points.
|
||||||
|
@ -102,6 +112,12 @@ public:
|
||||||
|
|
||||||
virtual const Size& getContentSize() const override;
|
virtual const Size& getContentSize() const override;
|
||||||
virtual Node* getVirtualRenderer() override;
|
virtual Node* getVirtualRenderer() override;
|
||||||
|
|
||||||
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
|
//initializes state of widget.
|
||||||
|
virtual bool init() override;
|
||||||
|
virtual bool init(const std::string& imageFileName, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void initRenderer() override;
|
virtual void initRenderer() override;
|
||||||
virtual void onSizeChanged() override;
|
virtual void onSizeChanged() override;
|
||||||
|
|
|
@ -1111,7 +1111,7 @@ void Layout::setBackGroundImageScale9Enabled(bool able)
|
||||||
_backGroundImage = nullptr;
|
_backGroundImage = nullptr;
|
||||||
_backGroundScale9Enabled = able;
|
_backGroundScale9Enabled = able;
|
||||||
addBackGroundImage();
|
addBackGroundImage();
|
||||||
setBackGroundImage(_backGroundImageFileName.c_str(),_bgImageTexType);
|
setBackGroundImage(_backGroundImageFileName,_bgImageTexType);
|
||||||
setBackGroundImageCapInsets(_backGroundImageCapInsets);
|
setBackGroundImageCapInsets(_backGroundImageCapInsets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1120,9 +1120,9 @@ bool Layout::isBackGroundImageScale9Enabled()
|
||||||
return _backGroundScale9Enabled;
|
return _backGroundScale9Enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layout::setBackGroundImage(const char* fileName,TextureResType texType)
|
void Layout::setBackGroundImage(const std::string& fileName,TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!fileName || strcmp(fileName, "") == 0)
|
if (fileName.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1519,7 +1519,7 @@ void Layout::copySpecialProperties(Widget *widget)
|
||||||
if (layout)
|
if (layout)
|
||||||
{
|
{
|
||||||
setBackGroundImageScale9Enabled(layout->_backGroundScale9Enabled);
|
setBackGroundImageScale9Enabled(layout->_backGroundScale9Enabled);
|
||||||
setBackGroundImage(layout->_backGroundImageFileName.c_str(),layout->_bgImageTexType);
|
setBackGroundImage(layout->_backGroundImageFileName,layout->_bgImageTexType);
|
||||||
setBackGroundImageCapInsets(layout->_backGroundImageCapInsets);
|
setBackGroundImageCapInsets(layout->_backGroundImageCapInsets);
|
||||||
setBackGroundColorType(layout->_colorType);
|
setBackGroundColorType(layout->_colorType);
|
||||||
setBackGroundColor(layout->_cColor);
|
setBackGroundColor(layout->_cColor);
|
||||||
|
|
|
@ -86,7 +86,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see TextureResType. UI_TEX_TYPE_LOCAL means local file, UI_TEX_TYPE_PLIST means sprite frame.
|
* @param texType @see TextureResType. UI_TEX_TYPE_LOCAL means local file, UI_TEX_TYPE_PLIST means sprite frame.
|
||||||
*/
|
*/
|
||||||
void setBackGroundImage(const char* fileName,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void setBackGroundImage(const std::string& fileName,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a background image capinsets for layout, if the background image is a scale9 render.
|
* Sets a background image capinsets for layout, if the background image is a scale9 render.
|
||||||
|
|
|
@ -63,6 +63,19 @@ LoadingBar* LoadingBar::create()
|
||||||
CC_SAFE_DELETE(widget);
|
CC_SAFE_DELETE(widget);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoadingBar* LoadingBar::create(const std::string &textureName, int percentage)
|
||||||
|
{
|
||||||
|
LoadingBar* widget = new LoadingBar;
|
||||||
|
if (widget && widget->init()) {
|
||||||
|
widget->autorelease();
|
||||||
|
widget->loadTexture(textureName);
|
||||||
|
widget->setPercent(percentage);
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
CC_SAFE_DELETE(widget);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void LoadingBar::initRenderer()
|
void LoadingBar::initRenderer()
|
||||||
{
|
{
|
||||||
|
@ -105,9 +118,9 @@ int LoadingBar::getDirection()
|
||||||
return _barType;
|
return _barType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadingBar::loadTexture(const char* texture,TextureResType texType)
|
void LoadingBar::loadTexture(const std::string& texture,TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!texture || strcmp(texture, "") == 0)
|
if (texture.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +195,7 @@ void LoadingBar::setScale9Enabled(bool enabled)
|
||||||
{
|
{
|
||||||
_barRenderer = Sprite::create();
|
_barRenderer = Sprite::create();
|
||||||
}
|
}
|
||||||
loadTexture(_textureFile.c_str(),_renderBarTexType);
|
loadTexture(_textureFile,_renderBarTexType);
|
||||||
addProtectedChild(_barRenderer, BAR_RENDERER_Z, -1);
|
addProtectedChild(_barRenderer, BAR_RENDERER_Z, -1);
|
||||||
if (_scale9Enabled)
|
if (_scale9Enabled)
|
||||||
{
|
{
|
||||||
|
@ -358,7 +371,7 @@ void LoadingBar::copySpecialProperties(Widget *widget)
|
||||||
{
|
{
|
||||||
_prevIgnoreSize = loadingBar->_prevIgnoreSize;
|
_prevIgnoreSize = loadingBar->_prevIgnoreSize;
|
||||||
setScale9Enabled(loadingBar->_scale9Enabled);
|
setScale9Enabled(loadingBar->_scale9Enabled);
|
||||||
loadTexture(loadingBar->_textureFile.c_str(), loadingBar->_renderBarTexType);
|
loadTexture(loadingBar->_textureFile, loadingBar->_renderBarTexType);
|
||||||
setCapInsets(loadingBar->_capInsets);
|
setCapInsets(loadingBar->_capInsets);
|
||||||
setPercent(loadingBar->_percent);
|
setPercent(loadingBar->_percent);
|
||||||
setDirection(loadingBar->_barType);
|
setDirection(loadingBar->_barType);
|
||||||
|
|
|
@ -61,6 +61,11 @@ public:
|
||||||
*/
|
*/
|
||||||
static LoadingBar* create();
|
static LoadingBar* create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a LoadingBar with a texture and a percentage
|
||||||
|
**/
|
||||||
|
static LoadingBar* create(const std::string& textureName, int percentage = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the progress direction of loadingbar.
|
* Changes the progress direction of loadingbar.
|
||||||
*
|
*
|
||||||
|
@ -86,7 +91,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadTexture(const char* texture,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadTexture(const std::string& texture,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the progress direction of loadingbar.
|
* Changes the progress direction of loadingbar.
|
||||||
|
|
|
@ -111,9 +111,9 @@ void Slider::initRenderer()
|
||||||
addProtectedChild(_slidBallRenderer, SLIDBALL_RENDERER_Z, -1);
|
addProtectedChild(_slidBallRenderer, SLIDBALL_RENDERER_Z, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slider::loadBarTexture(const char* fileName, TextureResType texType)
|
void Slider::loadBarTexture(const std::string& fileName, TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!fileName || strcmp(fileName, "") == 0)
|
if (fileName.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -149,9 +149,9 @@ void Slider::loadBarTexture(const char* fileName, TextureResType texType)
|
||||||
progressBarRendererScaleChangedWithSize();
|
progressBarRendererScaleChangedWithSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slider::loadProgressBarTexture(const char *fileName, TextureResType texType)
|
void Slider::loadProgressBarTexture(const std::string& fileName, TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!fileName || strcmp(fileName, "") == 0)
|
if (fileName.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -210,8 +210,8 @@ void Slider::setScale9Enabled(bool able)
|
||||||
_barRenderer = Sprite::create();
|
_barRenderer = Sprite::create();
|
||||||
_progressBarRenderer = Sprite::create();
|
_progressBarRenderer = Sprite::create();
|
||||||
}
|
}
|
||||||
loadBarTexture(_textureFile.c_str(), _barTexType);
|
loadBarTexture(_textureFile, _barTexType);
|
||||||
loadProgressBarTexture(_progressBarTextureFile.c_str(), _progressBarTexType);
|
loadProgressBarTexture(_progressBarTextureFile, _progressBarTexType);
|
||||||
addProtectedChild(_barRenderer, BASEBAR_RENDERER_Z, -1);
|
addProtectedChild(_barRenderer, BASEBAR_RENDERER_Z, -1);
|
||||||
addProtectedChild(_progressBarRenderer, PROGRESSBAR_RENDERER_Z, -1);
|
addProtectedChild(_progressBarRenderer, PROGRESSBAR_RENDERER_Z, -1);
|
||||||
if (_scale9Enabled)
|
if (_scale9Enabled)
|
||||||
|
@ -278,16 +278,16 @@ const Rect& Slider::getCapInsetsProgressBarRebderer()
|
||||||
return _capInsetsProgressBarRenderer;
|
return _capInsetsProgressBarRenderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slider::loadSlidBallTextures(const char* normal,const char* pressed,const char* disabled,TextureResType texType)
|
void Slider::loadSlidBallTextures(const std::string& normal,const std::string& pressed,const std::string& disabled,TextureResType texType)
|
||||||
{
|
{
|
||||||
loadSlidBallTextureNormal(normal, texType);
|
loadSlidBallTextureNormal(normal, texType);
|
||||||
loadSlidBallTexturePressed(pressed,texType);
|
loadSlidBallTexturePressed(pressed,texType);
|
||||||
loadSlidBallTextureDisabled(disabled,texType);
|
loadSlidBallTextureDisabled(disabled,texType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slider::loadSlidBallTextureNormal(const char* normal,TextureResType texType)
|
void Slider::loadSlidBallTextureNormal(const std::string& normal,TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!normal || strcmp(normal, "") == 0)
|
if (normal.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -307,9 +307,9 @@ void Slider::loadSlidBallTextureNormal(const char* normal,TextureResType texType
|
||||||
updateRGBAToRenderer(_slidBallNormalRenderer);
|
updateRGBAToRenderer(_slidBallNormalRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slider::loadSlidBallTexturePressed(const char* pressed,TextureResType texType)
|
void Slider::loadSlidBallTexturePressed(const std::string& pressed,TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!pressed || strcmp(pressed, "") == 0)
|
if (pressed.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -329,9 +329,9 @@ void Slider::loadSlidBallTexturePressed(const char* pressed,TextureResType texTy
|
||||||
updateRGBAToRenderer(_slidBallPressedRenderer);
|
updateRGBAToRenderer(_slidBallPressedRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slider::loadSlidBallTextureDisabled(const char* disabled,TextureResType texType)
|
void Slider::loadSlidBallTextureDisabled(const std::string& disabled,TextureResType texType)
|
||||||
{
|
{
|
||||||
if (!disabled || strcmp(disabled, "") == 0)
|
if (disabled.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -596,11 +596,11 @@ void Slider::copySpecialProperties(Widget *widget)
|
||||||
{
|
{
|
||||||
_prevIgnoreSize = slider->_prevIgnoreSize;
|
_prevIgnoreSize = slider->_prevIgnoreSize;
|
||||||
setScale9Enabled(slider->_scale9Enabled);
|
setScale9Enabled(slider->_scale9Enabled);
|
||||||
loadBarTexture(slider->_textureFile.c_str(), slider->_barTexType);
|
loadBarTexture(slider->_textureFile, slider->_barTexType);
|
||||||
loadProgressBarTexture(slider->_progressBarTextureFile.c_str(), slider->_progressBarTexType);
|
loadProgressBarTexture(slider->_progressBarTextureFile, slider->_progressBarTexType);
|
||||||
loadSlidBallTextureNormal(slider->_slidBallNormalTextureFile.c_str(), slider->_ballNTexType);
|
loadSlidBallTextureNormal(slider->_slidBallNormalTextureFile, slider->_ballNTexType);
|
||||||
loadSlidBallTexturePressed(slider->_slidBallPressedTextureFile.c_str(), slider->_ballPTexType);
|
loadSlidBallTexturePressed(slider->_slidBallPressedTextureFile, slider->_ballPTexType);
|
||||||
loadSlidBallTextureDisabled(slider->_slidBallDisabledTextureFile.c_str(), slider->_ballDTexType);
|
loadSlidBallTextureDisabled(slider->_slidBallDisabledTextureFile, slider->_ballDTexType);
|
||||||
setPercent(slider->getPercent());
|
setPercent(slider->getPercent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadBarTexture(const char* fileName,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadBarTexture(const std::string& fileName,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets if slider is using scale9 renderer.
|
* Sets if slider is using scale9 renderer.
|
||||||
|
@ -118,7 +118,10 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadSlidBallTextures(const char* normal,const char* pressed,const char* disabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadSlidBallTextures(const std::string& normal,
|
||||||
|
const std::string& pressed,
|
||||||
|
const std::string& disabled,
|
||||||
|
TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load normal state texture for slider ball.
|
* Load normal state texture for slider ball.
|
||||||
|
@ -127,7 +130,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadSlidBallTextureNormal(const char* normal,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadSlidBallTextureNormal(const std::string& normal,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load selected state texture for slider ball.
|
* Load selected state texture for slider ball.
|
||||||
|
@ -136,7 +139,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadSlidBallTexturePressed(const char* pressed,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadSlidBallTexturePressed(const std::string& pressed,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load dark state texture for slider ball.
|
* Load dark state texture for slider ball.
|
||||||
|
@ -145,7 +148,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadSlidBallTextureDisabled(const char* disabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadSlidBallTextureDisabled(const std::string& disabled,TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load dark state texture for slider progress bar.
|
* Load dark state texture for slider progress bar.
|
||||||
|
@ -154,7 +157,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param texType @see UI_TEX_TYPE_LOCAL
|
* @param texType @see UI_TEX_TYPE_LOCAL
|
||||||
*/
|
*/
|
||||||
void loadProgressBarTexture(const char* fileName, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
void loadProgressBarTexture(const std::string& fileName, TextureResType texType = UI_TEX_TYPE_LOCAL);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the progress direction of slider.
|
* Changes the progress direction of slider.
|
||||||
|
|
|
@ -68,6 +68,32 @@ bool Text::init()
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Text* Text::create(const std::string &textContent, const std::string &fontName, int fontSize)
|
||||||
|
{
|
||||||
|
Text *text = new Text;
|
||||||
|
if (text && text->init(textContent, fontName, fontSize)) {
|
||||||
|
text->autorelease();
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
CC_SAFE_DELETE(text);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Text::init(const std::string &textContent, const std::string &fontName, int fontSize)
|
||||||
|
{
|
||||||
|
bool ret = true;
|
||||||
|
do {
|
||||||
|
if (!Widget::init()) {
|
||||||
|
ret = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this->setText(textContent);
|
||||||
|
this->setFontName(fontName);
|
||||||
|
this->setFontSize(fontSize);
|
||||||
|
} while (0);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void Text::initRenderer()
|
void Text::initRenderer()
|
||||||
{
|
{
|
||||||
|
@ -287,7 +313,7 @@ void Text::copySpecialProperties(Widget *widget)
|
||||||
Text* label = dynamic_cast<Text*>(widget);
|
Text* label = dynamic_cast<Text*>(widget);
|
||||||
if (label)
|
if (label)
|
||||||
{
|
{
|
||||||
setFontName(label->_fontName.c_str());
|
setFontName(label->_fontName);
|
||||||
setFontSize(label->_labelRenderer->getFontSize());
|
setFontSize(label->_labelRenderer->getFontSize());
|
||||||
setText(label->getStringValue());
|
setText(label->getStringValue());
|
||||||
setTouchScaleChangeEnabled(label->_touchScaleChangeEnabled);
|
setTouchScaleChangeEnabled(label->_touchScaleChangeEnabled);
|
||||||
|
|
|
@ -55,6 +55,13 @@ public:
|
||||||
* Allocates and initializes.
|
* Allocates and initializes.
|
||||||
*/
|
*/
|
||||||
static Text* create();
|
static Text* create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a Text object with textContent, fontName and fontSize
|
||||||
|
*/
|
||||||
|
static Text* create(const std::string& textContent,
|
||||||
|
const std::string& fontName,
|
||||||
|
int fontSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the string value of label.
|
* Changes the string value of label.
|
||||||
|
@ -137,6 +144,9 @@ public:
|
||||||
|
|
||||||
CC_CONSTRUCTOR_ACCESS:
|
CC_CONSTRUCTOR_ACCESS:
|
||||||
virtual bool init() override;
|
virtual bool init() override;
|
||||||
|
virtual bool init(const std::string& textContent,
|
||||||
|
const std::string& fontName,
|
||||||
|
int fontSize);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void initRenderer() override;
|
virtual void initRenderer() override;
|
||||||
|
|
|
@ -64,6 +64,23 @@ void TextAtlas::initRenderer()
|
||||||
_labelAtlasRenderer = LabelAtlas::create();
|
_labelAtlasRenderer = LabelAtlas::create();
|
||||||
addProtectedChild(_labelAtlasRenderer, LABELATLAS_RENDERER_Z, -1);
|
addProtectedChild(_labelAtlasRenderer, LABELATLAS_RENDERER_Z, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextAtlas* TextAtlas::create(const std::string &stringValue,
|
||||||
|
const std::string &charMapFile,
|
||||||
|
int itemWidth,
|
||||||
|
int itemHeight,
|
||||||
|
const std::string &startCharMap)
|
||||||
|
{
|
||||||
|
TextAtlas* widget = new TextAtlas();
|
||||||
|
if (widget && widget->init())
|
||||||
|
{
|
||||||
|
widget->autorelease();
|
||||||
|
widget->setProperty(stringValue, charMapFile, itemWidth, itemHeight, startCharMap);
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
CC_SAFE_DELETE(widget);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void TextAtlas::setProperty(const std::string& stringValue, const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap)
|
void TextAtlas::setProperty(const std::string& stringValue, const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,8 +56,21 @@ public:
|
||||||
*/
|
*/
|
||||||
static TextAtlas* create();
|
static TextAtlas* create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create a LabelAtlas from a char map file
|
||||||
|
*/
|
||||||
|
static TextAtlas* create(const std::string& stringValue,
|
||||||
|
const std::string& charMapFile,
|
||||||
|
int itemWidth,
|
||||||
|
int itemHeight,
|
||||||
|
const std::string& startCharMap);
|
||||||
|
|
||||||
/** initializes the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
|
/** initializes the LabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */
|
||||||
void setProperty(const std::string& stringValue,const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap);
|
void setProperty(const std::string& stringValue,
|
||||||
|
const std::string& charMapFile,
|
||||||
|
int itemWidth,
|
||||||
|
int itemHeight,
|
||||||
|
const std::string& startCharMap);
|
||||||
|
|
||||||
//set string value for labelatlas.
|
//set string value for labelatlas.
|
||||||
void setStringValue(const std::string& value);
|
void setStringValue(const std::string& value);
|
||||||
|
|
|
@ -56,6 +56,20 @@ TextBMFont* TextBMFont::create()
|
||||||
CC_SAFE_DELETE(widget);
|
CC_SAFE_DELETE(widget);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextBMFont* TextBMFont::create(const std::string &text, const std::string &filename)
|
||||||
|
{
|
||||||
|
TextBMFont* widget = new TextBMFont();
|
||||||
|
if (widget && widget->init())
|
||||||
|
{
|
||||||
|
widget->setFntFile(filename);
|
||||||
|
widget->setText(text);
|
||||||
|
widget->autorelease();
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
CC_SAFE_DELETE(widget);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void TextBMFont::initRenderer()
|
void TextBMFont::initRenderer()
|
||||||
{
|
{
|
||||||
|
@ -63,9 +77,9 @@ void TextBMFont::initRenderer()
|
||||||
addProtectedChild(_labelBMFontRenderer, LABELBMFONT_RENDERER_Z, -1);
|
addProtectedChild(_labelBMFontRenderer, LABELBMFONT_RENDERER_Z, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBMFont::setFntFile(const char *fileName)
|
void TextBMFont::setFntFile(const std::string& fileName)
|
||||||
{
|
{
|
||||||
if (!fileName || strcmp(fileName, "") == 0)
|
if (fileName.empty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -74,15 +88,11 @@ void TextBMFont::setFntFile(const char *fileName)
|
||||||
updateAnchorPoint();
|
updateAnchorPoint();
|
||||||
labelBMFontScaleChangedWithSize();
|
labelBMFontScaleChangedWithSize();
|
||||||
_fntFileHasInit = true;
|
_fntFileHasInit = true;
|
||||||
setText(_stringValue.c_str());
|
setText(_stringValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBMFont::setText(const char* value)
|
void TextBMFont::setText(const std::string& value)
|
||||||
{
|
{
|
||||||
if (!value)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_stringValue = value;
|
_stringValue = value;
|
||||||
if (!_fntFileHasInit)
|
if (!_fntFileHasInit)
|
||||||
{
|
{
|
||||||
|
@ -92,9 +102,9 @@ void TextBMFont::setText(const char* value)
|
||||||
labelBMFontScaleChangedWithSize();
|
labelBMFontScaleChangedWithSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TextBMFont::getStringValue()
|
const std::string TextBMFont::getStringValue()
|
||||||
{
|
{
|
||||||
return _stringValue.c_str();
|
return _stringValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBMFont::setAnchorPoint(const Point &pt)
|
void TextBMFont::setAnchorPoint(const Point &pt)
|
||||||
|
@ -171,8 +181,8 @@ void TextBMFont::copySpecialProperties(Widget *widget)
|
||||||
TextBMFont* labelBMFont = dynamic_cast<TextBMFont*>(widget);
|
TextBMFont* labelBMFont = dynamic_cast<TextBMFont*>(widget);
|
||||||
if (labelBMFont)
|
if (labelBMFont)
|
||||||
{
|
{
|
||||||
setFntFile(labelBMFont->_fntFileName.c_str());
|
setFntFile(labelBMFont->_fntFileName);
|
||||||
setText(labelBMFont->_stringValue.c_str());
|
setText(labelBMFont->_stringValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,14 +56,16 @@ public:
|
||||||
*/
|
*/
|
||||||
static TextBMFont* create();
|
static TextBMFont* create();
|
||||||
|
|
||||||
|
static TextBMFont* create(const std::string& text, const std::string& filename);
|
||||||
|
|
||||||
/** init a bitmap font atlas with an initial string and the FNT file */
|
/** init a bitmap font atlas with an initial string and the FNT file */
|
||||||
void setFntFile(const char* fileName);
|
void setFntFile(const std::string& fileName);
|
||||||
|
|
||||||
/** set string value for labelbmfont*/
|
/** set string value for labelbmfont*/
|
||||||
void setText(const char* value);
|
void setText(const std::string& value);
|
||||||
|
|
||||||
/** get string value for labelbmfont*/
|
/** get string value for labelbmfont*/
|
||||||
const char* getStringValue();
|
const std::string getStringValue();
|
||||||
virtual void setAnchorPoint(const Point &pt) override;
|
virtual void setAnchorPoint(const Point &pt) override;
|
||||||
virtual const Size& getContentSize() const override;
|
virtual const Size& getContentSize() const override;
|
||||||
virtual Node* getVirtualRenderer() override;
|
virtual Node* getVirtualRenderer() override;
|
||||||
|
|
|
@ -386,6 +386,22 @@ TextField* TextField::create()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextField* TextField::create(const std::string &placeholder, const std::string &fontName, int fontSize)
|
||||||
|
{
|
||||||
|
TextField* widget = new TextField();
|
||||||
|
if (widget && widget->init())
|
||||||
|
{
|
||||||
|
widget->setTouchEnabled(true);
|
||||||
|
widget->setPlaceHolder(placeholder);
|
||||||
|
widget->setFontName(fontName);
|
||||||
|
widget->setFontSize(fontSize);
|
||||||
|
widget->autorelease();
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
CC_SAFE_DELETE(widget);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool TextField::init()
|
bool TextField::init()
|
||||||
{
|
{
|
||||||
if (Widget::init())
|
if (Widget::init())
|
||||||
|
|
|
@ -110,6 +110,9 @@ public:
|
||||||
TextField();
|
TextField();
|
||||||
virtual ~TextField();
|
virtual ~TextField();
|
||||||
static TextField* create();
|
static TextField* create();
|
||||||
|
static TextField* create(const std::string& placeholder,
|
||||||
|
const std::string& fontName,
|
||||||
|
int fontSize);
|
||||||
void setTouchSize(const Size &size);
|
void setTouchSize(const Size &size);
|
||||||
Size getTouchSize();
|
Size getTouchSize();
|
||||||
void setTouchAreaEnabled(bool enable);
|
void setTouchAreaEnabled(bool enable);
|
||||||
|
|
|
@ -49,8 +49,8 @@ typedef enum
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
UI_TEX_TYPE_LOCAL,
|
UI_TEX_TYPE_LOCAL = 0,
|
||||||
UI_TEX_TYPE_PLIST
|
UI_TEX_TYPE_PLIST = 1
|
||||||
}TextureResType;
|
}TextureResType;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
|
|
@ -141,7 +141,7 @@ Please refer to [ReadMe](../README.md)
|
||||||
|
|
||||||
# Highlights of v3.0
|
# Highlights of v3.0
|
||||||
|
|
||||||
* Replaced Objective-C patters with C++ (C++11) patterns and best practices
|
* Replaced Objective-C patterns with C++ (C++11) patterns and best practices
|
||||||
* Improved Labels
|
* Improved Labels
|
||||||
* Improved renderer (much faster than in v2.2!!)
|
* Improved renderer (much faster than in v2.2!!)
|
||||||
* New Event Dispatcher
|
* New Event Dispatcher
|
||||||
|
|
|
@ -458,16 +458,14 @@ void Scale9Sprite::updatePositions()
|
||||||
_centre->setPosition(Point(leftWidth, bottomHeight));
|
_centre->setPosition(Point(leftWidth, bottomHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scale9Sprite::initWithFile(const char* file, const Rect& rect, const Rect& capInsets)
|
bool Scale9Sprite::initWithFile(const std::string& file, const Rect& rect, const Rect& capInsets)
|
||||||
{
|
{
|
||||||
CCASSERT(file != NULL, "Invalid file for sprite");
|
|
||||||
|
|
||||||
SpriteBatchNode *batchnode = SpriteBatchNode::create(file, 9);
|
SpriteBatchNode *batchnode = SpriteBatchNode::create(file, 9);
|
||||||
bool pReturn = this->initWithBatchNode(batchnode, rect, capInsets);
|
bool pReturn = this->initWithBatchNode(batchnode, rect, capInsets);
|
||||||
return pReturn;
|
return pReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scale9Sprite* Scale9Sprite::create(const char* file, const Rect& rect, const Rect& capInsets)
|
Scale9Sprite* Scale9Sprite::create(const std::string& file, const Rect& rect, const Rect& capInsets)
|
||||||
{
|
{
|
||||||
Scale9Sprite* pReturn = new Scale9Sprite();
|
Scale9Sprite* pReturn = new Scale9Sprite();
|
||||||
if ( pReturn && pReturn->initWithFile(file, rect, capInsets) )
|
if ( pReturn && pReturn->initWithFile(file, rect, capInsets) )
|
||||||
|
@ -479,14 +477,13 @@ Scale9Sprite* Scale9Sprite::create(const char* file, const Rect& rect, const Re
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scale9Sprite::initWithFile(const char* file, const Rect& rect)
|
bool Scale9Sprite::initWithFile(const std::string& file, const Rect& rect)
|
||||||
{
|
{
|
||||||
CCASSERT(file != NULL, "Invalid file for sprite");
|
|
||||||
bool pReturn = this->initWithFile(file, rect, Rect::ZERO);
|
bool pReturn = this->initWithFile(file, rect, Rect::ZERO);
|
||||||
return pReturn;
|
return pReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scale9Sprite* Scale9Sprite::create(const char* file, const Rect& rect)
|
Scale9Sprite* Scale9Sprite::create(const std::string& file, const Rect& rect)
|
||||||
{
|
{
|
||||||
Scale9Sprite* pReturn = new Scale9Sprite();
|
Scale9Sprite* pReturn = new Scale9Sprite();
|
||||||
if ( pReturn && pReturn->initWithFile(file, rect) )
|
if ( pReturn && pReturn->initWithFile(file, rect) )
|
||||||
|
@ -499,13 +496,13 @@ Scale9Sprite* Scale9Sprite::create(const char* file, const Rect& rect)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Scale9Sprite::initWithFile(const Rect& capInsets, const char* file)
|
bool Scale9Sprite::initWithFile(const Rect& capInsets, const std::string& file)
|
||||||
{
|
{
|
||||||
bool pReturn = this->initWithFile(file, Rect::ZERO, capInsets);
|
bool pReturn = this->initWithFile(file, Rect::ZERO, capInsets);
|
||||||
return pReturn;
|
return pReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scale9Sprite* Scale9Sprite::create(const Rect& capInsets, const char* file)
|
Scale9Sprite* Scale9Sprite::create(const Rect& capInsets, const std::string& file)
|
||||||
{
|
{
|
||||||
Scale9Sprite* pReturn = new Scale9Sprite();
|
Scale9Sprite* pReturn = new Scale9Sprite();
|
||||||
if ( pReturn && pReturn->initWithFile(capInsets, file) )
|
if ( pReturn && pReturn->initWithFile(capInsets, file) )
|
||||||
|
@ -517,14 +514,14 @@ Scale9Sprite* Scale9Sprite::create(const Rect& capInsets, const char* file)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scale9Sprite::initWithFile(const char* file)
|
bool Scale9Sprite::initWithFile(const std::string& file)
|
||||||
{
|
{
|
||||||
bool pReturn = this->initWithFile(file, Rect::ZERO);
|
bool pReturn = this->initWithFile(file, Rect::ZERO);
|
||||||
return pReturn;
|
return pReturn;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Scale9Sprite* Scale9Sprite::create(const char* file)
|
Scale9Sprite* Scale9Sprite::create(const std::string& file)
|
||||||
{
|
{
|
||||||
Scale9Sprite* pReturn = new Scale9Sprite();
|
Scale9Sprite* pReturn = new Scale9Sprite();
|
||||||
if ( pReturn && pReturn->initWithFile(file) )
|
if ( pReturn && pReturn->initWithFile(file) )
|
||||||
|
@ -578,7 +575,7 @@ Scale9Sprite* Scale9Sprite::createWithSpriteFrame(SpriteFrame* spriteFrame)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scale9Sprite::initWithSpriteFrameName(const char* spriteFrameName, const Rect& capInsets)
|
bool Scale9Sprite::initWithSpriteFrameName(const std::string& spriteFrameName, const Rect& capInsets)
|
||||||
{
|
{
|
||||||
CCASSERT((SpriteFrameCache::getInstance()) != NULL, "SpriteFrameCache::getInstance() must be non-NULL");
|
CCASSERT((SpriteFrameCache::getInstance()) != NULL, "SpriteFrameCache::getInstance() must be non-NULL");
|
||||||
|
|
||||||
|
@ -591,7 +588,7 @@ bool Scale9Sprite::initWithSpriteFrameName(const char* spriteFrameName, const Re
|
||||||
return pReturn;
|
return pReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const char* spriteFrameName, const Rect& capInsets)
|
Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const std::string& spriteFrameName, const Rect& capInsets)
|
||||||
{
|
{
|
||||||
Scale9Sprite* pReturn = new Scale9Sprite();
|
Scale9Sprite* pReturn = new Scale9Sprite();
|
||||||
if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName, capInsets) )
|
if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName, capInsets) )
|
||||||
|
@ -603,16 +600,14 @@ Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const char* spriteFrameNam
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scale9Sprite::initWithSpriteFrameName(const char* spriteFrameName)
|
bool Scale9Sprite::initWithSpriteFrameName(const std::string& spriteFrameName)
|
||||||
{
|
{
|
||||||
bool pReturn = this->initWithSpriteFrameName(spriteFrameName, Rect::ZERO);
|
bool pReturn = this->initWithSpriteFrameName(spriteFrameName, Rect::ZERO);
|
||||||
return pReturn;
|
return pReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const char* spriteFrameName)
|
Scale9Sprite* Scale9Sprite::createWithSpriteFrameName(const std::string& spriteFrameName)
|
||||||
{
|
{
|
||||||
CCASSERT(spriteFrameName != NULL, "spriteFrameName must be non-NULL");
|
|
||||||
|
|
||||||
Scale9Sprite* pReturn = new Scale9Sprite();
|
Scale9Sprite* pReturn = new Scale9Sprite();
|
||||||
if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName) )
|
if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
*
|
*
|
||||||
* @see initWithFile(const char *file, const Rect& rect, const Rect& capInsets)
|
* @see initWithFile(const char *file, const Rect& rect, const Rect& capInsets)
|
||||||
*/
|
*/
|
||||||
static Scale9Sprite* create(const char* file, const Rect& rect, const Rect& capInsets);
|
static Scale9Sprite* create(const std::string& file, const Rect& rect, const Rect& capInsets);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a 9-slice sprite with a texture file. The whole texture will be
|
* Creates a 9-slice sprite with a texture file. The whole texture will be
|
||||||
|
@ -83,7 +83,7 @@ public:
|
||||||
*
|
*
|
||||||
* @see initWithFile(const Rect& capInsets, const char *file)
|
* @see initWithFile(const Rect& capInsets, const char *file)
|
||||||
*/
|
*/
|
||||||
static Scale9Sprite* create(const Rect& capInsets, const char* file);
|
static Scale9Sprite* create(const Rect& capInsets, const std::string& file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a 9-slice sprite with a texture file and a delimitation zone. The
|
* Creates a 9-slice sprite with a texture file and a delimitation zone. The
|
||||||
|
@ -91,7 +91,7 @@ public:
|
||||||
*
|
*
|
||||||
* @see initWithFile(const char *file, const Rect& rect)
|
* @see initWithFile(const char *file, const Rect& rect)
|
||||||
*/
|
*/
|
||||||
static Scale9Sprite* create(const char* file, const Rect& rect);
|
static Scale9Sprite* create(const std::string& file, const Rect& rect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a 9-slice sprite with a texture file. The whole texture will be
|
* Creates a 9-slice sprite with a texture file. The whole texture will be
|
||||||
|
@ -99,7 +99,7 @@ public:
|
||||||
*
|
*
|
||||||
* @see initWithFile(const char *file)
|
* @see initWithFile(const char *file)
|
||||||
*/
|
*/
|
||||||
static Scale9Sprite* create(const char* file);
|
static Scale9Sprite* create(const std::string& file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a 9-slice sprite with an sprite frame.
|
* Creates a 9-slice sprite with an sprite frame.
|
||||||
|
@ -129,7 +129,7 @@ public:
|
||||||
*
|
*
|
||||||
* @see initWithSpriteFrameName(const char *spriteFrameName)
|
* @see initWithSpriteFrameName(const char *spriteFrameName)
|
||||||
*/
|
*/
|
||||||
static Scale9Sprite* createWithSpriteFrameName(const char*spriteFrameName);
|
static Scale9Sprite* createWithSpriteFrameName(const std::string& spriteFrameName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a 9-slice sprite with an sprite frame name and the centre of its
|
* Creates a 9-slice sprite with an sprite frame name and the centre of its
|
||||||
|
@ -140,7 +140,7 @@ public:
|
||||||
*
|
*
|
||||||
* @see initWithSpriteFrameName(const char *spriteFrameName, const Rect& capInsets)
|
* @see initWithSpriteFrameName(const char *spriteFrameName, const Rect& capInsets)
|
||||||
*/
|
*/
|
||||||
static Scale9Sprite* createWithSpriteFrameName(const char*spriteFrameName, const Rect& capInsets);
|
static Scale9Sprite* createWithSpriteFrameName(const std::string& spriteFrameName, const Rect& capInsets);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a 9-slice sprite with a texture file, a delimitation zone and
|
* Initializes a 9-slice sprite with a texture file, a delimitation zone and
|
||||||
|
@ -155,7 +155,7 @@ public:
|
||||||
* texture's full rect.
|
* texture's full rect.
|
||||||
* @param capInsets The values to use for the cap insets.
|
* @param capInsets The values to use for the cap insets.
|
||||||
*/
|
*/
|
||||||
virtual bool initWithFile(const char* file, const Rect& rect, const Rect& capInsets);
|
virtual bool initWithFile(const std::string& file, const Rect& rect, const Rect& capInsets);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a 9-slice sprite with a texture file and a delimitation zone. The
|
* Initializes a 9-slice sprite with a texture file and a delimitation zone. The
|
||||||
|
@ -169,7 +169,7 @@ public:
|
||||||
* is the whole image. If the shape is the whole texture, set this to the
|
* is the whole image. If the shape is the whole texture, set this to the
|
||||||
* texture's full rect.
|
* texture's full rect.
|
||||||
*/
|
*/
|
||||||
virtual bool initWithFile(const char* file, const Rect& rect);
|
virtual bool initWithFile(const std::string& file, const Rect& rect);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a 9-slice sprite with a texture file and with the specified cap
|
* Initializes a 9-slice sprite with a texture file and with the specified cap
|
||||||
|
@ -181,7 +181,7 @@ public:
|
||||||
* @param file The name of the texture file.
|
* @param file The name of the texture file.
|
||||||
* @param capInsets The values to use for the cap insets.
|
* @param capInsets The values to use for the cap insets.
|
||||||
*/
|
*/
|
||||||
virtual bool initWithFile(const Rect& capInsets, const char* file);
|
virtual bool initWithFile(const Rect& capInsets, const std::string& file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a 9-slice sprite with a texture file. The whole texture will be
|
* Initializes a 9-slice sprite with a texture file. The whole texture will be
|
||||||
|
@ -192,7 +192,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param file The name of the texture file.
|
* @param file The name of the texture file.
|
||||||
*/
|
*/
|
||||||
virtual bool initWithFile(const char* file);
|
virtual bool initWithFile(const std::string& file);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a 9-slice sprite with an sprite frame and with the specified
|
* Initializes a 9-slice sprite with an sprite frame and with the specified
|
||||||
|
@ -226,7 +226,7 @@ public:
|
||||||
* @param spriteFrameName The sprite frame name.
|
* @param spriteFrameName The sprite frame name.
|
||||||
* @param capInsets The values to use for the cap insets.
|
* @param capInsets The values to use for the cap insets.
|
||||||
*/
|
*/
|
||||||
virtual bool initWithSpriteFrameName(const char*spriteFrameName, const Rect& capInsets);
|
virtual bool initWithSpriteFrameName(const std::string& spriteFrameName, const Rect& capInsets);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a 9-slice sprite with an sprite frame name.
|
* Initializes a 9-slice sprite with an sprite frame name.
|
||||||
|
@ -236,7 +236,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param spriteFrameName The sprite frame name.
|
* @param spriteFrameName The sprite frame name.
|
||||||
*/
|
*/
|
||||||
virtual bool initWithSpriteFrameName(const char*spriteFrameName);
|
virtual bool initWithSpriteFrameName(const std::string& spriteFrameName);
|
||||||
|
|
||||||
virtual bool init();
|
virtual bool init();
|
||||||
virtual bool initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, bool rotated, const Rect& capInsets);
|
virtual bool initWithBatchNode(SpriteBatchNode* batchnode, const Rect& rect, bool rotated, const Rect& capInsets);
|
||||||
|
|
2
plugin
2
plugin
|
@ -1 +1 @@
|
||||||
Subproject commit d177da9b541ab1b436476f9caa057766d485d9c3
|
Subproject commit 547ce2ea62a220a419f5df6bc54ab609437e49f3
|
|
@ -21,29 +21,24 @@ bool UIButtonTest::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add a label in which the button events will be displayed
|
// Add a label in which the button events will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf",32);
|
||||||
_displayValueLabel->setText("No Event");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Button","fonts/Marker Felt.ttf",30);
|
||||||
alert->setText("Button");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
|
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
|
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the button
|
// Create the button
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/animationbuttonnormal.png",
|
||||||
button->setTouchEnabled(true);
|
"cocosui/animationbuttonpressed.png");
|
||||||
button->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
|
||||||
button->addTouchEventListener(this, toucheventselector(UIButtonTest::touchEvent));
|
button->addTouchEventListener(this, toucheventselector(UIButtonTest::touchEvent));
|
||||||
_uiLayer->addChild(button);
|
_uiLayer->addChild(button);
|
||||||
|
|
||||||
|
@ -97,29 +92,22 @@ bool UIButtonTest_Scale9::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add a label in which the button events will be displayed
|
// Add a label in which the button events will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32);
|
||||||
_displayValueLabel->setText("No Event");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Button scale9 render", "fonts/Marker Felt.ttf",30);
|
||||||
alert->setText("Button scale9 render");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the button
|
// Create the button
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
button->setTouchEnabled(true);
|
|
||||||
// open scale9 render
|
// open scale9 render
|
||||||
button->setScale9Enabled(true);
|
button->setScale9Enabled(true);
|
||||||
button->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
button->setSize(Size(150, button->getContentSize().height * 1.5f));
|
button->setSize(Size(150, button->getContentSize().height * 1.5f));
|
||||||
button->addTouchEventListener(this, toucheventselector(UIButtonTest_Scale9::touchEvent));
|
button->addTouchEventListener(this, toucheventselector(UIButtonTest_Scale9::touchEvent));
|
||||||
|
@ -172,29 +160,23 @@ bool UIButtonTest_PressedAction::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add a label in which the button events will be displayed
|
// Add a label in which the button events will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf",32);
|
||||||
_displayValueLabel->setText("No Event");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Button Pressed Action", "fonts/Marker Felt.ttf", 30);
|
||||||
alert->setText("Button Pressed Action");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
|
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
|
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the button
|
// Create the button
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||||
button->setTouchEnabled(true);
|
|
||||||
button->setPressedActionEnabled(true);
|
button->setPressedActionEnabled(true);
|
||||||
button->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
button->addTouchEventListener(this, toucheventselector(UIButtonTest_PressedAction::touchEvent));
|
button->addTouchEventListener(this, toucheventselector(UIButtonTest_PressedAction::touchEvent));
|
||||||
_uiLayer->addChild(button);
|
_uiLayer->addChild(button);
|
||||||
|
@ -247,27 +229,21 @@ bool UIButtonTest_Title::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add a label in which the text button events will be displayed
|
// Add a label in which the text button events will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32);
|
||||||
_displayValueLabel->setText("No Event");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Button with title", "fonts/Marker Felt.ttf", 30);
|
||||||
alert->setText("Button with title");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
|
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the button with title
|
// Create the button with title
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png");
|
||||||
button->setTouchEnabled(true);
|
|
||||||
button->loadTextures("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png", "");
|
|
||||||
button->setTitleText("Title Button");
|
button->setTitleText("Title Button");
|
||||||
button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
button->addTouchEventListener(this, toucheventselector(UIButtonTest_Title::touchEvent));
|
button->addTouchEventListener(this, toucheventselector(UIButtonTest_Title::touchEvent));
|
||||||
|
|
|
@ -21,31 +21,23 @@ bool UICheckBoxTest::init()
|
||||||
Size widgetSize = _widget->getSize();;
|
Size widgetSize = _widget->getSize();;
|
||||||
|
|
||||||
// Add a label in which the checkbox events will be displayed
|
// Add a label in which the checkbox events will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf", 32);
|
||||||
_displayValueLabel->setText("No Event");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("CheckBox","fonts/Marker Felt.ttf",30 );
|
||||||
alert->setText("CheckBox");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the checkbox
|
// Create the checkbox
|
||||||
CheckBox* checkBox = CheckBox::create();
|
CheckBox* checkBox = CheckBox::create("cocosui/check_box_normal.png",
|
||||||
checkBox->setTouchEnabled(true);
|
"cocosui/check_box_normal_press.png",
|
||||||
checkBox->loadTextures("cocosui/check_box_normal.png",
|
"cocosui/check_box_active.png",
|
||||||
"cocosui/check_box_normal_press.png",
|
"cocosui/check_box_normal_disable.png",
|
||||||
"cocosui/check_box_active.png",
|
"cocosui/check_box_active_disable.png");
|
||||||
"cocosui/check_box_normal_disable.png",
|
|
||||||
"cocosui/check_box_active_disable.png");
|
|
||||||
checkBox->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
checkBox->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
|
|
||||||
checkBox->addEventListenerCheckBox(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent));
|
checkBox->addEventListenerCheckBox(this, checkboxselectedeventselector(UICheckBoxTest::selectedEvent));
|
||||||
|
|
|
@ -11,52 +11,21 @@ bool UIImageViewTest::init()
|
||||||
{
|
{
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("ImageView", "fonts/Marker Felt.ttf", 30);
|
||||||
alert->setText("ImageView");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
|
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the imageview
|
// Create the imageview
|
||||||
ImageView* imageView = ImageView::create();
|
ImageView* imageView = ImageView::create("cocosui/ccicon.png");
|
||||||
imageView->loadTexture("cocosui/ccicon.png");
|
imageView->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
imageView->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + imageView->getSize().height / 4.0f));
|
widgetSize.height / 2.0f + imageView->getSize().height / 4.0f));
|
||||||
|
|
||||||
// imageView->setOpacity(64);
|
|
||||||
_uiLayer->addChild(imageView);
|
_uiLayer->addChild(imageView);
|
||||||
|
|
||||||
/*
|
|
||||||
NodeRGBA* root = NodeRGBA::create();
|
|
||||||
root->setCascadeOpacityEnabled(true);
|
|
||||||
NodeRGBA* render = Sprite::create();
|
|
||||||
static_cast<Sprite*>(render)->setTexture("cocosui/ccicon.png");
|
|
||||||
root->addChild(render);
|
|
||||||
// root->setOpacity(64);
|
|
||||||
root->setPosition(Point(200, 180));
|
|
||||||
_uiLayer->addChild(root);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
NodeRGBA* nodergba = NodeRGBA::create();
|
|
||||||
Sprite* child = Sprite::create();
|
|
||||||
child->setTexture("cocosui/ccicon.png");
|
|
||||||
nodergba->addChild(child);
|
|
||||||
nodergba->setPosition(Point(120, 80));
|
|
||||||
nodergba->setOpacity(64);
|
|
||||||
_uiLayer->addChild(nodergba);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Sprite* sprite = Sprite::create();
|
|
||||||
sprite->setTexture("cocosui/ccicon.png");
|
|
||||||
sprite->setPosition(Point(200, 180));
|
|
||||||
// sprite->setOpacity(64);
|
|
||||||
_uiLayer->addChild(sprite);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// imageView->setZOrder(20);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -72,20 +41,20 @@ bool UIImageViewTest_Scale9::init()
|
||||||
{
|
{
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("ImageView scale9 render", "fonts/Marker Felt.ttf", 26);
|
||||||
alert->setText("ImageView scale9 render");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(26);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.125f));
|
alert->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f - alert->getSize().height * 2.125f));
|
||||||
|
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the imageview
|
// Create the imageview
|
||||||
ImageView* imageView = ImageView::create();
|
ImageView* imageView = ImageView::create("cocosui/buttonHighlighted.png");
|
||||||
imageView->setScale9Enabled(true);
|
imageView->setScale9Enabled(true);
|
||||||
imageView->loadTexture("cocosui/buttonHighlighted.png");
|
imageView->setSize(Size(300, 115));
|
||||||
imageView->setSize(Size(200, 85));
|
imageView->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
imageView->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + imageView->getSize().height / 4.0f));
|
widgetSize.height / 2.0f + imageView->getSize().height / 4.0f));
|
||||||
|
|
||||||
_uiLayer->addChild(imageView);
|
_uiLayer->addChild(imageView);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -20,12 +20,11 @@ bool UILayoutTest::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Layout", "fonts/Marker Felt.ttf", 30 );
|
||||||
alert->setText("Layout");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
alert->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||||
|
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)) ;
|
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81)) ;
|
||||||
|
@ -42,25 +41,22 @@ bool UILayoutTest::init()
|
||||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||||
_uiLayer->addChild(layout);
|
_uiLayer->addChild(layout);
|
||||||
|
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||||
button->setTouchEnabled(true);
|
button->setPosition(Point(button->getSize().width / 2.0f,
|
||||||
button->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
layout->getSize().height - button->getSize().height / 2.0f));
|
||||||
button->setPosition(Point(button->getSize().width / 2.0f, layout->getSize().height - button->getSize().height / 2.0f));
|
|
||||||
layout->addChild(button);
|
layout->addChild(button);
|
||||||
|
|
||||||
Button* titleButton = Button::create();
|
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||||
titleButton->setTouchEnabled(true);
|
|
||||||
titleButton->loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "");
|
|
||||||
titleButton->setTitleText("Title Button");
|
titleButton->setTitleText("Title Button");
|
||||||
titleButton->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
titleButton->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||||
layout->addChild(titleButton);
|
layout->addChild(titleButton);
|
||||||
|
|
||||||
Button* button_scale9 = Button::create();
|
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
button_scale9->setTouchEnabled(true);
|
|
||||||
button_scale9->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
button_scale9->setScale9Enabled(true);
|
button_scale9->setScale9Enabled(true);
|
||||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||||
button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f));
|
button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||||
|
button_scale9->getSize().height / 2.0f));
|
||||||
|
|
||||||
layout->addChild(button_scale9);
|
layout->addChild(button_scale9);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -86,12 +82,11 @@ bool UILayoutTest_Color::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Layout color render", "fonts/Marker Felt.ttf", 30);
|
||||||
alert->setText("Layout color render");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
alert->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||||
|
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||||
|
@ -110,25 +105,23 @@ bool UILayoutTest_Color::init()
|
||||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||||
_uiLayer->addChild(layout);
|
_uiLayer->addChild(layout);
|
||||||
|
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||||
button->setTouchEnabled(true);
|
button->setPosition(Point(button->getSize().width / 2.0f,
|
||||||
button->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
layout->getSize().height - button->getSize().height / 2.0f));
|
||||||
button->setPosition(Point(button->getSize().width / 2.0f, layout->getSize().height - button->getSize().height / 2.0f));
|
|
||||||
layout->addChild(button);
|
layout->addChild(button);
|
||||||
|
|
||||||
Button* titleButton = Button::create();
|
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||||
titleButton->setTouchEnabled(true);
|
|
||||||
titleButton->loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "");
|
|
||||||
titleButton->setTitleText("Title Button");
|
titleButton->setTitleText("Title Button");
|
||||||
titleButton->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
titleButton->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||||
layout->addChild(titleButton);
|
layout->addChild(titleButton);
|
||||||
|
|
||||||
Button* button_scale9 = Button::create();
|
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
button_scale9->setTouchEnabled(true);
|
|
||||||
button_scale9->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
button_scale9->setScale9Enabled(true);
|
button_scale9->setScale9Enabled(true);
|
||||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||||
button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f));
|
button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||||
|
button_scale9->getSize().height / 2.0f));
|
||||||
|
|
||||||
layout->addChild(button_scale9);
|
layout->addChild(button_scale9);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -153,12 +146,11 @@ bool UILayoutTest_Gradient::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Layout gradient render", "fonts/Marker Felt.ttf", 30);
|
||||||
alert->setText("Layout gradient render");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
alert->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||||
|
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||||
|
@ -177,25 +169,23 @@ bool UILayoutTest_Gradient::init()
|
||||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||||
_uiLayer->addChild(layout);
|
_uiLayer->addChild(layout);
|
||||||
|
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||||
button->setTouchEnabled(true);
|
button->setPosition(Point(button->getSize().width / 2.0f,
|
||||||
button->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
layout->getSize().height - button->getSize().height / 2.0f));
|
||||||
button->setPosition(Point(button->getSize().width / 2.0f, layout->getSize().height - button->getSize().height / 2.0f));
|
|
||||||
layout->addChild(button);
|
layout->addChild(button);
|
||||||
|
|
||||||
Button* titleButton = Button::create();
|
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||||
titleButton->setTouchEnabled(true);
|
|
||||||
titleButton->loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "");
|
|
||||||
titleButton->setTitleText("Title Button");
|
titleButton->setTitleText("Title Button");
|
||||||
titleButton->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
titleButton->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||||
layout->addChild(titleButton);
|
layout->addChild(titleButton);
|
||||||
|
|
||||||
Button* button_scale9 = Button::create();
|
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
button_scale9->setTouchEnabled(true);
|
|
||||||
button_scale9->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
button_scale9->setScale9Enabled(true);
|
button_scale9->setScale9Enabled(true);
|
||||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||||
button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f));
|
button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||||
|
button_scale9->getSize().height / 2.0f));
|
||||||
|
|
||||||
layout->addChild(button_scale9);
|
layout->addChild(button_scale9);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -220,10 +210,7 @@ bool UILayoutTest_BackGroundImage::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Layout background image", "fonts/Marker Felt.ttf", 20);
|
||||||
alert->setText("Layout background image");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(20);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
@ -244,25 +231,22 @@ bool UILayoutTest_BackGroundImage::init()
|
||||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||||
_uiLayer->addChild(layout);
|
_uiLayer->addChild(layout);
|
||||||
|
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||||
button->setTouchEnabled(true);
|
button->setPosition(Point(button->getSize().width / 2.0f,
|
||||||
button->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
layout->getSize().height - button->getSize().height / 2.0f));
|
||||||
button->setPosition(Point(button->getSize().width / 2.0f, layout->getSize().height - button->getSize().height / 2.0f));
|
|
||||||
layout->addChild(button);
|
layout->addChild(button);
|
||||||
|
|
||||||
Button* titleButton = Button::create();
|
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||||
titleButton->setTouchEnabled(true);
|
|
||||||
titleButton->loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "");
|
|
||||||
titleButton->setTitleText("Title Button");
|
titleButton->setTitleText("Title Button");
|
||||||
titleButton->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
titleButton->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||||
layout->addChild(titleButton);
|
layout->addChild(titleButton);
|
||||||
|
|
||||||
Button* button_scale9 = Button::create();
|
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
button_scale9->setTouchEnabled(true);
|
|
||||||
button_scale9->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
button_scale9->setScale9Enabled(true);
|
button_scale9->setScale9Enabled(true);
|
||||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||||
button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f));
|
button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||||
|
button_scale9->getSize().height / 2.0f));
|
||||||
|
|
||||||
layout->addChild(button_scale9);
|
layout->addChild(button_scale9);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -287,10 +271,7 @@ bool UILayoutTest_BackGroundImage_Scale9::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Layout background image scale9", "fonts/Marker Felt.ttf", 20);
|
||||||
alert->setText("Layout background image scale9");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(20);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
@ -311,26 +292,23 @@ bool UILayoutTest_BackGroundImage_Scale9::init()
|
||||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||||
_uiLayer->addChild(layout);
|
_uiLayer->addChild(layout);
|
||||||
|
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||||
button->setTouchEnabled(true);
|
button->setPosition(Point(button->getSize().width / 2.0f,
|
||||||
button->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
layout->getSize().height - button->getSize().height / 2.0f));
|
||||||
button->setPosition(Point(button->getSize().width / 2.0f, layout->getSize().height - button->getSize().height / 2.0f));
|
|
||||||
layout->addChild(button);
|
layout->addChild(button);
|
||||||
|
|
||||||
Button* titleButton = Button::create();
|
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||||
titleButton->setTouchEnabled(true);
|
|
||||||
titleButton->loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "");
|
|
||||||
titleButton->setTitleText("Title Button");
|
titleButton->setTitleText("Title Button");
|
||||||
titleButton->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
titleButton->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||||
layout->addChild(titleButton);
|
layout->addChild(titleButton);
|
||||||
|
|
||||||
Button* button_scale9 = Button::create();
|
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
button_scale9->setTouchEnabled(true);
|
|
||||||
button_scale9->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
button_scale9->setScale9Enabled(true);
|
button_scale9->setScale9Enabled(true);
|
||||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||||
button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f, button_scale9->getSize().height / 2.0f));
|
button_scale9->setPosition(Point(layout->getSize().width - button_scale9->getSize().width / 2.0f,
|
||||||
layout->addChild(button_scale9);
|
button_scale9->getSize().height / 2.0f));
|
||||||
|
layout->addChild(button_scale9);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -354,12 +332,11 @@ bool UILayoutTest_Layout_Linear_Vertical::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Layout Linear Vertical", "fonts/Marker Felt.ttf", 20);
|
||||||
alert->setText("Layout Linear Vertical");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(20);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
alert->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
||||||
|
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||||
|
@ -378,9 +355,7 @@ bool UILayoutTest_Layout_Linear_Vertical::init()
|
||||||
_uiLayer->addChild(layout);
|
_uiLayer->addChild(layout);
|
||||||
|
|
||||||
|
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||||
button->setTouchEnabled(true);
|
|
||||||
button->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
layout->addChild(button);
|
layout->addChild(button);
|
||||||
|
|
||||||
LinearLayoutParameter* lp1 = LinearLayoutParameter::create();
|
LinearLayoutParameter* lp1 = LinearLayoutParameter::create();
|
||||||
|
@ -389,9 +364,7 @@ bool UILayoutTest_Layout_Linear_Vertical::init()
|
||||||
lp1->setMargin(Margin(0.0f, 5.0f, 0.0f, 10.0f));
|
lp1->setMargin(Margin(0.0f, 5.0f, 0.0f, 10.0f));
|
||||||
|
|
||||||
|
|
||||||
Button* titleButton = Button::create();
|
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||||
titleButton->setTouchEnabled(true);
|
|
||||||
titleButton->loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "");
|
|
||||||
titleButton->setTitleText("Title Button");
|
titleButton->setTitleText("Title Button");
|
||||||
layout->addChild(titleButton);
|
layout->addChild(titleButton);
|
||||||
|
|
||||||
|
@ -401,9 +374,7 @@ bool UILayoutTest_Layout_Linear_Vertical::init()
|
||||||
lp2->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f));
|
lp2->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f));
|
||||||
|
|
||||||
|
|
||||||
Button* button_scale9 = Button::create();
|
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
button_scale9->setTouchEnabled(true);
|
|
||||||
button_scale9->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
button_scale9->setScale9Enabled(true);
|
button_scale9->setScale9Enabled(true);
|
||||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||||
layout->addChild(button_scale9);
|
layout->addChild(button_scale9);
|
||||||
|
@ -414,8 +385,6 @@ bool UILayoutTest_Layout_Linear_Vertical::init()
|
||||||
lp3->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f));
|
lp3->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f));
|
||||||
|
|
||||||
|
|
||||||
// layout->doLayout();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,10 +408,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Layout Linear Horizontal", "fonts/Marker Felt.ttf", 20);
|
||||||
alert->setText("Layout Linear Horizontal");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(20);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
@ -463,9 +429,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init()
|
||||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
||||||
_uiLayer->addChild(layout);
|
_uiLayer->addChild(layout);
|
||||||
|
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||||
button->setTouchEnabled(true);
|
|
||||||
button->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
layout->addChild(button);
|
layout->addChild(button);
|
||||||
|
|
||||||
LinearLayoutParameter* lp1 = LinearLayoutParameter::create();
|
LinearLayoutParameter* lp1 = LinearLayoutParameter::create();
|
||||||
|
@ -474,9 +438,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init()
|
||||||
lp1->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f));
|
lp1->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f));
|
||||||
|
|
||||||
|
|
||||||
Button* titleButton = Button::create();
|
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||||
titleButton->setTouchEnabled(true);
|
|
||||||
titleButton->loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "");
|
|
||||||
titleButton->setTitleText("Title Button");
|
titleButton->setTitleText("Title Button");
|
||||||
layout->addChild(titleButton);
|
layout->addChild(titleButton);
|
||||||
|
|
||||||
|
@ -486,9 +448,7 @@ bool UILayoutTest_Layout_Linear_Horizontal::init()
|
||||||
lp2->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f));
|
lp2->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f));
|
||||||
|
|
||||||
|
|
||||||
Button* button_scale9 = Button::create();
|
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
button_scale9->setTouchEnabled(true);
|
|
||||||
button_scale9->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
button_scale9->setScale9Enabled(true);
|
button_scale9->setScale9Enabled(true);
|
||||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||||
layout->addChild(button_scale9);
|
layout->addChild(button_scale9);
|
||||||
|
@ -499,8 +459,6 @@ bool UILayoutTest_Layout_Linear_Horizontal::init()
|
||||||
lp3->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f));
|
lp3->setMargin(Margin(0.0f, 10.0f, 0.0f, 10.0f));
|
||||||
|
|
||||||
|
|
||||||
// layout->doLayout();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,10 +482,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Layout Relative Align Parent", "fonts/Marker Felt.ttf", 20);
|
||||||
alert->setText("Layout Relative Align Parent");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(20);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
@ -550,9 +505,8 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init()
|
||||||
_uiLayer->addChild(layout);
|
_uiLayer->addChild(layout);
|
||||||
|
|
||||||
// top left
|
// top left
|
||||||
Button* button_TopLeft = Button::create();
|
Button* button_TopLeft = Button::create("cocosui/animationbuttonnormal.png",
|
||||||
button_TopLeft->setTouchEnabled(true);
|
"cocosui/animationbuttonpressed.png");
|
||||||
button_TopLeft->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
layout->addChild(button_TopLeft);
|
layout->addChild(button_TopLeft);
|
||||||
|
|
||||||
RelativeLayoutParameter* rp_TopLeft = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rp_TopLeft = RelativeLayoutParameter::create();
|
||||||
|
@ -561,9 +515,8 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init()
|
||||||
|
|
||||||
|
|
||||||
// top center horizontal
|
// top center horizontal
|
||||||
Button* button_TopCenter = Button::create();
|
Button* button_TopCenter = Button::create("cocosui/animationbuttonnormal.png",
|
||||||
button_TopCenter->setTouchEnabled(true);
|
"cocosui/animationbuttonpressed.png");
|
||||||
button_TopCenter->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
layout->addChild(button_TopCenter);
|
layout->addChild(button_TopCenter);
|
||||||
|
|
||||||
RelativeLayoutParameter* rp_TopCenter = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rp_TopCenter = RelativeLayoutParameter::create();
|
||||||
|
@ -572,9 +525,8 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init()
|
||||||
|
|
||||||
|
|
||||||
// top right
|
// top right
|
||||||
Button* button_TopRight = Button::create();
|
Button* button_TopRight = Button::create("cocosui/animationbuttonnormal.png",
|
||||||
button_TopRight->setTouchEnabled(true);
|
"cocosui/animationbuttonpressed.png");
|
||||||
button_TopRight->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
layout->addChild(button_TopRight);
|
layout->addChild(button_TopRight);
|
||||||
|
|
||||||
RelativeLayoutParameter* rp_TopRight = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rp_TopRight = RelativeLayoutParameter::create();
|
||||||
|
@ -583,9 +535,8 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init()
|
||||||
|
|
||||||
|
|
||||||
// left center
|
// left center
|
||||||
Button* button_LeftCenter = Button::create();
|
Button* button_LeftCenter = Button::create("cocosui/animationbuttonnormal.png",
|
||||||
button_LeftCenter->setTouchEnabled(true);
|
"cocosui/animationbuttonpressed.png");
|
||||||
button_LeftCenter->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
layout->addChild(button_LeftCenter);
|
layout->addChild(button_LeftCenter);
|
||||||
|
|
||||||
RelativeLayoutParameter* rp_LeftCenter = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rp_LeftCenter = RelativeLayoutParameter::create();
|
||||||
|
@ -594,9 +545,8 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init()
|
||||||
|
|
||||||
|
|
||||||
// center
|
// center
|
||||||
Button* buttonCenter = Button::create();
|
Button* buttonCenter = Button::create("cocosui/animationbuttonnormal.png",
|
||||||
buttonCenter->setTouchEnabled(true);
|
"cocosui/animationbuttonpressed.png");
|
||||||
buttonCenter->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
layout->addChild(buttonCenter);
|
layout->addChild(buttonCenter);
|
||||||
|
|
||||||
RelativeLayoutParameter* rpCenter = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rpCenter = RelativeLayoutParameter::create();
|
||||||
|
@ -605,9 +555,8 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init()
|
||||||
|
|
||||||
|
|
||||||
// right center
|
// right center
|
||||||
Button* button_RightCenter = Button::create();
|
Button* button_RightCenter = Button::create("cocosui/animationbuttonnormal.png",
|
||||||
button_RightCenter->setTouchEnabled(true);
|
"cocosui/animationbuttonpressed.png");
|
||||||
button_RightCenter->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
layout->addChild(button_RightCenter);
|
layout->addChild(button_RightCenter);
|
||||||
|
|
||||||
RelativeLayoutParameter* rp_RightCenter = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rp_RightCenter = RelativeLayoutParameter::create();
|
||||||
|
@ -616,9 +565,8 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init()
|
||||||
|
|
||||||
|
|
||||||
// left bottom
|
// left bottom
|
||||||
Button* button_LeftBottom = Button::create();
|
Button* button_LeftBottom = Button::create("cocosui/animationbuttonnormal.png",
|
||||||
button_LeftBottom->setTouchEnabled(true);
|
"cocosui/animationbuttonpressed.png");
|
||||||
button_LeftBottom->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
layout->addChild(button_LeftBottom);
|
layout->addChild(button_LeftBottom);
|
||||||
|
|
||||||
RelativeLayoutParameter* rp_LeftBottom = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rp_LeftBottom = RelativeLayoutParameter::create();
|
||||||
|
@ -627,9 +575,8 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init()
|
||||||
|
|
||||||
|
|
||||||
// bottom center
|
// bottom center
|
||||||
Button* button_BottomCenter = Button::create();
|
Button* button_BottomCenter = Button::create("cocosui/animationbuttonnormal.png",
|
||||||
button_BottomCenter->setTouchEnabled(true);
|
"cocosui/animationbuttonpressed.png");
|
||||||
button_BottomCenter->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
layout->addChild(button_BottomCenter);
|
layout->addChild(button_BottomCenter);
|
||||||
|
|
||||||
RelativeLayoutParameter* rp_BottomCenter = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rp_BottomCenter = RelativeLayoutParameter::create();
|
||||||
|
@ -638,9 +585,8 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init()
|
||||||
|
|
||||||
|
|
||||||
// right bottom
|
// right bottom
|
||||||
Button* button_RightBottom = Button::create();
|
Button* button_RightBottom = Button::create("cocosui/animationbuttonnormal.png",
|
||||||
button_RightBottom->setTouchEnabled(true);
|
"cocosui/animationbuttonpressed.png");
|
||||||
button_RightBottom->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
layout->addChild(button_RightBottom);
|
layout->addChild(button_RightBottom);
|
||||||
|
|
||||||
RelativeLayoutParameter* rp_RightBottom = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rp_RightBottom = RelativeLayoutParameter::create();
|
||||||
|
@ -648,8 +594,6 @@ bool UILayoutTest_Layout_Relative_Align_Parent::init()
|
||||||
button_RightBottom->setLayoutParameter(rp_RightBottom);
|
button_RightBottom->setLayoutParameter(rp_RightBottom);
|
||||||
|
|
||||||
|
|
||||||
// layout->doLayout();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,10 +617,7 @@ bool UILayoutTest_Layout_Relative_Location::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Layout Relative Location", "fonts/Marker Felt.ttf", 20);
|
||||||
alert->setText("Layout Relative Location");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(20);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
@ -697,8 +638,7 @@ bool UILayoutTest_Layout_Relative_Location::init()
|
||||||
_uiLayer->addChild(layout);
|
_uiLayer->addChild(layout);
|
||||||
|
|
||||||
// center
|
// center
|
||||||
ImageView* imageView_Center = ImageView::create();
|
ImageView* imageView_Center = ImageView::create("cocosui/scrollviewbg.png");
|
||||||
imageView_Center->loadTexture("cocosui/scrollviewbg.png");
|
|
||||||
layout->addChild(imageView_Center);
|
layout->addChild(imageView_Center);
|
||||||
|
|
||||||
RelativeLayoutParameter* rp_Center = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rp_Center = RelativeLayoutParameter::create();
|
||||||
|
@ -708,8 +648,7 @@ bool UILayoutTest_Layout_Relative_Location::init()
|
||||||
|
|
||||||
|
|
||||||
// above center
|
// above center
|
||||||
ImageView* imageView_AboveCenter = ImageView::create();
|
ImageView* imageView_AboveCenter = ImageView::create("cocosui/switch-mask.png");
|
||||||
imageView_AboveCenter->loadTexture("cocosui/switch-mask.png");
|
|
||||||
layout->addChild(imageView_AboveCenter);
|
layout->addChild(imageView_AboveCenter);
|
||||||
|
|
||||||
RelativeLayoutParameter* rp_AboveCenter = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rp_AboveCenter = RelativeLayoutParameter::create();
|
||||||
|
@ -719,8 +658,7 @@ bool UILayoutTest_Layout_Relative_Location::init()
|
||||||
|
|
||||||
|
|
||||||
// below center
|
// below center
|
||||||
ImageView* imageView_BelowCenter = ImageView::create();
|
ImageView* imageView_BelowCenter = ImageView::create("cocosui/switch-mask.png");
|
||||||
imageView_BelowCenter->loadTexture("cocosui/switch-mask.png");
|
|
||||||
layout->addChild(imageView_BelowCenter);
|
layout->addChild(imageView_BelowCenter);
|
||||||
|
|
||||||
RelativeLayoutParameter* rp_BelowCenter = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rp_BelowCenter = RelativeLayoutParameter::create();
|
||||||
|
@ -730,8 +668,7 @@ bool UILayoutTest_Layout_Relative_Location::init()
|
||||||
|
|
||||||
|
|
||||||
// left center
|
// left center
|
||||||
ImageView* imageView_LeftCenter = ImageView::create();
|
ImageView* imageView_LeftCenter = ImageView::create("cocosui/switch-mask.png");
|
||||||
imageView_LeftCenter->loadTexture("cocosui/switch-mask.png");
|
|
||||||
layout->addChild(imageView_LeftCenter);
|
layout->addChild(imageView_LeftCenter);
|
||||||
|
|
||||||
RelativeLayoutParameter* rp_LeftCenter = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rp_LeftCenter = RelativeLayoutParameter::create();
|
||||||
|
@ -742,8 +679,7 @@ bool UILayoutTest_Layout_Relative_Location::init()
|
||||||
|
|
||||||
|
|
||||||
// right center
|
// right center
|
||||||
ImageView* imageView_RightCenter = ImageView::create();
|
ImageView* imageView_RightCenter = ImageView::create("cocosui/switch-mask.png");
|
||||||
imageView_RightCenter->loadTexture("cocosui/switch-mask.png");
|
|
||||||
layout->addChild(imageView_RightCenter);
|
layout->addChild(imageView_RightCenter);
|
||||||
|
|
||||||
RelativeLayoutParameter* rp_RightCenter = RelativeLayoutParameter::create();
|
RelativeLayoutParameter* rp_RightCenter = RelativeLayoutParameter::create();
|
||||||
|
@ -752,93 +688,9 @@ bool UILayoutTest_Layout_Relative_Location::init()
|
||||||
imageView_RightCenter->setLayoutParameter(rp_RightCenter);
|
imageView_RightCenter->setLayoutParameter(rp_RightCenter);
|
||||||
|
|
||||||
|
|
||||||
// layout->doLayout();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UILayoutTest_Layout_Grid
|
|
||||||
/*
|
|
||||||
UILayoutTest_Layout_Grid::UILayoutTest_Layout_Grid()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
UILayoutTest_Layout_Grid::~UILayoutTest_Layout_Grid()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UILayoutTest_Layout_Grid::init()
|
|
||||||
{
|
|
||||||
if (UIScene::init())
|
|
||||||
{
|
|
||||||
Size widgetSize = _widget->getSize();
|
|
||||||
|
|
||||||
// Add the alert
|
|
||||||
Text* alert = Text::create();
|
|
||||||
alert->setText("Layout Grid");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(20);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5f));
|
|
||||||
_uiLayer->addChild(alert);
|
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
|
||||||
|
|
||||||
Layout* background = dynamic_cast<Layout*>(root->getChildByName("background_Panel"));
|
|
||||||
|
|
||||||
// Create the layout
|
|
||||||
Layout* layout = Layout::create();
|
|
||||||
layout->setLayoutType(LAYOUT_GRID_MODE_COLUMN);
|
|
||||||
layout->setSize(Size(280, 150));
|
|
||||||
Size backgroundSize = background->getSize();
|
|
||||||
layout->setPosition(Point((widgetSize.width - backgroundSize.width) / 2.0f +
|
|
||||||
(backgroundSize.width - layout->getSize().width) / 2.0f,
|
|
||||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
|
||||||
(backgroundSize.height - layout->getSize().height) / 2.0f));
|
|
||||||
_uiLayer->addChild(layout);
|
|
||||||
|
|
||||||
|
|
||||||
// create items
|
|
||||||
for (int i = 0; i < 14; ++i)
|
|
||||||
{
|
|
||||||
Button* button = Button::create();
|
|
||||||
button->setName("TextButton");
|
|
||||||
button->setTouchEnabled(true);
|
|
||||||
button->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
button->setScale9Enabled(true);
|
|
||||||
AffineTransform transform = AffineTransformMakeIdentity();
|
|
||||||
transform = AffineTransformScale(transform, 3.0f, 1.3f);
|
|
||||||
button->setSize(SizeApplyAffineTransform(button->getContentSize(), transform));
|
|
||||||
button->setTitleText(CCString::createWithFormat("grid_%d", i)->getCString());
|
|
||||||
|
|
||||||
Layout* item = Layout::create();
|
|
||||||
item->setTouchEnabled(true);
|
|
||||||
item->setSize(button->getSize());
|
|
||||||
button->setPosition(Point(item->getSize().width / 2.0f, item->getSize().height / 2.0f));
|
|
||||||
item->addChild(button);
|
|
||||||
|
|
||||||
GridLayoutParameter* gp = GridLayoutParameter::create();
|
|
||||||
item->setLayoutParameter(gp);
|
|
||||||
gp->setMargin(Margin(0.0f, 0.0f, 0.0f, 0.0f));
|
|
||||||
|
|
||||||
layout->addChild(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
// set grid view row and column
|
|
||||||
Widget* item = static_cast<Widget*>(layout->getChildren().at(0));
|
|
||||||
int rowCount = layout->getSize().height / item->getSize().height;
|
|
||||||
int columnCount = layout->getSize().width / item->getSize().width;
|
|
||||||
layout->setGridLayoutRowAndColumnCount(rowCount, columnCount);
|
|
||||||
|
|
||||||
// layout->doLayout();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
|
@ -24,21 +24,17 @@ bool UIListViewTest_Vertical::init()
|
||||||
{
|
{
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("Move by vertical direction", "fonts/Marker Felt.ttf", 32);
|
||||||
_displayValueLabel->setText("Move by vertical direction");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
|
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("ListView vertical", "fonts/Marker Felt.ttf", 30);
|
||||||
alert->setText("ListView vertical");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
alert->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
Layout* root = static_cast<Layout*>(_uiLayer->getChildByTag(81));
|
||||||
|
@ -75,15 +71,14 @@ bool UIListViewTest_Vertical::init()
|
||||||
|
|
||||||
|
|
||||||
// create model
|
// create model
|
||||||
Button* default_button = Button::create();
|
Button* default_button = Button::create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png");
|
||||||
default_button->setName("Title Button");
|
default_button->setName("Title Button");
|
||||||
default_button->setTouchEnabled(true);
|
|
||||||
default_button->loadTextures("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png", "");
|
|
||||||
|
|
||||||
Layout* default_item = Layout::create();
|
Layout* default_item = Layout::create();
|
||||||
default_item->setTouchEnabled(true);
|
default_item->setTouchEnabled(true);
|
||||||
default_item->setSize(default_button->getSize());
|
default_item->setSize(default_button->getSize());
|
||||||
default_button->setPosition(Point(default_item->getSize().width / 2.0f, default_item->getSize().height / 2.0f));
|
default_button->setPosition(Point(default_item->getSize().width / 2.0f,
|
||||||
|
default_item->getSize().height / 2.0f));
|
||||||
default_item->addChild(default_button);
|
default_item->addChild(default_button);
|
||||||
|
|
||||||
// set model
|
// set model
|
||||||
|
@ -104,10 +99,8 @@ bool UIListViewTest_Vertical::init()
|
||||||
// add custom item
|
// add custom item
|
||||||
for (int i = 0; i < count / 4; ++i)
|
for (int i = 0; i < count / 4; ++i)
|
||||||
{
|
{
|
||||||
Button* custom_button = Button::create();
|
Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
custom_button->setName("Title Button");
|
custom_button->setName("Title Button");
|
||||||
custom_button->setTouchEnabled(true);
|
|
||||||
custom_button->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
custom_button->setScale9Enabled(true);
|
custom_button->setScale9Enabled(true);
|
||||||
custom_button->setSize(default_button->getSize());
|
custom_button->setSize(default_button->getSize());
|
||||||
|
|
||||||
|
@ -123,10 +116,8 @@ bool UIListViewTest_Vertical::init()
|
||||||
ssize_t items_count = items.size();
|
ssize_t items_count = items.size();
|
||||||
for (int i = 0; i < count / 4; ++i)
|
for (int i = 0; i < count / 4; ++i)
|
||||||
{
|
{
|
||||||
Button* custom_button = Button::create();
|
Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
custom_button->setName("Title Button");
|
custom_button->setName("Title Button");
|
||||||
custom_button->setTouchEnabled(true);
|
|
||||||
custom_button->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
custom_button->setScale9Enabled(true);
|
custom_button->setScale9Enabled(true);
|
||||||
custom_button->setSize(default_button->getSize());
|
custom_button->setSize(default_button->getSize());
|
||||||
|
|
||||||
|
@ -209,19 +200,16 @@ bool UIListViewTest_Horizontal::init()
|
||||||
{
|
{
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32);
|
||||||
_displayValueLabel->setText("Move by horizontal direction");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f
|
||||||
|
+ _displayValueLabel->getContentSize().height * 1.5f));
|
||||||
|
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
|
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("ListView horizontal", "fonts/Marker Felt.ttf", 30);
|
||||||
alert->setText("ListView horizontal");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
@ -260,10 +248,8 @@ bool UIListViewTest_Horizontal::init()
|
||||||
|
|
||||||
|
|
||||||
// create model
|
// create model
|
||||||
Button* default_button = Button::create();
|
Button* default_button = Button::create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png");
|
||||||
default_button->setName("Title Button");
|
default_button->setName("Title Button");
|
||||||
default_button->setTouchEnabled(true);
|
|
||||||
default_button->loadTextures("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png", "");
|
|
||||||
|
|
||||||
Layout *default_item = Layout::create();
|
Layout *default_item = Layout::create();
|
||||||
default_item->setTouchEnabled(true);
|
default_item->setTouchEnabled(true);
|
||||||
|
@ -289,10 +275,8 @@ bool UIListViewTest_Horizontal::init()
|
||||||
// add custom item
|
// add custom item
|
||||||
for (int i = 0; i < count / 4; ++i)
|
for (int i = 0; i < count / 4; ++i)
|
||||||
{
|
{
|
||||||
Button* custom_button = Button::create();
|
Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
custom_button->setName("Title Button");
|
custom_button->setName("Title Button");
|
||||||
custom_button->setTouchEnabled(true);
|
|
||||||
custom_button->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
custom_button->setScale9Enabled(true);
|
custom_button->setScale9Enabled(true);
|
||||||
custom_button->setSize(default_button->getSize());
|
custom_button->setSize(default_button->getSize());
|
||||||
|
|
||||||
|
@ -308,10 +292,8 @@ bool UIListViewTest_Horizontal::init()
|
||||||
ssize_t items_count = items.size();
|
ssize_t items_count = items.size();
|
||||||
for (int i = 0; i < count / 4; ++i)
|
for (int i = 0; i < count / 4; ++i)
|
||||||
{
|
{
|
||||||
Button* custom_button = Button::create();
|
Button* custom_button = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
custom_button->setName("Title Button");
|
custom_button->setName("Title Button");
|
||||||
custom_button->setTouchEnabled(true);
|
|
||||||
custom_button->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
custom_button->setScale9Enabled(true);
|
custom_button->setScale9Enabled(true);
|
||||||
custom_button->setSize(default_button->getSize());
|
custom_button->setSize(default_button->getSize());
|
||||||
|
|
||||||
|
|
|
@ -25,21 +25,17 @@ bool UILoadingBarTest_Left::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("LoadingBar left", "fonts/Marker Felt.ttf", 30);
|
||||||
alert->setText("LoadingBar left");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the loading bar
|
// Create the loading bar
|
||||||
LoadingBar* loadingBar = LoadingBar::create();
|
LoadingBar* loadingBar = LoadingBar::create("cocosui/sliderProgress.png");
|
||||||
loadingBar->setTag(0);
|
loadingBar->setTag(0);
|
||||||
loadingBar->loadTexture("cocosui/sliderProgress.png");
|
loadingBar->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
loadingBar->setPercent(0);
|
widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
|
||||||
|
|
||||||
loadingBar->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
|
|
||||||
_uiLayer->addChild(loadingBar);
|
_uiLayer->addChild(loadingBar);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -107,22 +103,19 @@ bool UILoadingBarTest_Right::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text *alert = Text::create();
|
Text *alert = Text::create("LoadingBar right", "fonts/Marker Felt.ttf", 30);
|
||||||
alert->setText("LoadingBar right");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the loading bar
|
// Create the loading bar
|
||||||
LoadingBar* loadingBar = LoadingBar::create();
|
LoadingBar* loadingBar = LoadingBar::create("cocosui/sliderProgress.png");
|
||||||
loadingBar->setTag(0);
|
loadingBar->setTag(0);
|
||||||
loadingBar->loadTexture("cocosui/sliderProgress.png");
|
|
||||||
loadingBar->setDirection(LoadingBarTypeRight);
|
loadingBar->setDirection(LoadingBarTypeRight);
|
||||||
loadingBar->setPercent(0);
|
|
||||||
|
|
||||||
loadingBar->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
|
loadingBar->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
|
||||||
|
|
||||||
_uiLayer->addChild(loadingBar);
|
_uiLayer->addChild(loadingBar);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -190,24 +183,21 @@ bool UILoadingBarTest_Left_Scale9::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("LoadingBar left scale9 render", "fonts/Marker Felt.ttf", 20);
|
||||||
alert->setText("LoadingBar left scale9 render");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(20);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the loading bar
|
// Create the loading bar
|
||||||
LoadingBar* loadingBar = LoadingBar::create();
|
LoadingBar* loadingBar = LoadingBar::create("cocosui/slider_bar_active_9patch.png");
|
||||||
loadingBar->setTag(0);
|
loadingBar->setTag(0);
|
||||||
loadingBar->loadTexture("cocosui/slider_bar_active_9patch.png");
|
|
||||||
loadingBar->setScale9Enabled(true);
|
loadingBar->setScale9Enabled(true);
|
||||||
loadingBar->setCapInsets(Rect(0, 0, 0, 0));
|
loadingBar->setCapInsets(Rect(0, 0, 0, 0));
|
||||||
loadingBar->setSize(Size(300, loadingBar->getContentSize().height));
|
loadingBar->setSize(Size(300, loadingBar->getContentSize().height));
|
||||||
loadingBar->setPercent(0);
|
|
||||||
|
|
||||||
loadingBar->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
|
loadingBar->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
|
||||||
|
|
||||||
_uiLayer->addChild(loadingBar);
|
_uiLayer->addChild(loadingBar);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -275,25 +265,22 @@ bool UILoadingBarTest_Right_Scale9::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text *alert = Text::create();
|
Text *alert = Text::create("LoadingBar right scale9 render", "fonts/Marker Felt.ttf", 20);
|
||||||
alert->setText("LoadingBar right scale9 render");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(20);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 2.7f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the loading bar
|
// Create the loading bar
|
||||||
LoadingBar* loadingBar = LoadingBar::create();
|
LoadingBar* loadingBar = LoadingBar::create("cocosui/slider_bar_active_9patch.png");
|
||||||
loadingBar->setTag(0);
|
loadingBar->setTag(0);
|
||||||
loadingBar->loadTexture("cocosui/slider_bar_active_9patch.png");
|
|
||||||
loadingBar->setScale9Enabled(true);
|
loadingBar->setScale9Enabled(true);
|
||||||
loadingBar->setCapInsets(Rect(0, 0, 0, 0));
|
loadingBar->setCapInsets(Rect(0, 0, 0, 0));
|
||||||
loadingBar->setSize(Size(300, loadingBar->getContentSize().height));
|
loadingBar->setSize(Size(300, loadingBar->getContentSize().height));
|
||||||
loadingBar->setDirection(LoadingBarTypeRight);
|
loadingBar->setDirection(LoadingBarTypeRight);
|
||||||
loadingBar->setPercent(0);
|
|
||||||
|
|
||||||
loadingBar->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
|
loadingBar->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f + loadingBar->getSize().height / 4.0f));
|
||||||
|
|
||||||
_uiLayer->addChild(loadingBar);
|
_uiLayer->addChild(loadingBar);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -21,19 +21,15 @@ bool UIPageViewTest::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add a label in which the dragpanel events will be displayed
|
// Add a label in which the dragpanel events will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("Move by horizontal direction", "fonts/Marker Felt.ttf", 32);
|
||||||
_displayValueLabel->setText("Move by horizontal direction");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f +
|
||||||
|
_displayValueLabel->getContentSize().height * 1.5));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the black background
|
// Add the black background
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("PageView", "fonts/Marker Felt.ttf", 30);
|
||||||
alert->setText("PageView");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
@ -44,7 +40,6 @@ bool UIPageViewTest::init()
|
||||||
|
|
||||||
// Create the page view
|
// Create the page view
|
||||||
PageView* pageView = PageView::create();
|
PageView* pageView = PageView::create();
|
||||||
pageView->setTouchEnabled(true);
|
|
||||||
pageView->setSize(Size(240.0f, 130.0f));
|
pageView->setSize(Size(240.0f, 130.0f));
|
||||||
Size backgroundSize = background->getContentSize();
|
Size backgroundSize = background->getContentSize();
|
||||||
pageView->setPosition(Point((widgetSize.width - backgroundSize.width) / 2.0f +
|
pageView->setPosition(Point((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||||
|
@ -57,18 +52,13 @@ bool UIPageViewTest::init()
|
||||||
Layout* layout = Layout::create();
|
Layout* layout = Layout::create();
|
||||||
layout->setSize(Size(240.0f, 130.0f));
|
layout->setSize(Size(240.0f, 130.0f));
|
||||||
|
|
||||||
ImageView* imageView = ImageView::create();
|
ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png");
|
||||||
imageView->setTouchEnabled(true);
|
|
||||||
imageView->setScale9Enabled(true);
|
imageView->setScale9Enabled(true);
|
||||||
imageView->loadTexture("cocosui/scrollviewbg.png");
|
|
||||||
imageView->setSize(Size(240, 130));
|
imageView->setSize(Size(240, 130));
|
||||||
imageView->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
imageView->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||||
layout->addChild(imageView);
|
layout->addChild(imageView);
|
||||||
|
|
||||||
Text* label = Text::create();
|
Text* label = Text::create(StringUtils::format("page %d",(i+1)), "fonts/Marker Felt.ttf", 30);
|
||||||
label->setText(CCString::createWithFormat("page %d", (i + 1))->getCString());
|
|
||||||
label->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
label->setFontSize(30);
|
|
||||||
label->setColor(Color3B(192, 192, 192));
|
label->setColor(Color3B(192, 192, 192));
|
||||||
label->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
label->setPosition(Point(layout->getSize().width / 2.0f, layout->getSize().height / 2.0f));
|
||||||
layout->addChild(label);
|
layout->addChild(label);
|
||||||
|
|
|
@ -21,18 +21,14 @@ bool UIRichTextTest::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text *alert = Text::create();
|
Text *alert = Text::create("RichText", "fonts/Marker Felt.ttf", 30);
|
||||||
alert->setText("RichText");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.125));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.125));
|
||||||
_widget->addChild(alert);
|
_widget->addChild(alert);
|
||||||
|
|
||||||
|
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||||
button->setTouchEnabled(true);
|
button->setTouchEnabled(true);
|
||||||
button->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
button->setTitleText("switch");
|
button->setTitleText("switch");
|
||||||
button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + button->getSize().height * 2.5));
|
button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + button->getSize().height * 2.5));
|
||||||
button->addTouchEventListener(this, toucheventselector(UIRichTextTest::touchEvent));
|
button->addTouchEventListener(this, toucheventselector(UIRichTextTest::touchEvent));
|
||||||
|
|
|
@ -21,19 +21,14 @@ bool UIScrollViewTest_Vertical::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add a label in which the scrollview alert will be displayed
|
// Add a label in which the scrollview alert will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("Move by vertical direction", "fonts/Marker Felt.ttf", 32);
|
||||||
_displayValueLabel->setText("Move by vertical direction");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f,
|
||||||
|
widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("ScrollView vertical", "fonts/Marker Felt.ttf", 30);
|
||||||
alert->setText("ScrollView vertical");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
@ -44,7 +39,6 @@ bool UIScrollViewTest_Vertical::init()
|
||||||
|
|
||||||
// Create the scrollview by vertical
|
// Create the scrollview by vertical
|
||||||
ui::ScrollView* scrollView = ui::ScrollView::create();
|
ui::ScrollView* scrollView = ui::ScrollView::create();
|
||||||
scrollView->setTouchEnabled(true);
|
|
||||||
scrollView->setSize(Size(280.0f, 150.0f));
|
scrollView->setSize(Size(280.0f, 150.0f));
|
||||||
Size backgroundSize = background->getContentSize();
|
Size backgroundSize = background->getContentSize();
|
||||||
scrollView->setPosition(Point((widgetSize.width - backgroundSize.width) / 2.0f +
|
scrollView->setPosition(Point((widgetSize.width - backgroundSize.width) / 2.0f +
|
||||||
|
@ -53,31 +47,24 @@ bool UIScrollViewTest_Vertical::init()
|
||||||
(backgroundSize.height - scrollView->getSize().height) / 2.0f));
|
(backgroundSize.height - scrollView->getSize().height) / 2.0f));
|
||||||
_uiLayer->addChild(scrollView);
|
_uiLayer->addChild(scrollView);
|
||||||
|
|
||||||
ImageView* imageView = ImageView::create();
|
ImageView* imageView = ImageView::create("cocosui/ccicon.png");
|
||||||
imageView->loadTexture("cocosui/ccicon.png");
|
|
||||||
|
|
||||||
float innerWidth = scrollView->getSize().width;
|
float innerWidth = scrollView->getSize().width;
|
||||||
float innerHeight = scrollView->getSize().height + imageView->getSize().height;
|
float innerHeight = scrollView->getSize().height + imageView->getSize().height;
|
||||||
|
|
||||||
scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
|
scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
|
||||||
|
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||||
button->setTouchEnabled(true);
|
|
||||||
button->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
button->setPosition(Point(innerWidth / 2.0f, scrollView->getInnerContainerSize().height - button->getSize().height / 2.0f));
|
button->setPosition(Point(innerWidth / 2.0f, scrollView->getInnerContainerSize().height - button->getSize().height / 2.0f));
|
||||||
scrollView->addChild(button);
|
scrollView->addChild(button);
|
||||||
|
|
||||||
Button* titleButton = Button::create();
|
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||||
titleButton->setTouchEnabled(true);
|
|
||||||
titleButton->loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "");
|
|
||||||
titleButton->setTitleText("Title Button");
|
titleButton->setTitleText("Title Button");
|
||||||
titleButton->setPosition(Point(innerWidth / 2.0f, button->getBottomInParent() - button->getSize().height));
|
titleButton->setPosition(Point(innerWidth / 2.0f, button->getBottomInParent() - button->getSize().height));
|
||||||
scrollView->addChild(titleButton);
|
scrollView->addChild(titleButton);
|
||||||
|
|
||||||
Button* button_scale9 = Button::create();
|
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
button_scale9->setTouchEnabled(true);
|
|
||||||
button_scale9->setScale9Enabled(true);
|
button_scale9->setScale9Enabled(true);
|
||||||
button_scale9->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||||
button_scale9->setPosition(Point(innerWidth / 2.0f, titleButton->getBottomInParent() - titleButton->getSize().height));
|
button_scale9->setPosition(Point(innerWidth / 2.0f, titleButton->getBottomInParent() - titleButton->getSize().height));
|
||||||
scrollView->addChild(button_scale9);
|
scrollView->addChild(button_scale9);
|
||||||
|
@ -109,18 +96,12 @@ bool UIScrollViewTest_Horizontal::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add a label in which the scrollview alert will be displayed
|
// Add a label in which the scrollview alert will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("Move by horizontal direction","fonts/Marker Felt.ttf",32);
|
||||||
_displayValueLabel->setText("Move by horizontal direction");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getContentSize().height * 1.5f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("ScrollView horizontal","fonts/Marker Felt.ttf",30);
|
||||||
alert->setText("ScrollView horizontal");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
@ -133,7 +114,6 @@ bool UIScrollViewTest_Horizontal::init()
|
||||||
ui::ScrollView* scrollView = ui::ScrollView::create();
|
ui::ScrollView* scrollView = ui::ScrollView::create();
|
||||||
scrollView->setBounceEnabled(true);
|
scrollView->setBounceEnabled(true);
|
||||||
scrollView->setDirection(SCROLLVIEW_DIR_HORIZONTAL);
|
scrollView->setDirection(SCROLLVIEW_DIR_HORIZONTAL);
|
||||||
scrollView->setTouchEnabled(true);
|
|
||||||
scrollView->setSize(Size(280.0f, 150.0f));
|
scrollView->setSize(Size(280.0f, 150.0f));
|
||||||
scrollView->setInnerContainerSize(scrollView->getSize());
|
scrollView->setInnerContainerSize(scrollView->getSize());
|
||||||
Size backgroundSize = background->getContentSize();
|
Size backgroundSize = background->getContentSize();
|
||||||
|
@ -143,33 +123,26 @@ bool UIScrollViewTest_Horizontal::init()
|
||||||
(backgroundSize.height - scrollView->getSize().height) / 2.0f));
|
(backgroundSize.height - scrollView->getSize().height) / 2.0f));
|
||||||
_uiLayer->addChild(scrollView);
|
_uiLayer->addChild(scrollView);
|
||||||
|
|
||||||
ImageView* imageView = ImageView::create();
|
ImageView* imageView = ImageView::create("cocosui/ccicon.png");
|
||||||
imageView->loadTexture("cocosui/ccicon.png");
|
|
||||||
|
|
||||||
float innerWidth = scrollView->getSize().width + imageView->getSize().width;
|
float innerWidth = scrollView->getSize().width + imageView->getSize().width;
|
||||||
float innerHeight = scrollView->getSize().height;
|
float innerHeight = scrollView->getSize().height;
|
||||||
|
|
||||||
scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
|
scrollView->setInnerContainerSize(Size(innerWidth, innerHeight));
|
||||||
|
|
||||||
Button* button = Button::create();
|
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
|
||||||
button->setTouchEnabled(true);
|
|
||||||
button->loadTextures("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png", "");
|
|
||||||
button->setPosition(Point(button->getSize().width / 2.0f,
|
button->setPosition(Point(button->getSize().width / 2.0f,
|
||||||
scrollView->getInnerContainerSize().height - button->getSize().height / 2.0f));
|
scrollView->getInnerContainerSize().height - button->getSize().height / 2.0f));
|
||||||
scrollView->addChild(button);
|
scrollView->addChild(button);
|
||||||
|
|
||||||
Button* titleButton = Button::create();
|
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||||
titleButton->setTouchEnabled(true);
|
|
||||||
titleButton->loadTextures("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png", "");
|
|
||||||
titleButton->setTitleText("Title Button");
|
titleButton->setTitleText("Title Button");
|
||||||
titleButton->setPosition(Point(button->getRightInParent() + button->getSize().width / 2.0f,
|
titleButton->setPosition(Point(button->getRightInParent() + button->getSize().width / 2.0f,
|
||||||
button->getBottomInParent() - button->getSize().height / 2.0f));
|
button->getBottomInParent() - button->getSize().height / 2.0f));
|
||||||
scrollView->addChild(titleButton);
|
scrollView->addChild(titleButton);
|
||||||
|
|
||||||
Button* button_scale9 = Button::create();
|
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||||
button_scale9->setTouchEnabled(true);
|
|
||||||
button_scale9->setScale9Enabled(true);
|
button_scale9->setScale9Enabled(true);
|
||||||
button_scale9->loadTextures("cocosui/button.png", "cocosui/buttonHighlighted.png", "");
|
|
||||||
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
button_scale9->setSize(Size(100.0f, button_scale9->getContentSize().height));
|
||||||
button_scale9->setPosition(Point(titleButton->getRightInParent() + titleButton->getSize().width / 2.0f,
|
button_scale9->setPosition(Point(titleButton->getRightInParent() + titleButton->getSize().width / 2.0f,
|
||||||
titleButton->getBottomInParent() - titleButton->getSize().height / 2.0f));
|
titleButton->getBottomInParent() - titleButton->getSize().height / 2.0f));
|
||||||
|
@ -203,19 +176,13 @@ bool UIScrollViewTest_Both::init()
|
||||||
Size widgetSize = _widget->getSize();;
|
Size widgetSize = _widget->getSize();;
|
||||||
|
|
||||||
// Add a label in which the dragpanel events will be displayed
|
// Add a label in which the dragpanel events will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("Move by any direction","fonts/Marker Felt.ttf",32);
|
||||||
_displayValueLabel->setText("Move by any direction");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("ScrollView both","fonts/Marker Felt.ttf",30);
|
||||||
alert->setText("ScrollView both");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
@ -237,9 +204,7 @@ bool UIScrollViewTest_Both::init()
|
||||||
(backgroundSize.width - scrollView->getSize().width) / 2.0f,
|
(backgroundSize.width - scrollView->getSize().width) / 2.0f,
|
||||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||||
(backgroundSize.height - scrollView->getSize().height) / 2.0f));
|
(backgroundSize.height - scrollView->getSize().height) / 2.0f));
|
||||||
ImageView* imageView = ImageView::create();
|
ImageView* imageView = ImageView::create("Hello.png");
|
||||||
imageView->setTouchEnabled(true);
|
|
||||||
imageView->loadTexture("Hello.png");
|
|
||||||
scrollView->addChild(imageView);
|
scrollView->addChild(imageView);
|
||||||
|
|
||||||
scrollView->setInnerContainerSize(imageView->getContentSize());
|
scrollView->setInnerContainerSize(imageView->getContentSize());
|
||||||
|
@ -272,19 +237,13 @@ bool UIScrollViewTest_ScrollToPercentBothDirection::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add a label in which the dragpanel events will be displayed
|
// Add a label in which the dragpanel events will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("No Event", "fonts/Marker Felt.ttf",30);
|
||||||
// _displayValueLabel->setText("No Event");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("ScrollView scroll to percent both directrion","fonts/Marker Felt.ttf",20);
|
||||||
alert->setText("ScrollView scroll to percent both directrion");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(20);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
@ -305,8 +264,7 @@ bool UIScrollViewTest_ScrollToPercentBothDirection::init()
|
||||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||||
(backgroundSize.height - sc->getSize().height) / 2.0f));
|
(backgroundSize.height - sc->getSize().height) / 2.0f));
|
||||||
sc->scrollToPercentBothDirection(Point(50, 50), 1, true);
|
sc->scrollToPercentBothDirection(Point(50, 50), 1, true);
|
||||||
ImageView* iv = ImageView::create();
|
ImageView* iv = ImageView::create("cocosui/Hello.png");
|
||||||
iv->loadTexture("cocosui/Hello.png");
|
|
||||||
iv->setPosition(Point(240, 160));
|
iv->setPosition(Point(240, 160));
|
||||||
sc->addChild(iv);
|
sc->addChild(iv);
|
||||||
_uiLayer->addChild(sc);
|
_uiLayer->addChild(sc);
|
||||||
|
@ -334,19 +292,13 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add a label in which the dragpanel events will be displayed
|
// Add a label in which the dragpanel events will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",32);
|
||||||
// _displayValueLabel->setText("No Event");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("ScrollView scroll to percent both directrion bounce","fonts/Marker Felt.ttf",20);
|
||||||
alert->setText("ScrollView scroll to percent both directrion bounce");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(20);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 4.5));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
@ -368,8 +320,7 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce::init()
|
||||||
(widgetSize.height - backgroundSize.height) / 2.0f +
|
(widgetSize.height - backgroundSize.height) / 2.0f +
|
||||||
(backgroundSize.height - sc->getSize().height) / 2.0f));
|
(backgroundSize.height - sc->getSize().height) / 2.0f));
|
||||||
sc->scrollToPercentBothDirection(Point(50, 50), 1, true);
|
sc->scrollToPercentBothDirection(Point(50, 50), 1, true);
|
||||||
ImageView* iv = ImageView::create();
|
ImageView* iv = ImageView::create("cocosui/Hello.png");
|
||||||
iv->loadTexture("cocosui/Hello.png");
|
|
||||||
iv->setPosition(Point(240, 160));
|
iv->setPosition(Point(240, 160));
|
||||||
sc->addChild(iv);
|
sc->addChild(iv);
|
||||||
_uiLayer->addChild(sc);
|
_uiLayer->addChild(sc);
|
||||||
|
|
|
@ -22,26 +22,19 @@ bool UISliderTest::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add a label in which the slider alert will be displayed
|
// Add a label in which the slider alert will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("Move the slider thumb","Move the slider thumb",32);
|
||||||
_displayValueLabel->setText("Move the slider thumb");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Slider","fonts/Marker Felt.ttf",30);
|
||||||
alert->setText("Slider");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the slider
|
// Create the slider
|
||||||
Slider* slider = Slider::create();
|
Slider* slider = Slider::create();
|
||||||
slider->setTouchEnabled(true);
|
|
||||||
slider->loadBarTexture("cocosui/sliderTrack.png");
|
slider->loadBarTexture("cocosui/sliderTrack.png");
|
||||||
slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
|
slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
|
||||||
slider->loadProgressBarTexture("cocosui/sliderProgress.png");
|
slider->loadProgressBarTexture("cocosui/sliderProgress.png");
|
||||||
|
@ -49,19 +42,6 @@ bool UISliderTest::init()
|
||||||
slider->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest::sliderEvent));
|
slider->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest::sliderEvent));
|
||||||
_uiLayer->addChild(slider);
|
_uiLayer->addChild(slider);
|
||||||
|
|
||||||
/*
|
|
||||||
// Create the slider that set allow min progress and allow max progress
|
|
||||||
Slider* sliderAllow = Slider::create();
|
|
||||||
// sliderAllow->setMinAllowPercent(20);
|
|
||||||
// sliderAllow->setMaxAllowPercent(80);
|
|
||||||
sliderAllow->setTouchEnabled(true);
|
|
||||||
sliderAllow->loadBarTexture("cocosui/sliderTrack.png");
|
|
||||||
sliderAllow->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
|
|
||||||
sliderAllow->loadProgressBarTexture("cocosui/sliderProgress.png");
|
|
||||||
sliderAllow->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - sliderAllow->getSize().height * 2.0f));
|
|
||||||
sliderAllow->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest::sliderEvent));
|
|
||||||
_uiLayer->addChild(sliderAllow);
|
|
||||||
*/
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -97,26 +77,19 @@ bool UISliderTest_Scale9::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add a label in which the slider alert will be displayed
|
// Add a label in which the slider alert will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("Move the slider thumb","fonts/Marker Felt.ttf",32);
|
||||||
_displayValueLabel->setText("Move the slider thumb");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text *alert = Text::create();
|
Text *alert = Text::create("Slider scale9 render","fonts/Marker Felt.ttf",30);
|
||||||
alert->setText("Slider scale9 render");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the slider
|
// Create the slider
|
||||||
Slider* slider = Slider::create();
|
Slider* slider = Slider::create();
|
||||||
slider->setTouchEnabled(true);
|
|
||||||
slider->loadBarTexture("cocosui/sliderTrack2.png");
|
slider->loadBarTexture("cocosui/sliderTrack2.png");
|
||||||
slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
|
slider->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
|
||||||
slider->loadProgressBarTexture("cocosui/slider_bar_active_9patch.png");
|
slider->loadProgressBarTexture("cocosui/slider_bar_active_9patch.png");
|
||||||
|
@ -127,22 +100,6 @@ bool UISliderTest_Scale9::init()
|
||||||
slider->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest_Scale9::sliderEvent));
|
slider->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest_Scale9::sliderEvent));
|
||||||
_uiLayer->addChild(slider);
|
_uiLayer->addChild(slider);
|
||||||
|
|
||||||
/*
|
|
||||||
// Create the slider that set allow min progress and allow max progress
|
|
||||||
Slider* sliderAllow = Slider::create();
|
|
||||||
// sliderAllow->setMinAllowPercent(20);
|
|
||||||
// sliderAllow->setMaxAllowPercent(80);
|
|
||||||
sliderAllow->setTouchEnabled(true);
|
|
||||||
sliderAllow->loadBarTexture("cocosui/sliderTrack2.png");
|
|
||||||
sliderAllow->loadSlidBallTextures("cocosui/sliderThumb.png", "cocosui/sliderThumb.png", "");
|
|
||||||
sliderAllow->loadProgressBarTexture("cocosui/slider_bar_active_9patch.png");
|
|
||||||
sliderAllow->setScale9Enabled(true);
|
|
||||||
sliderAllow->setCapInsets(Rect(0, 0, 0, 0));
|
|
||||||
sliderAllow->setSize(Size(250.0f, 10.0f / Director::getInstance()->getContentScaleFactor()));
|
|
||||||
sliderAllow->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - slider->getSize().height * 3.0f));
|
|
||||||
sliderAllow->addEventListenerSlider(this, sliderpercentchangedselector(UISliderTest_Scale9::sliderEvent));
|
|
||||||
_uiLayer->addChild(sliderAllow);
|
|
||||||
*/
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,17 +12,13 @@ bool UITextAtlasTest::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("TextAtlas","fonts/Marker Felt.ttf",30);
|
||||||
alert->setText("TextAtlas");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the text atlas
|
// Create the text atlas
|
||||||
TextAtlas* textAtlas = TextAtlas::create();
|
TextAtlas* textAtlas = TextAtlas::create("1234567890", "cocosui/labelatlas.png", 17, 22, "0");
|
||||||
textAtlas->setProperty("1234567890", "cocosui/labelatlas.png", 17, 22, "0");
|
|
||||||
textAtlas->setPosition(Point((widgetSize.width) / 2, widgetSize.height / 2.0f));
|
textAtlas->setPosition(Point((widgetSize.width) / 2, widgetSize.height / 2.0f));
|
||||||
_uiLayer->addChild(textAtlas);
|
_uiLayer->addChild(textAtlas);
|
||||||
|
|
||||||
|
|
|
@ -11,18 +11,13 @@ bool UITextBMFontTest::init()
|
||||||
{
|
{
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("TextBMFont","TextBMFont",30);
|
||||||
alert->setText("TextBMFont");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the TextBMFont
|
// Create the TextBMFont
|
||||||
TextBMFont* textBMFont = TextBMFont::create();
|
TextBMFont* textBMFont = TextBMFont::create("BMFont", "cocosui/bitmapFontTest2.fnt");
|
||||||
textBMFont->setFntFile("cocosui/bitmapFontTest2.fnt");
|
|
||||||
textBMFont->setText("BMFont");
|
|
||||||
textBMFont->setPosition(Point(widgetSize.width / 2, widgetSize.height / 2.0f + textBMFont->getSize().height / 8.0f));
|
textBMFont->setPosition(Point(widgetSize.width / 2, widgetSize.height / 2.0f + textBMFont->getSize().height / 8.0f));
|
||||||
_uiLayer->addChild(textBMFont);
|
_uiLayer->addChild(textBMFont);
|
||||||
|
|
||||||
|
|
|
@ -20,35 +20,24 @@ bool UITextFieldTest::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add a label in which the textfield events will be displayed
|
// Add a label in which the textfield events will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",32);
|
||||||
_displayValueLabel->setText("No Event");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("TextField","fonts/Marker Felt.ttf",30);
|
||||||
alert->setText("TextField");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the textfield
|
// Create the textfield
|
||||||
TextField* textField = TextField::create();
|
TextField* textField = TextField::create("input words here","fonts/Marker Felt.ttf",30);
|
||||||
textField->setTouchEnabled(true);
|
|
||||||
textField->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
textField->setFontSize(30);
|
|
||||||
textField->setPlaceHolder("input words here");
|
|
||||||
textField->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
textField->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest::textFieldEvent));
|
textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest::textFieldEvent));
|
||||||
_uiLayer->addChild(textField);
|
_uiLayer->addChild(textField);
|
||||||
|
|
||||||
// textField->setColor(Color3B(255, 0, 0));
|
|
||||||
// textField->setColorSpaceHolder(Color3B(255, 255, 255));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -109,31 +98,21 @@ bool UITextFieldTest_MaxLength::init()
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
|
||||||
// Add a label in which the textfield events will be displayed
|
// Add a label in which the textfield events will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",32);
|
||||||
_displayValueLabel->setText("No Event");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
_displayValueLabel->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text *alert = Text::create();
|
Text *alert = Text::create("TextField max length","fonts/Marker Felt.ttf",30);
|
||||||
alert->setText("TextField max length");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getSize().height * 3.075f));
|
alert->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the textfield
|
// Create the textfield
|
||||||
TextField* textField = TextField::create();
|
TextField* textField = TextField::create("input words here","fonts/Marker Felt.ttf",30);
|
||||||
textField->setMaxLengthEnabled(true);
|
textField->setMaxLengthEnabled(true);
|
||||||
textField->setMaxLength(3);
|
textField->setMaxLength(3);
|
||||||
textField->setTouchEnabled(true);
|
|
||||||
textField->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
textField->setFontSize(30);
|
|
||||||
textField->setPlaceHolder("input words here");
|
|
||||||
textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
|
textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
|
||||||
textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest_MaxLength::textFieldEvent));
|
textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest_MaxLength::textFieldEvent));
|
||||||
_uiLayer->addChild(textField);
|
_uiLayer->addChild(textField);
|
||||||
|
@ -203,31 +182,21 @@ bool UITextFieldTest_Password::init()
|
||||||
Size screenSize = CCDirector::getInstance()->getWinSize();
|
Size screenSize = CCDirector::getInstance()->getWinSize();
|
||||||
|
|
||||||
// Add a label in which the textfield events will be displayed
|
// Add a label in which the textfield events will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",32);
|
||||||
_displayValueLabel->setText("No Event");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(32);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1.0f));
|
||||||
_displayValueLabel->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
_displayValueLabel->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5f));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text *alert = Text::create();
|
Text *alert = Text::create("TextField password","fonts/Marker Felt.ttf",30);
|
||||||
alert->setText("TextField password");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getSize().height * 3.075f));
|
alert->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getSize().height * 3.075f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the textfield
|
// Create the textfield
|
||||||
TextField* textField = TextField::create();
|
TextField* textField = TextField::create("input password here","fonts/Marker Felt.ttf",30);
|
||||||
textField->setPasswordEnabled(true);
|
textField->setPasswordEnabled(true);
|
||||||
textField->setPasswordStyleText("*");
|
textField->setPasswordStyleText("*");
|
||||||
textField->setTouchEnabled(true);
|
|
||||||
textField->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
textField->setFontSize(30);
|
|
||||||
textField->setPlaceHolder("input password here");
|
|
||||||
textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
|
textField->setPosition(Point(screenSize.width / 2.0f, screenSize.height / 2.0f));
|
||||||
textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest_Password::textFieldEvent));
|
textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest_Password::textFieldEvent));
|
||||||
_uiLayer->addChild(textField);
|
_uiLayer->addChild(textField);
|
||||||
|
@ -292,33 +261,23 @@ bool UITextFieldTest_LineWrap::init()
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
// Add a label in which the textfield events will be displayed
|
// Add a label in which the textfield events will be displayed
|
||||||
_displayValueLabel = Text::create();
|
_displayValueLabel = Text::create("No Event","fonts/Marker Felt.ttf",30);
|
||||||
_displayValueLabel->setText("No Event");
|
|
||||||
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
_displayValueLabel->setFontSize(30);
|
|
||||||
_displayValueLabel->setAnchorPoint(Point(0.5f, -1));
|
_displayValueLabel->setAnchorPoint(Point(0.5f, -1));
|
||||||
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5));
|
_displayValueLabel->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + _displayValueLabel->getSize().height * 1.5));
|
||||||
_uiLayer->addChild(_displayValueLabel);
|
_uiLayer->addChild(_displayValueLabel);
|
||||||
|
|
||||||
// Add the alert
|
// Add the alert
|
||||||
Text *alert = Text::create();
|
Text *alert = Text::create("TextField line wrap","fonts/Marker Felt.ttf",30);
|
||||||
alert->setText("TextField line wrap");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 3.075));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the textfield
|
// Create the textfield
|
||||||
TextField* textField = TextField::create();
|
TextField* textField = TextField::create("input words here","fonts/Marker Felt.ttf",30);
|
||||||
textField->ignoreContentAdaptWithSize(false);
|
textField->ignoreContentAdaptWithSize(false);
|
||||||
textField->setSize(Size(240, 160));
|
textField->setSize(Size(240, 160));
|
||||||
textField->setTextHorizontalAlignment(TextHAlignment::CENTER);
|
textField->setTextHorizontalAlignment(TextHAlignment::CENTER);
|
||||||
textField->setTextVerticalAlignment(TextVAlignment::CENTER);
|
textField->setTextVerticalAlignment(TextVAlignment::CENTER);
|
||||||
textField->setTouchEnabled(true);
|
|
||||||
textField->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
textField->setFontSize(30);
|
|
||||||
textField->setPlaceHolder("input words here");
|
|
||||||
textField->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
textField->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
|
||||||
textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest_LineWrap::textFieldEvent));
|
textField->addEventListenerTextField(this, textfieldeventselector(UITextFieldTest_LineWrap::textFieldEvent));
|
||||||
_uiLayer->addChild(textField);
|
_uiLayer->addChild(textField);
|
||||||
|
|
|
@ -11,19 +11,13 @@ bool UITextTest::init()
|
||||||
{
|
{
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Text","fonts/Marker Felt.ttf", 30);
|
||||||
alert->setText("Text");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the text
|
// Create the text
|
||||||
Text* text = Text::create();
|
Text* text = Text::create("Text", "AmericanTypewriter", 30);
|
||||||
text->setText("Text");
|
|
||||||
text->setFontName("AmericanTypewriter");
|
|
||||||
text->setFontSize(30);
|
|
||||||
text->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + text->getSize().height / 4.0f));
|
text->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + text->getSize().height / 4.0f));
|
||||||
_uiLayer->addChild(text);
|
_uiLayer->addChild(text);
|
||||||
|
|
||||||
|
@ -40,22 +34,16 @@ bool UITextTest_LineWrap::init()
|
||||||
{
|
{
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Text line wrap","fonts/Marker Felt.ttf",30);
|
||||||
alert->setText("Text line wrap");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the line wrap
|
// Create the line wrap
|
||||||
Text* text = Text::create();
|
Text* text = Text::create("Text can line wrap","AmericanTypewriter",32);
|
||||||
text->ignoreContentAdaptWithSize(false);
|
text->ignoreContentAdaptWithSize(false);
|
||||||
text->setSize(Size(280, 150));
|
text->setSize(Size(280, 150));
|
||||||
text->setTextHorizontalAlignment(TextHAlignment::CENTER);
|
text->setTextHorizontalAlignment(TextHAlignment::CENTER);
|
||||||
text->setText("Text can line wrap");
|
|
||||||
text->setFontName("AmericanTypewriter");
|
|
||||||
text->setFontSize(32);
|
|
||||||
text->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - text->getSize().height / 8.0f));
|
text->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - text->getSize().height / 8.0f));
|
||||||
_uiLayer->addChild(text);
|
_uiLayer->addChild(text);
|
||||||
|
|
||||||
|
@ -171,19 +159,13 @@ bool UITextTest_TTF::init()
|
||||||
{
|
{
|
||||||
Size widgetSize = _widget->getSize();
|
Size widgetSize = _widget->getSize();
|
||||||
|
|
||||||
Text* alert = Text::create();
|
Text* alert = Text::create("Text set TTF font","fonts/Marker Felt.ttf",30);
|
||||||
alert->setText("Text set TTF font");
|
|
||||||
alert->setFontName("fonts/Marker Felt.ttf");
|
|
||||||
alert->setFontSize(30);
|
|
||||||
alert->setColor(Color3B(159, 168, 176));
|
alert->setColor(Color3B(159, 168, 176));
|
||||||
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
alert->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75f));
|
||||||
_uiLayer->addChild(alert);
|
_uiLayer->addChild(alert);
|
||||||
|
|
||||||
// Create the text, and set font with .ttf
|
// Create the text, and set font with .ttf
|
||||||
Text* text = Text::create();
|
Text* text = Text::create("Text","fonts/A Damn Mess.ttf",30);
|
||||||
text->setText("Text");
|
|
||||||
text->setFontName("fonts/A Damn Mess.ttf");
|
|
||||||
text->setFontSize(30);
|
|
||||||
text->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + text->getSize().height / 4.0f));
|
text->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + text->getSize().height / 4.0f));
|
||||||
_uiLayer->addChild(text);
|
_uiLayer->addChild(text);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "NewEventDispatcherTest.h"
|
#include "NewEventDispatcherTest.h"
|
||||||
#include "testResource.h"
|
#include "testResource.h"
|
||||||
|
#include "CCAutoreleasePool.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -27,7 +28,8 @@ std::function<Layer*()> createFunctions[] =
|
||||||
CL(PauseResumeTargetTest),
|
CL(PauseResumeTargetTest),
|
||||||
CL(Issue4129),
|
CL(Issue4129),
|
||||||
CL(Issue4160),
|
CL(Issue4160),
|
||||||
CL(DanglingNodePointersTest)
|
CL(DanglingNodePointersTest),
|
||||||
|
CL(RegisterAndUnregisterWhileEventHanldingTest)
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int TEST_CASE_COUNT = sizeof(createFunctions) / sizeof(createFunctions[0]);
|
unsigned int TEST_CASE_COUNT = sizeof(createFunctions) / sizeof(createFunctions[0]);
|
||||||
|
@ -1413,3 +1415,44 @@ std::string DanglingNodePointersTest::subtitle() const
|
||||||
"CC_NODE_DEBUG_VERIFY_EVENT_LISTENERS == 1\n&& COCOS2D_DEBUG > 0";
|
"CC_NODE_DEBUG_VERIFY_EVENT_LISTENERS == 1\n&& COCOS2D_DEBUG > 0";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RegisterAndUnregisterWhileEventHanldingTest::RegisterAndUnregisterWhileEventHanldingTest()
|
||||||
|
{
|
||||||
|
Point origin = Director::getInstance()->getVisibleOrigin();
|
||||||
|
Size size = Director::getInstance()->getVisibleSize();
|
||||||
|
|
||||||
|
auto callback1 = [=](DanglingNodePointersTestSprite * sprite)
|
||||||
|
{
|
||||||
|
auto callback2 = [](DanglingNodePointersTestSprite * sprite)
|
||||||
|
{
|
||||||
|
CCASSERT(false, "This should never get called!");
|
||||||
|
};
|
||||||
|
|
||||||
|
{
|
||||||
|
AutoreleasePool pool;
|
||||||
|
|
||||||
|
auto sprite2 = DanglingNodePointersTestSprite::create(callback2);
|
||||||
|
sprite2->setTexture("Images/CyanSquare.png");
|
||||||
|
sprite2->setPosition(origin+Point(size.width/2, size.height/2));
|
||||||
|
|
||||||
|
addChild(sprite2, 0);
|
||||||
|
removeChild(sprite2);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto sprite1 = DanglingNodePointersTestSprite::create(callback1);
|
||||||
|
sprite1->setTexture("Images/CyanSquare.png");
|
||||||
|
sprite1->setPosition(origin+Point(size.width/2, size.height/2));
|
||||||
|
addChild(sprite1, -10);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string RegisterAndUnregisterWhileEventHanldingTest::title() const
|
||||||
|
{
|
||||||
|
return "RegisterAndUnregisterWhileEventHanldingTest";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string RegisterAndUnregisterWhileEventHanldingTest::subtitle() const
|
||||||
|
{
|
||||||
|
return "Tap the square multiple times - should not crash!";
|
||||||
|
}
|
||||||
|
|
|
@ -217,4 +217,14 @@ public:
|
||||||
virtual std::string subtitle() const override;
|
virtual std::string subtitle() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RegisterAndUnregisterWhileEventHanldingTest : public EventDispatcherTestDemo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CREATE_FUNC(RegisterAndUnregisterWhileEventHanldingTest);
|
||||||
|
RegisterAndUnregisterWhileEventHanldingTest();
|
||||||
|
|
||||||
|
virtual std::string title() const override;
|
||||||
|
virtual std::string subtitle() const override;
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* defined(__samples__NewEventDispatcherTest__) */
|
#endif /* defined(__samples__NewEventDispatcherTest__) */
|
||||||
|
|
|
@ -947,6 +947,10 @@ void VisitSceneGraph::update(float dt)
|
||||||
CC_PROFILER_START( this->profilerName() );
|
CC_PROFILER_START( this->profilerName() );
|
||||||
this->visit();
|
this->visit();
|
||||||
CC_PROFILER_STOP( this->profilerName() );
|
CC_PROFILER_STOP( this->profilerName() );
|
||||||
|
|
||||||
|
// Call `Renderer::clean` to prevent crash if current scene is destroyed.
|
||||||
|
// The render commands associated with current scene should be cleaned.
|
||||||
|
Director::getInstance()->getRenderer()->clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string VisitSceneGraph::title() const
|
std::string VisitSceneGraph::title() const
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
static int sceneIdx = -1;
|
static int sceneIdx = -1;
|
||||||
|
|
||||||
#define MAX_LAYER 9
|
#define MAX_LAYER 8
|
||||||
|
|
||||||
static Layer* createShaderLayer(int nIndex)
|
static Layer* createShaderLayer(int nIndex)
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,6 @@ static Layer* createShaderLayer(int nIndex)
|
||||||
case 5: return new ShaderPlasma();
|
case 5: return new ShaderPlasma();
|
||||||
case 6: return new ShaderBlur();
|
case 6: return new ShaderBlur();
|
||||||
case 7: return new ShaderRetroEffect();
|
case 7: return new ShaderRetroEffect();
|
||||||
case 8: return new ShaderFail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -745,58 +744,6 @@ std::string ShaderRetroEffect::subtitle() const
|
||||||
return "sin() effect with moving colors";
|
return "sin() effect with moving colors";
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShaderFail
|
|
||||||
const GLchar *shader_frag_fail = "\n\
|
|
||||||
#ifdef GL_ES \n\
|
|
||||||
precision lowp float; \n\
|
|
||||||
#endif \n\
|
|
||||||
\n\
|
|
||||||
varying vec2 v_texCoord; \n\
|
|
||||||
uniform sampler2D CC_Texture0; \n\
|
|
||||||
\n\
|
|
||||||
vec4 colors[10]; \n\
|
|
||||||
\n\
|
|
||||||
void main(void) \n\
|
|
||||||
{ \n\
|
|
||||||
colors[0] = vec4(1,0,0,1); \n\
|
|
||||||
colors[1] = vec4(0,1,0,1); \n\
|
|
||||||
colors[2] = vec4(0,0,1,1); \n\
|
|
||||||
colors[3] = vec4(0,1,1,1); \n\
|
|
||||||
colors[4] = vec4(1,0,1,1); \n\
|
|
||||||
colors[5] = vec4(1,1,0,1); \n\
|
|
||||||
colors[6] = vec4(1,1,1,1); \n\
|
|
||||||
colors[7] = vec4(1,0.5,0,1); \n\
|
|
||||||
colors[8] = vec4(1,0.5,0.5,1); \n\
|
|
||||||
colors[9] = vec4(0.5,0.5,1,1); \n\
|
|
||||||
\n\
|
|
||||||
int y = int( mod(gl_FragCoord.y / 3.0, 10.0 ) ); \n\
|
|
||||||
gl_FragColor = colors[z] * texture2D(CC_Texture0, v_texCoord); \n\
|
|
||||||
} \n\
|
|
||||||
\n";
|
|
||||||
|
|
||||||
ShaderFail::ShaderFail()
|
|
||||||
{
|
|
||||||
auto p = new GLProgram();
|
|
||||||
p->initWithByteArrays(ccPositionTexture_vert, shader_frag_fail);
|
|
||||||
|
|
||||||
p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
|
|
||||||
p->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
|
|
||||||
|
|
||||||
p->link();
|
|
||||||
p->updateUniforms();
|
|
||||||
p->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ShaderFail::title() const
|
|
||||||
{
|
|
||||||
return "Shader: Invalid shader";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ShaderFail::subtitle() const
|
|
||||||
{
|
|
||||||
return "See console for output with useful error log";
|
|
||||||
}
|
|
||||||
|
|
||||||
///---------------------------------------
|
///---------------------------------------
|
||||||
//
|
//
|
||||||
// ShaderTestScene
|
// ShaderTestScene
|
||||||
|
|
|
@ -137,14 +137,6 @@ protected:
|
||||||
CustomCommand _customCommand;
|
CustomCommand _customCommand;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShaderFail : public ShaderTestDemo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ShaderFail();
|
|
||||||
virtual std::string title() const override;
|
|
||||||
virtual std::string subtitle() const override;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ShaderTestScene : public TestScene
|
class ShaderTestScene : public TestScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 47edbdcc88c99b4c0125bf70b847f03ad26f463d
|
Subproject commit 9aeab189f0a734423e7418c5ea11771c1db09592
|
|
@ -85,7 +85,7 @@ def main():
|
||||||
git_fetch_pr = "git fetch origin pull/" + str(pr_num) + "/merge"
|
git_fetch_pr = "git fetch origin pull/" + str(pr_num) + "/merge"
|
||||||
ret = os.system(git_fetch_pr)
|
ret = os.system(git_fetch_pr)
|
||||||
if(ret != 0):
|
if(ret != 0):
|
||||||
return(1)
|
return(2)
|
||||||
|
|
||||||
#checkout
|
#checkout
|
||||||
git_checkout = "git checkout -b " + "pull" + str(pr_num) + " FETCH_HEAD"
|
git_checkout = "git checkout -b " + "pull" + str(pr_num) + " FETCH_HEAD"
|
||||||
|
@ -99,7 +99,7 @@ def main():
|
||||||
git_update_submodule = "git submodule update --init --force"
|
git_update_submodule = "git submodule update --init --force"
|
||||||
ret = os.system(git_update_submodule)
|
ret = os.system(git_update_submodule)
|
||||||
if(ret != 0):
|
if(ret != 0):
|
||||||
return(1)
|
return(2)
|
||||||
|
|
||||||
# Generate binding glue codes
|
# Generate binding glue codes
|
||||||
if(branch == 'develop'):
|
if(branch == 'develop'):
|
||||||
|
|
Loading…
Reference in New Issue