Skip to content

Commit

Permalink
Merge pull request #104 from pec1985/timob-14190-3_1_X
Browse files Browse the repository at this point in the history
backport [TIMOB-14190] Window orientation
  • Loading branch information
Russ McMahon committed Jun 13, 2013
2 parents ea51882 + b6519d7 commit ad6e972
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/tibb/NativeControlObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <bb/cascades/Container>
#include <bb/cascades/ImagePaint>
#include <bb/cascades/LayoutUpdateHandler>
#include <bb/device/DeviceInfo>
#include <bb/device/DisplayInfo>

#include "EventHandler.h"
Expand All @@ -32,6 +33,7 @@
#include "TiUIAnimation.h"
#include "NativeAnimationObject.h"
#include "TiUtils.h"
#include "TiOrientation.h"

using namespace bb::cascades;
using namespace titanium;
Expand Down Expand Up @@ -221,8 +223,17 @@ NativeControlObject::NativeControlObject(TiObject* tiObject, NATIVE_TYPE objType
ppi_ = tiUtils->getPPI();

bb::device::DisplayInfo display;
displayWidth_ = display.pixelSize().width();
displayHeight_ = display.pixelSize().height();
bb::device::DeviceInfo info;
int orientation = Orientation::fromDevice(info.orientation());
if (orientation != Orientation::PORTRAIT) {
displayWidth_ = display.pixelSize().height();
displayHeight_ = display.pixelSize().width();
}
else {
displayWidth_ = display.pixelSize().width();
displayHeight_ = display.pixelSize().height();

}
}

NativeControlObject::~NativeControlObject()
Expand Down Expand Up @@ -277,11 +288,22 @@ void NativeControlObject::updateLayout(QRectF rect)
}
}


if (requestLayout) {
struct Node* root = nodeRequestLayout(&layoutNode_);
if (root) {
root->element._measuredWidth = displayWidth_;
root->element._measuredHeight = displayHeight_;
bb::device::DisplayInfo display;
bb::device::DeviceInfo info;
int orientation = Orientation::fromDevice(info.orientation());
if (orientation != Orientation::PORTRAIT) {
displayWidth_ = display.pixelSize().height();
displayHeight_ = display.pixelSize().width();
}
else {
displayWidth_ = display.pixelSize().width();
displayHeight_ = display.pixelSize().height();

}
nodeLayout(root);
}
}
Expand Down Expand Up @@ -487,8 +509,8 @@ void NativeControlObject::resize(float width, float height)
Control* control = static_cast<Control*>(getNativeHandle());

if (objType_ == N_TYPE_WINDOW) {
return;
}
return;
}

if (!deferWidth_) {
control->setMinWidth(width);
Expand Down

0 comments on commit ad6e972

Please sign in to comment.