summaryrefslogtreecommitdiffstats
path: root/src/android/jar/src
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@digia.com>2014-09-08 17:22:42 +0200
committerChristian Stromme <christian.stromme@digia.com>2014-09-26 23:45:13 +0200
commit10a0f93c86e8be018119a07123b88d3e4a5e584c (patch)
tree32b478785da92f72bbb797c16678258245037076 /src/android/jar/src
parentafece6e49697983e7fd55647e1674504f7bc7235 (diff)
Android: Add function to change the stacking order in the layout.
This change enables us to reorder the stacking order used by the layout. This is necessary if we want to influence the drawing order. Lowering or raising views are done separately for native views and Qt surface views, that is, the two different view "types" are moved relative to other views of the same type and Native views are always placed on top. Change-Id: I01cbb88f8efee08877b5972cf330fd25266a2aa9 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Diffstat (limited to 'src/android/jar/src')
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java29
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtLayout.java13
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtNative.java20
3 files changed, 60 insertions, 2 deletions
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
index 9507d7eb3b..cddb06eff1 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -1102,4 +1102,33 @@ public class QtActivityDelegate
m_layout.removeView(view);
}
}
+
+ public void bringChildToFront(int id)
+ {
+ View view = m_surfaces.get(id);
+ if (view != null) {
+ final int index = m_layout.getChildCount() - m_nativeViews.size() - 1;
+ m_layout.moveChild(view, index < 0 ? 0 : index);
+ return;
+ }
+
+ view = m_nativeViews.get(id);
+ if (view != null)
+ m_layout.moveChild(view, -1);
+ }
+
+ public void bringChildToBack(int id)
+ {
+ View view = m_surfaces.get(id);
+ if (view != null) {
+ m_layout.moveChild(view, 0);
+ return;
+ }
+
+ view = m_nativeViews.get(id);
+ if (view != null) {
+ final int index = m_layout.getChildCount() - m_nativeViews.size();
+ m_layout.moveChild(view, index);
+ }
+ }
}
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java b/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java
index 058b10750f..4033866e6c 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtLayout.java
@@ -205,8 +205,17 @@ public class QtLayout extends ViewGroup
}
}
- public void bringChildFront(int child)
+ public void moveChild(View view, int index)
{
- bringChildToFront(getChildAt(child));
+ if (view == null)
+ return;
+
+ if (indexOfChild(view) == -1)
+ return;
+
+ detachViewFromParent(view);
+ requestLayout();
+ invalidate();
+ attachViewToParent(view, index, view.getLayoutParams());
}
}
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
index 8b0febe641..aba4cfa502 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java
@@ -537,6 +537,26 @@ public class QtNative
});
}
+ private static void bringChildToFront(final int id)
+ {
+ runAction(new Runnable() {
+ @Override
+ public void run() {
+ m_activityDelegate.bringChildToFront(id);
+ }
+ });
+ }
+
+ private static void bringChildToBack(final int id)
+ {
+ runAction(new Runnable() {
+ @Override
+ public void run() {
+ m_activityDelegate.bringChildToBack(id);
+ }
+ });
+ }
+
private static void destroySurface(final int id)
{
runAction(new Runnable() {