Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Add layer priority sorting. Make pointer not affect widget sorting. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored Jun 23, 2020
1 parent df4c777 commit b6d6e9d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {
aPlacement.worldWidth = WidgetPlacement.floatDimension(context, R.dimen.keyboard_world_width);
aPlacement.visible = false;
aPlacement.cylinder = true;
aPlacement.layerPriority = 1;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public WidgetPlacement(Context aContext) {
public boolean showPointer = true;
public boolean composited = false;
public boolean layer = true;
public int layerPriority = 0; // Used for depth sorting
public boolean proxifyLayer = false;
public float textureScale = 0.7f;
// Widget will be curved if enabled.
Expand Down Expand Up @@ -99,6 +100,7 @@ public void copyFrom(WidgetPlacement w) {
this.showPointer = w.showPointer;
this.composited = w.composited;
this.layer = w.layer;
this.layerPriority = w.layerPriority;
this.proxifyLayer = w.proxifyLayer;
this.textureScale = w.textureScale;
this.cylinder = w.cylinder;
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/cpp/BrowserWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,13 +686,18 @@ BrowserWorld::State::SortWidgets() {
}
}
if (!target) {
bool isPointer = false;
for (Controller& controller: controllers->GetControllers()) {
if (controller.pointer && controller.pointer->GetRoot() == node) {
target = controller.pointer->GetHitWidget().get();
zDelta = 0.02f;
isPointer = true;
break;
}
}
if (isPointer) {
// Always render the pointer on top
depthSorting.emplace(node.get(), std::make_pair(target, 0.0f));
continue;
}
}

if (!target && widgetResizer && widgetResizer->GetRoot() == node) {
Expand All @@ -717,12 +722,14 @@ BrowserWorld::State::SortWidgets() {
Widget* wa = da->second.first;
Widget* wb = db->second.first;

// Parenting sort
// Parenting or layer priority sort
if (wa && wb && wa->IsVisible() && wb->IsVisible()) {
if (IsParent(*wa, *wb)) {
return true;
} else if (IsParent(*wb, *wa)) {
return false;
} else if (wa->GetPlacement()->layerPriority != wb->GetPlacement()->layerPriority) {
return wa->GetPlacement()->layerPriority > wb->GetPlacement()->layerPriority;
}
}

Expand Down
1 change: 1 addition & 0 deletions app/src/main/cpp/WidgetPlacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ WidgetPlacement::FromJava(JNIEnv* aEnv, jobject& aObject) {
GET_BOOLEAN_FIELD(showPointer);
GET_BOOLEAN_FIELD(composited);
GET_BOOLEAN_FIELD(layer);
GET_INT_FIELD(layerPriority);
GET_BOOLEAN_FIELD(proxifyLayer);
GET_FLOAT_FIELD(textureScale, "textureScale");
GET_BOOLEAN_FIELD(cylinder);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/cpp/WidgetPlacement.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct WidgetPlacement {
bool showPointer;
bool composited;
bool layer;
int32_t layerPriority;
bool proxifyLayer;
float textureScale;
bool cylinder;
Expand Down

0 comments on commit b6d6e9d

Please sign in to comment.