-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-12295] Initial NavigationGroup implementation #69
Merged
joshthecoder
merged 6 commits into
appcelerator-archive:master
from
pec1985:timob-12295
Jun 14, 2013
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6511691
Initial NavigationGroup implementation
pec1985 71bea47
added modal option to nag group
pec1985 d118012
Moved NavigationGroup to root directory
pec1985 2df5a7d
Merge branch 'refs/heads/master' into timob-12295
pec1985 50227d0
Navigation Setters and Getters
pec1985 228e26a
Merge branch 'refs/heads/master' into timob-12295
pec1985 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
/* | ||
* TiUINavigationGroupProxy.cpp | ||
* | ||
* Created on: May 31, 2013 | ||
* Author: penrique | ||
*/ | ||
|
||
#include "TiUINavigationGroupProxy.h" | ||
#include "TiGenericFunctionObject.h" | ||
#include "SceneManager.h" | ||
#include "Window.h" | ||
#include "TiLogger.h" | ||
#include "NativeObject.h" | ||
|
||
|
||
/* How to create a NavigationGroup | ||
* | ||
* var nav = Ti.UI.createNavigationGroup(); | ||
* var rootWindow = Ti.UI.createWindow(); | ||
* nav.setRootWindow(rootWindow); | ||
* nav.open(); | ||
*/ | ||
|
||
/* | ||
* How to open a new window | ||
* | ||
* var otherWindow = Ti.UI.createWindow(); | ||
* nav.push(otherWindow); | ||
*/ | ||
|
||
/* | ||
* How to close the last window | ||
* | ||
* nav.pop(); | ||
*/ | ||
|
||
/* | ||
* How remove a specific window | ||
* | ||
* nav.remove(window); | ||
*/ | ||
|
||
/* | ||
* How to close the NavigationGroup | ||
* | ||
* nav.close() | ||
*/ | ||
|
||
TiUINavigationGroupProxy::TiUINavigationGroupProxy() { | ||
navigationScene_ = NULL; | ||
} | ||
|
||
TiUINavigationGroupProxy::~TiUINavigationGroupProxy() { | ||
// TODO Auto-generated destructor stub | ||
} | ||
|
||
TiUINavigationGroupProxy* TiUINavigationGroupProxy::createProxy(NativeObjectFactory* objectFactory) | ||
{ | ||
TiUINavigationGroupProxy* obj = new TiUINavigationGroupProxy; | ||
obj->setNativeObjectFactory(objectFactory); | ||
obj->initializeTiObject(NULL); | ||
return obj; | ||
} | ||
|
||
NavigationScene *TiUINavigationGroupProxy::getNavigationScene() | ||
{ | ||
if(navigationScene_ == NULL) { | ||
navigationScene_ = new NavigationScene(); | ||
} | ||
return navigationScene_; | ||
} | ||
|
||
void TiUINavigationGroupProxy::onCreateStaticMembers() | ||
{ | ||
TiProxy::onCreateStaticMembers(); | ||
TiGenericFunctionObject::addGenericFunctionToParent(this, "close", this, _close); | ||
TiGenericFunctionObject::addGenericFunctionToParent(this, "open", this, _open); | ||
TiGenericFunctionObject::addGenericFunctionToParent(this, "pop", this, _pop); | ||
TiGenericFunctionObject::addGenericFunctionToParent(this, "push", this, _push); | ||
TiGenericFunctionObject::addGenericFunctionToParent(this, "remove", this, _remove); | ||
|
||
|
||
// TODO: Replace these with the setters and getters | ||
// Waiting on https://github.com/appcelerator/titanium_mobile_blackberry/pull/63 | ||
TiGenericFunctionObject::addGenericFunctionToParent(this, "setWindow", this, _setWindow); | ||
TiGenericFunctionObject::addGenericFunctionToParent(this, "setRootWindow", this, _setRootWindow); | ||
TiGenericFunctionObject::addGenericFunctionToParent(this, "setBackButtonsVisible", this, _setBackButtonsVisible); | ||
TiGenericFunctionObject::addGenericFunctionToParent(this, "setPeekEnabled", this, _setPeekEnabled); | ||
TiGenericFunctionObject::addGenericFunctionToParent(this, "getPeekEnabled", this, _getPeekEnabled); | ||
// createSettersAndGetters("window", _setWindow, NULL); | ||
// createSettersAndGetters("rootWindow", _setRootWindow, NULL); | ||
// createSettersAndGetters("backButtonsVisible", _setBackButtonsVisible, NULL); | ||
// createSettersAndGetters("peekEnabled", _setPeekEnabled, NULL); | ||
|
||
} | ||
|
||
bb::cascades::Page* TiUINavigationGroupProxy::getPageFromTiObject(TiObject* obj) | ||
{ | ||
NativeObject *nativeObject = obj->getNativeObject(); | ||
if (nativeObject->getObjectType() == N_TYPE_WINDOW) { | ||
titanium::Window* window = static_cast<titanium::Window*>(nativeObject->getNativeHandle()); | ||
bb::cascades::Page* page = static_cast<bb::cascades::Page*>(window->scene()->pane()); | ||
return page; | ||
} | ||
return NULL; | ||
} | ||
|
||
Handle<Value> TiUINavigationGroupProxy::_setPeekEnabled(void* userContext, TiObject*, const Arguments& args) | ||
{ | ||
if(args.Length() > 0 && args[0]->IsBoolean()) | ||
{ | ||
TiUINavigationGroupProxy* proxy = (TiUINavigationGroupProxy*)userContext; | ||
NavigationScene *nav = proxy->getNavigationScene(); | ||
bb::cascades::NavigationPane *pane = static_cast<bb::cascades::NavigationPane*>(nav->pane()); | ||
Local<Boolean> b = args[0]->ToBoolean(); | ||
pane->setPeekEnabled(b->Value()); | ||
} | ||
return Undefined(); | ||
} | ||
|
||
Handle<Value> TiUINavigationGroupProxy::_getPeekEnabled(void* userContext, TiObject*, const Arguments& args) | ||
{ | ||
TiUINavigationGroupProxy* proxy = (TiUINavigationGroupProxy*)userContext; | ||
NavigationScene *nav = proxy->getNavigationScene(); | ||
bb::cascades::NavigationPane *pane = static_cast<bb::cascades::NavigationPane*>(nav->pane()); | ||
return Boolean::New(pane->isPeekEnabled()); | ||
} | ||
|
||
Handle<Value> TiUINavigationGroupProxy::_setBackButtonsVisible(void* userContext, TiObject*, const Arguments& args) | ||
{ | ||
if(args.Length() > 0 && args[0]->IsBoolean()) | ||
{ | ||
TiUINavigationGroupProxy* proxy = (TiUINavigationGroupProxy*)userContext; | ||
NavigationScene *nav = proxy->getNavigationScene(); | ||
bb::cascades::NavigationPane *pane = static_cast<bb::cascades::NavigationPane*>(nav->pane()); | ||
Local<Boolean> b = args[0]->ToBoolean(); | ||
pane->setBackButtonsVisible(b->Value()); | ||
} | ||
return Undefined(); | ||
} | ||
Handle<Value> TiUINavigationGroupProxy::_close(void* userContext, TiObject*, const Arguments& args) | ||
{ | ||
TiUINavigationGroupProxy* proxy = (TiUINavigationGroupProxy*)userContext; | ||
NavigationScene *nav = proxy->getNavigationScene(); | ||
if(args.Length() == 0) | ||
{ | ||
titanium::SceneManager::instance()->removeScene(nav); | ||
delete nav; | ||
proxy->navigationScene_ = NULL; | ||
} | ||
else if(args[0]->IsObject()) | ||
{ | ||
TiLogger::getInstance().log("[WARN] .close() is depricated, use .remove() instead."); | ||
return TiUINavigationGroupProxy::_remove(userContext, NULL, args); | ||
} | ||
return Undefined(); | ||
} | ||
Handle<Value> TiUINavigationGroupProxy::_open(void* userContext, TiObject*, const Arguments& args) | ||
{ | ||
TiUINavigationGroupProxy* proxy = (TiUINavigationGroupProxy*)userContext; | ||
NavigationScene *nav = proxy->getNavigationScene(); | ||
|
||
if(args.Length() == 0) { | ||
titanium::SceneManager::instance()->presentScene(nav); | ||
} | ||
else if(args.Length() > 0 && args[0]->IsObject()) | ||
{ | ||
TiLogger::getInstance().log("[WARN] .open() is depricated, use .push() instead."); | ||
return TiUINavigationGroupProxy::_push(userContext, NULL, args); | ||
} | ||
return Undefined(); | ||
} | ||
Handle<Value> TiUINavigationGroupProxy::_pop(void* userContext, TiObject*, const Arguments& args) | ||
{ | ||
TiUINavigationGroupProxy* proxy = (TiUINavigationGroupProxy*)userContext; | ||
NavigationScene *nav = proxy->getNavigationScene(); | ||
bb::cascades::NavigationPane *pane = static_cast<bb::cascades::NavigationPane*>(nav->pane()); | ||
pane->pop(); | ||
return Undefined(); | ||
} | ||
Handle<Value> TiUINavigationGroupProxy::_push(void* userContext, TiObject*, const Arguments& args) | ||
{ | ||
TiUINavigationGroupProxy* proxy = (TiUINavigationGroupProxy*)userContext; | ||
NavigationScene *nav = proxy->getNavigationScene(); | ||
|
||
if(args.Length() > 0 && args[0]->IsObject()) | ||
{ | ||
TiObject *obj = TiObject::getTiObjectFromJsObject(args[0]); | ||
bb::cascades::Page* page = proxy->getPageFromTiObject(obj); | ||
bb::cascades::NavigationPane *pane = static_cast<bb::cascades::NavigationPane*>(nav->pane()); | ||
|
||
page->setParent(0); | ||
pane->push(page); | ||
return Undefined(); | ||
} | ||
|
||
TiLogger::getInstance().log("[ERROR] .push() takes a Ti.UI.Window"); | ||
return Undefined(); | ||
} | ||
Handle<Value> TiUINavigationGroupProxy::_remove(void* userContext, TiObject*, const Arguments& args) | ||
{ | ||
TiUINavigationGroupProxy* proxy = (TiUINavigationGroupProxy*)userContext; | ||
NavigationScene *nav = proxy->getNavigationScene(); | ||
if(args.Length() > 0 && args[0]->IsObject()) | ||
{ | ||
TiObject *obj = TiObject::getTiObjectFromJsObject(args[0]); | ||
bb::cascades::Page *page = proxy->getPageFromTiObject(obj); | ||
bb::cascades::NavigationPane *pane = static_cast<bb::cascades::NavigationPane*>(nav->pane()); | ||
pane->remove(page); | ||
} | ||
return Undefined(); | ||
} | ||
Handle<Value> TiUINavigationGroupProxy::_setWindow(void* userContext, TiObject*, const Arguments& args) | ||
{ | ||
TiLogger::getInstance().log("[WARN] .setWindow() is deprecated, use .setRootWindow() instead"); | ||
return TiUINavigationGroupProxy::_push(userContext, NULL, args); | ||
} | ||
Handle<Value> TiUINavigationGroupProxy::_setRootWindow(void* userContext, TiObject*, const Arguments& args) | ||
{ | ||
return TiUINavigationGroupProxy::_push(userContext, NULL, args); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Appcelerator copyright header. |
||
* TiUINavigationGroupProxy.h | ||
* | ||
* Created on: May 31, 2013 | ||
* Author: penrique | ||
*/ | ||
|
||
#ifndef TIUINAVIGATIONGROUPPROXY_H_ | ||
#define TIUINAVIGATIONGROUPPROXY_H_ | ||
|
||
#include <bb/cascades/NavigationPane> | ||
#include <bb/cascades/Page> | ||
#include "TiProxy.h" | ||
#include "Scene.h" | ||
|
||
class NavigationScene: public titanium::Scene { | ||
Q_OBJECT | ||
public: | ||
NavigationScene(): titanium::Scene(new bb::cascades::NavigationPane()){} | ||
}; | ||
|
||
class TiUINavigationGroupProxy: public TiProxy { | ||
public: | ||
|
||
static TiUINavigationGroupProxy* createProxy(NativeObjectFactory* objectFactory); | ||
|
||
protected: | ||
virtual void onCreateStaticMembers(); | ||
private: | ||
|
||
static Handle<Value> _close(void* userContext, TiObject*, const Arguments& args); | ||
static Handle<Value> _open(void* userContext, TiObject*, const Arguments& args); | ||
static Handle<Value> _pop(void* userContext, TiObject*, const Arguments& args); | ||
static Handle<Value> _push(void* userContext, TiObject*, const Arguments& args); | ||
static Handle<Value> _remove(void* userContext, TiObject*, const Arguments& args); | ||
static Handle<Value> _setWindow(void* userContext, TiObject*, const Arguments& args); | ||
static Handle<Value> _setRootWindow(void* userContext, TiObject*, const Arguments& args); | ||
static Handle<Value> _setBackButtonsVisible(void* userContext, TiObject*, const Arguments& args); | ||
static Handle<Value> _setPeekEnabled(void* userContext, TiObject*, const Arguments& args); | ||
static Handle<Value> _getPeekEnabled(void* userContext, TiObject*, const Arguments& args); | ||
|
||
TiUINavigationGroupProxy(); | ||
virtual ~TiUINavigationGroupProxy(); | ||
|
||
NavigationScene *getNavigationScene(); | ||
bb::cascades::Page *getPageFromTiObject(TiObject*); | ||
NavigationScene *navigationScene_; | ||
}; | ||
|
||
#endif /* TIUINAVIGATIONGROUPPROXY_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the Appcelerator copyright header.