Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 12 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 15, 2013
Joshua Roesslein Implement the Tab.active property.
Allows developer to query if a tab is currently active.
The property is also writtable so when set to "true"
the tab becomes active. Setting it to any other value has no affect.

[TIMOB-12983]
e411a10
Commits on Mar 19, 2013
Joshua Roesslein Implement property TabGroup.activeTab.
[TIMOB-12983]
0a92ed8
Joshua Roesslein Fix a bug which caused proxy corruption with setters.
Do not override the TiObject* of a JavaScript proxy object.
This was leading to the proxy becoming un-usable since it
no longer pointed to a valid TiObject* instance.
c8f77b4
Joshua Roesslein Merge branch 'TIMOB-12983' 5263138
View
32 src/tibb/NativeControlObject.cpp
@@ -1023,6 +1023,30 @@ void NativeControlObject::blur() {
}
}
+PROP_SETGET(setActive)
+int NativeControlObject::setActive(TiObject* obj)
+{
+ return NATIVE_ERROR_NOTSUPPORTED;
+}
+
+PROP_SETGET(isActive)
+int NativeControlObject::isActive(TiObject* obj)
+{
+ return NATIVE_ERROR_NOTSUPPORTED;
+}
+
+PROP_SETGET(setActiveTab)
+int NativeControlObject::setActiveTab(TiObject* obj)
+{
+ return NATIVE_ERROR_NOTSUPPORTED;
+}
+
+PROP_SETGET(getActiveTab)
+int NativeControlObject::getActiveTab(TiObject* obj)
+{
+ return NATIVE_ERROR_NOTSUPPORTED;
+}
+
// PROP_SETTING_FUNCTION resolves the static name of the function, e.g.,
// PROP_SETTING_FUNCTION(setBackgroundColor) resolves to "prop_setBackgroundColor"
@@ -1100,7 +1124,13 @@ const static NATIVE_PROPSETGET_SETTING g_propSetGet[] =
{N_PROP_LEFTVIEW, PROP_SETGET_FUNCTION(setLeftView), NULL},
{N_PROP_RIGHTVIEW, PROP_SETGET_FUNCTION(setRightView), NULL},
////////////////////////
- {N_PROP_ZINDEX, PROP_SETGET_FUNCTION(setZIndex), PROP_SETGET_FUNCTION(getZIndex)}
+ {N_PROP_ZINDEX, PROP_SETGET_FUNCTION(setZIndex), PROP_SETGET_FUNCTION(getZIndex)},
+
+ // Tab properties
+ {N_PROP_ACTIVE, PROP_SETGET_FUNCTION(setActive), PROP_SETGET_FUNCTION(isActive)},
+
+ // TabGroup properties
+ {N_PROP_ACTIVE_TAB, PROP_SETGET_FUNCTION(setActiveTab), PROP_SETGET_FUNCTION(getActiveTab)}
};
static SetGetProperties g_props(g_propSetGet, GET_ARRAY_SIZE(g_propSetGet));
View
8 src/tibb/NativeControlObject.h
@@ -153,6 +153,14 @@ class NativeControlObject : public NativeProxyObject
static int getDateTime(TiObject* obj, QDateTime& dt);
virtual void updateLayout(QRectF rect);
+ // Tab properties
+ virtual int setActive(TiObject* obj);
+ virtual int isActive(TiObject* obj);
+
+ // TabGroup properties
+ virtual int setActiveTab(TiObject* obj);
+ virtual int getActiveTab(TiObject* obj);
+
bb::cascades::Container* container_;
protected:
View
2  src/tibb/NativeObject.h
@@ -54,6 +54,8 @@ enum NATIVE_TYPE
enum NATIVE_PROP
{
N_PROP_UNDEFINED
+ , N_PROP_ACTIVE
+ , N_PROP_ACTIVE_TAB
, N_PROP_ANCHOR_POINT
, N_PROP_ANIMATED_CENTER_POINT
, N_PROP_AUTO_LINK
View
51 src/tibb/NativeTabGroupObject.cpp
@@ -5,15 +5,23 @@
* Please see the LICENSE included with this distribution for details.
*/
-#include "NativeObjectFactory.h"
#include "NativeTabGroupObject.h"
+
+#include <bb/cascades/TabbedPane>
+
+#include <v8.h>
+
+#include "NativeObjectFactory.h"
+#include "NativeTabObject.h"
#include "SceneManager.h"
#include "TabbedScene.h"
#include "TiCascadesApp.h"
-#include <bb/cascades/TabbedPane>
+#include "TiObject.h"
+#include "TiUITabGroup.h"
using namespace bb::cascades;
using namespace titanium;
+using namespace v8;
NativeTabGroupObject::NativeTabGroupObject(TiObject* tiObject)
: NativeControlObject(tiObject, N_TYPE_TABGROUP)
@@ -71,13 +79,39 @@ int NativeTabGroupObject::addChildNativeObject(NativeObject* obj)
{
if (obj->getNativeHandle())
{
- tabGroup_->add((bb::cascades::Tab*) obj->getNativeHandle());
+ NativeTabObject* tab = static_cast<NativeTabObject*>(obj);
+ tabGroup_->add((bb::cascades::Tab*) tab->getNativeHandle());
+ tab->setTabbedPane(tabGroup_);
return NATIVE_ERROR_OK;
}
}
return NATIVE_ERROR_NOTSUPPORTED;
}
+int NativeTabGroupObject::setActiveTab(TiObject* obj)
+{
+ HandleScope scope;
+
+ Handle<Value> val = obj->getValue();
+ if (val->IsObject()) {
+ TiObject* obj = TiObject::getTiObjectFromJsObject(val);
+ if (!obj || !obj->isUIObject()) {
+ // Not the right type of object.
+ return NATIVE_ERROR_INVALID_ARG;
+ }
+ setActiveTab(obj->getNativeObject());
+ } else {
+ Local<Number> index = val->ToInteger();
+ if (index.IsEmpty()) {
+ // Not a valid number.
+ return NATIVE_ERROR_INVALID_ARG;
+ }
+ setActiveTab(index->Value());
+ }
+
+ return NATIVE_ERROR_OK;
+}
+
int NativeTabGroupObject::setActiveTab(NativeObject* tab)
{
if (tab && tab->getObjectType() == N_TYPE_TAB)
@@ -101,6 +135,17 @@ int NativeTabGroupObject::setActiveTab(int index)
return NATIVE_ERROR_NOTSUPPORTED;
}
+int NativeTabGroupObject::getActiveTab(TiObject* obj)
+{
+ Tab* activeTab = tabGroup_->activeTab();
+ if (activeTab) {
+ TiUITabGroup* tabGroup = static_cast<TiUITabGroup*>(tiObject_);
+ TiObject* tabObj = tabGroup->getChildAt(tabGroup_->indexOf(activeTab));
+ obj->setValue(tabObj->getValue());
+ }
+ return NATIVE_ERROR_OK;
+}
+
int NativeTabGroupObject::open()
{
//Q_ASSERT(nativeObjectFactory_ != NULL);
View
2  src/tibb/NativeTabGroupObject.h
@@ -37,8 +37,10 @@ class NativeTabGroupObject : public NativeControlObject
virtual NATIVE_TYPE getObjectType() const;
virtual NAHANDLE getNativeHandle() const;
virtual int addChildNativeObject(NativeObject* obj);
+ virtual int setActiveTab(TiObject* obj);
virtual int setActiveTab(NativeObject* tab);
virtual int setActiveTab(int index);
+ virtual int getActiveTab(TiObject* obj);
virtual int open();
protected:
View
59 src/tibb/NativeTabObject.cpp
@@ -15,6 +15,7 @@
#include <bb/cascades/Tab>
#include "Scene.h"
+#include "TiObject.h"
#include "Window.h"
using namespace bb::cascades;
@@ -51,17 +52,26 @@ NAHANDLE NativeTabObject::getNativeHandle() const
return tab_;
}
-int NativeTabObject::setTitle(TiObject* obj)
+int NativeTabObject::addChildNativeObject(NativeObject* obj)
{
- QString str;
-
- int error = NativeControlObject::getString(obj, str);
- if (!N_SUCCEEDED(error))
+ if (obj->getObjectType() == N_TYPE_WINDOW)
{
- return error;
+ Window* window = static_cast<Window*>(obj->getNativeHandle());
+ Page* page = static_cast<Page*>(window->scene()->pane());
+
+ // The ownership of the page must be cleared before pushing,
+ // otherwise navigation pane will do nothing.
+ page->setParent(0);
+
+ navigationPane_->push(page);
+ return NATIVE_ERROR_OK;
}
- tab_->setTitle(str);
- return NATIVE_ERROR_OK;
+ return NATIVE_ERROR_NOTSUPPORTED;
+}
+
+int NativeTabObject::openWindowOnTab(NativeObject* obj)
+{
+ return addChildNativeObject(obj);
}
int NativeTabObject::setIcon(TiObject* obj)
@@ -77,26 +87,32 @@ int NativeTabObject::setIcon(TiObject* obj)
return NATIVE_ERROR_OK;
}
-int NativeTabObject::addChildNativeObject(NativeObject* obj)
+int NativeTabObject::setTitle(TiObject* obj)
{
- if (obj->getObjectType() == N_TYPE_WINDOW)
- {
- Window* window = static_cast<Window*>(obj->getNativeHandle());
- Page* page = static_cast<Page*>(window->scene()->pane());
+ QString str;
- // The ownership of the page must be cleared before pushing,
- // otherwise navigation pane will do nothing.
- page->setParent(0);
+ int error = NativeControlObject::getString(obj, str);
+ if (!N_SUCCEEDED(error))
+ {
+ return error;
+ }
+ tab_->setTitle(str);
+ return NATIVE_ERROR_OK;
+}
- navigationPane_->push(page);
- return NATIVE_ERROR_OK;
+int NativeTabObject::setActive(TiObject* obj)
+{
+ if (!tabPane_.isNull() && obj->getValue()->IsTrue()) {
+ tabPane_->setActiveTab(tab_);
}
- return NATIVE_ERROR_NOTSUPPORTED;
+ return NATIVE_ERROR_OK;
}
-int NativeTabObject::openWindowOnTab(NativeObject* obj)
+int NativeTabObject::isActive(TiObject* obj)
{
- return addChildNativeObject(obj);
+ bool active = !tabPane_.isNull() && tabPane_->activeTab() == tab_;
+ obj->setValue(Boolean::New(active));
+ return NATIVE_ERROR_OK;
}
int NativeTabObject::initialize()
@@ -113,3 +129,4 @@ int NativeTabObject::initialize()
}
return NATIVE_ERROR_OK;
}
+
View
23 src/tibb/NativeTabObject.h
@@ -10,6 +10,10 @@
#include "NativeControlObject.h"
+#include <QPointer>
+
+#include <bb/cascades/TabbedPane>
+
class NativeObjectFactory;
namespace bb
{
@@ -33,24 +37,37 @@ class NativeTabObject : public NativeControlObject
public:
static NativeObject* createTab(TiObject* tiObject);
virtual ~NativeTabObject();
+
virtual NATIVE_TYPE getObjectType() const;
- virtual int setTitle(TiObject* obj);
- virtual int setIcon(TiObject* obj);
+ virtual NAHANDLE getNativeHandle() const;
+
virtual int addChildNativeObject(NativeObject* obj);
virtual int openWindowOnTab(NativeObject* obj);
- virtual NAHANDLE getNativeHandle() const;
+
+ virtual int setActive(TiObject* obj);
+ virtual int setIcon(TiObject* obj);
+ virtual int setTitle(TiObject* obj);
+
+ virtual int isActive(TiObject* obj);
protected:
virtual int initialize();
+ void setTabbedPane(bb::cascades::TabbedPane* pane) {
+ tabPane_ = pane;
+ }
+
private:
bb::cascades::NavigationPane* navigationPane_;
bb::cascades::Tab* tab_;
+ QPointer<bb::cascades::TabbedPane> tabPane_;
explicit NativeTabObject(TiObject* tiObject);
// Disable copy ctor & assignment operator
NativeTabObject(const NativeTabObject& obj);
NativeTabObject& operator=(const NativeTabObject& obj);
+
+friend class NativeTabGroupObject;
};
View
1  src/tibb/TiObject.cpp
@@ -453,7 +453,6 @@ Handle<Value> TiObject::setPropHelper(const char* propString, Local<Value> value
destObj = srcObj;
}
(destObj->*cb)(value);
- setTiObjectToJsObject(value, destObj);
addMember(destObj, propString);
onSetProperty(propString, value);
srcObj->release();
View
10 src/tibb/TiUIBase.cpp
@@ -22,6 +22,16 @@
const static TiProperty g_tiProperties[] =
{
{
+ "active", TI_PROP_PERMISSION_READ | TI_PROP_PERMISSION_WRITE,
+ N_PROP_ACTIVE
+ },
+
+ {
+ "activeTab", TI_PROP_PERMISSION_READ | TI_PROP_PERMISSION_WRITE,
+ N_PROP_ACTIVE_TAB
+ },
+
+ {
"anchorPoint", TI_PROP_PERMISSION_READ | TI_PROP_PERMISSION_WRITE | TI_PROP_FLAG_READ_NO_BRIDGE,
N_PROP_ANCHOR_POINT
},
View
4 src/tibb/TiUIBase.h
@@ -29,6 +29,10 @@ class TiUIBase : public TiProxy
virtual bool isUIObject() const;
virtual void setTiMappingProperties(const TiProperty* props, int propertyCount);
+ TiObject* getChildAt(int index) const {
+ return childControls_[index].getObject();
+ }
+
protected:
TiUIBase(const char* name);
TiUIBase();
View
34 src/tibb/TiUITabGroup.cpp
@@ -32,7 +32,6 @@ void TiUITabGroup::onCreateStaticMembers()
TiUIBase::onCreateStaticMembers();
TiGenericFunctionObject::addGenericFunctionToParent(this, "open", this, _open);
TiGenericFunctionObject::addGenericFunctionToParent(this, "addTab", this, _addTab);
- TiGenericFunctionObject::addGenericFunctionToParent(this, "setActiveTab", this, _setActiveTab);
}
void TiUITabGroup::initializeTiObject(TiObject* parentContext)
@@ -62,36 +61,3 @@ Handle<Value> TiUITabGroup::_addTab(void* userContext, TiObject* caller, const A
return Undefined();
}
-Handle<Value> TiUITabGroup::_setActiveTab(void* userContext, TiObject*, const Arguments& args)
-{
- HandleScope handleScope;
- TiUITabGroup* obj = (TiUITabGroup*) userContext;
- NativeObject* no = obj->getNativeObject();
- if ((args.Length() > 0) && args[0]->IsNumber())
- {
- Local<Integer> index = args[0]->ToInteger();
- no->setActiveTab(index->Value());
- }
- else
- {
- HandleScope handleScope;
- if ((args.Length() > 0) && (args[0]->IsObject()))
- {
- TiObject* addObj = getTiObjectFromJsObject(args[0]);
- if ((addObj == NULL) || (!addObj->isUIObject()))
- {
- return Undefined();
- }
- TiUIBase* uiObj = (TiUIBase*) addObj;
- NativeObject* childNO = uiObj->getNativeObject();
- no->setActiveTab(childNO);
- childNO->release();
- }
- else
- {
- ThrowException(String::New(Native::Msg::Expected_argument_of_type_object_or_external));
- }
- }
- no->release();
- return Undefined();
-}
View
1  src/tibb/TiUITabGroup.h
@@ -32,7 +32,6 @@ class TiUITabGroup : public TiUIBase
private:
static Handle<Value> _open(void* userContext, TiObject* caller, const Arguments& args);
static Handle<Value> _addTab(void* userContext, TiObject* caller, const Arguments& args);
- static Handle<Value> _setActiveTab(void* userContext, TiObject* caller, const Arguments& args);
TiUITabGroup();
//This class is neither copy-constructible nor assignable

No commit comments for this range

Something went wrong with that request. Please try again.