void MainWindow::on_languageChooser_currentIndexChanged(const QString &text) { Qt::LayoutDirection dir = getLayoutDirection(text); ui->listView->setLayoutDirection(dir); ui->searchField->setLayoutDirection(dir); refreshSearchResults(); }
void FrameLayout::onLayout(bool changed, int left, int top, int right, int bottom) { CCLOG("onLayout(%s) %d, %d, %d, %d", m_id.c_str(), left, top, right, bottom); const int count = getChildCount(); const int parentLeft = getPaddingLeftWithForeground(); const int parentRight = right - left - getPaddingRightWithForeground(); const int parentTop = getPaddingTopWithForeground(); const int parentBottom = bottom - top - getPaddingBottomWithForeground(); m_foregroundBoundsChanged = true; for (int i = 0; i < count; i++) { shared_ptr<View> child = getChildAt(i); if (child->getVisibility() != View::GONE) { FrameLayoutParams *lp = static_cast<FrameLayoutParams*>(child->getLayoutParams()); const int width = child->getMeasuredWidth(); const int height = child->getMeasuredHeight(); int childLeft; int childTop; int gravity = lp->gravity; if (gravity == -1) { gravity = DEFAULT_CHILD_GRAVITY; } const int layoutDirection = getLayoutDirection(); const int absoluteGravity = Gravity::getAbsoluteGravity(gravity, layoutDirection); const int verticalGravity = gravity & Gravity::VERTICAL_GRAVITY_MASK; switch (absoluteGravity & Gravity::HORIZONTAL_GRAVITY_MASK) { case Gravity::LEFT: childLeft = parentLeft + lp->leftMargin; break; case Gravity::CENTER_HORIZONTAL: childLeft = parentLeft + (parentRight - parentLeft - width) / 2 + lp->leftMargin - lp->rightMargin; break; case Gravity::RIGHT: childLeft = parentRight - width - lp->rightMargin; break; default: childLeft = parentLeft + lp->leftMargin; } switch (verticalGravity) { case Gravity::TOP: childTop = parentTop + lp->topMargin; break; case Gravity::CENTER_VERTICAL: childTop = parentTop + (parentBottom - parentTop - height) / 2 + lp->topMargin - lp->bottomMargin; break; case Gravity::BOTTOM: childTop = parentBottom - height - lp->bottomMargin; break; default: childTop = parentTop + lp->topMargin; } child->layout(childLeft, childTop, childLeft + width, childTop + height); } } }