Skip to content
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-13877] ScrollView scrolling again #152

Merged
merged 2 commits into from
Aug 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 17 additions & 11 deletions src/tibb/NativeScrollViewObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,12 @@ NativeScrollViewContentObject::NativeScrollViewContentObject(TiObject* tiObject,
setContainer(bb::cascades::Container::create());
scrollView_ = scrollView;

TiObject height;
height.setValue(String::New("UI.SIZE"));
setHeight(&height);

TiObject width;
width.setValue(String::New("UI.SIZE"));
setWidth(&height);
}

void NativeScrollViewContentObject::updateLayout(QRectF rect)
{
NativeControlObject::updateLayout(rect);
scrollView_->setContentWidthAndHeight(rect.width(), rect.height());
scrollView_->setContentWidthAndHeight(rect.width(), rect.height(), true);
}

NativeScrollViewObject::NativeScrollViewObject(TiObject* tiObject)
Expand Down Expand Up @@ -75,7 +68,7 @@ int NativeScrollViewObject::setLayout(TiObject *obj)
width.setValue(String::New("UI.FILL"));
err = contentViewProxy_->setWidth(&width);
}

else
if (str == "horizontal" && !contentWidthSet_)
{
TiObject height;
Expand All @@ -90,11 +83,11 @@ int NativeScrollViewObject::setLayout(TiObject *obj)

return err;
}
void NativeScrollViewObject::setContentWidthAndHeight(float width, float height)
void NativeScrollViewObject::setContentWidthAndHeight(float width, float height, bool applyScrolling)
{
contentSize_.setHeight(height);
contentSize_.setWidth(width);

if(!applyScrolling) return;
if(contentSize_.width() > scrollViewSize_.width() && contentSize_.height() <= scrollViewSize_.height())
{
scrollViewProperties_->setScrollMode(bb::cascades::ScrollMode::Horizontal);
Expand Down Expand Up @@ -136,8 +129,19 @@ int NativeScrollViewObject::initialize()

bb::cascades::LayoutUpdateHandler::create(nativeContentView_).onLayoutFrameChanged(eventHandler_, SLOT(onContainerLayoutChange(QRectF)));


TiObject height;
height.setValue(String::New("UI.SIZE"));
contentViewProxy_->setHeight(&height);

TiObject width;
width.setValue(String::New("UI.SIZE"));
contentViewProxy_->setWidth(&width);


contentSize_ = QSize(0,0);
scrollViewSize_ = QSize(0,0);

return NATIVE_ERROR_OK;
}
/*
Expand Down Expand Up @@ -192,6 +196,8 @@ void NativeScrollViewObject::updateLayout(QRectF rect)
scrollView_->setPreferredWidth(w);
scrollViewSize_.setHeight(h);
scrollViewSize_.setWidth(w);

setContentWidthAndHeight(contentSize_.width(), contentSize_.height(), true);
}

int NativeScrollViewObject::setBackgroundColor(TiObject* obj)
Expand Down
2 changes: 1 addition & 1 deletion src/tibb/NativeScrollViewObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class NativeScrollViewObject : public NativeControlObject
virtual int setLayout(TiObject *obj);
virtual int setHeight(TiObject *obj);
virtual int setWidth(TiObject *obj);
void setContentWidthAndHeight(float w, float h);
void setContentWidthAndHeight(float w, float h, bool a);
bb::cascades::ScrollViewProperties* scrollViewProperties_;
bb::cascades::ScrollView* scrollView_;
bb::cascades::Container* contentView_;
Expand Down
22 changes: 15 additions & 7 deletions src/tibb/TiNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ void TiNetwork::addObjectToParent(TiObject* parent, NativeObjectFactory* objectF
obj->release();
}

static Handle<Value> _getNetworkType(void*)
Handle<Value> TiNetwork::_getNetworkType(void*)
{
QNetworkConfigurationManager *qncm = new QNetworkConfigurationManager();
QList<QNetworkConfiguration> activeConfigs = qncm->allConfigurations(QNetworkConfiguration::Active);
QNetworkConfigurationManager qncm;
QList<QNetworkConfiguration> activeConfigs = qncm.allConfigurations(QNetworkConfiguration::Active);
foreach (QNetworkConfiguration qnc, activeConfigs){
int type = 0;
switch(qnc.bearerType())
Expand All @@ -55,18 +55,18 @@ static Handle<Value> _getNetworkType(void*)
case QNetworkConfiguration::BearerWCDMA : type = 5; break;
case QNetworkConfiguration::BearerHSPA : type = 6; break;
case QNetworkConfiguration::BearerBluetooth : type = 7; break;

default: type = 8; break;
}
return Number::New(type);
}
return Null();

}

static Handle<Value> _getNetworkTypeName(void*)
Handle<Value> TiNetwork::_getNetworkTypeName(void*)
{
QNetworkConfigurationManager *qncm = new QNetworkConfigurationManager();
QList<QNetworkConfiguration> activeConfigs = qncm->allConfigurations(QNetworkConfiguration::Active);
QNetworkConfigurationManager qncm;
QList<QNetworkConfiguration> activeConfigs = qncm.allConfigurations(QNetworkConfiguration::Active);
foreach (QNetworkConfiguration qnc, activeConfigs){
QString typeName = qnc.bearerTypeName();
return String::New(typeName.toLocal8Bit().constData());
Expand All @@ -75,6 +75,13 @@ static Handle<Value> _getNetworkTypeName(void*)

}

Handle<Value> TiNetwork::_getOnline(void*)
{
QNetworkConfigurationManager m;
return Boolean::New(m.isOnline());

}

void TiNetwork::onCreateStaticMembers()
{
TiProxy::onCreateStaticMembers();
Expand All @@ -86,6 +93,7 @@ void TiNetwork::onCreateStaticMembers()

TiPropertySetGetObject::createProperty(this, "networkTypeName", this, NULL, _getNetworkTypeName);
TiPropertySetGetObject::createProperty(this, "networkType", this, NULL, _getNetworkType);
TiPropertySetGetObject::createProperty(this, "online", this, NULL, _getOnline);
}

Handle<Value> TiNetwork::_encodeURIComponent(void* userContext, TiObject* /*caller*/, const Arguments& args)
Expand Down
4 changes: 3 additions & 1 deletion src/tibb/TiNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class TiNetwork : public TiProxy
explicit TiNetwork(NativeObjectFactory* objectFactory);
TiNetwork(const TiNetwork&);
TiNetwork& operator=(const TiNetwork&);

static Handle<Value> _getNetworkTypeName(void*);
static Handle<Value> _getNetworkType(void*);
static Handle<Value> _getOnline(void*);
NativeObjectFactory* objectFactory_;
};

Expand Down