mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Draw glow along screen edge when dragging in portrait.
This commit is contained in:
BIN
res/drawable/page_hover_left.9.png
Normal file
BIN
res/drawable/page_hover_left.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 413 B |
BIN
res/drawable/page_hover_right.9.png
Normal file
BIN
res/drawable/page_hover_right.9.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 415 B |
@@ -15,6 +15,10 @@
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- the area at the edge of the screen that makes the workspace go left
|
||||
or right while you're dragging. -->
|
||||
<dimen name="scroll_zone">40dp</dimen>
|
||||
|
||||
<!-- Width/height gap overrides for the workspace -->
|
||||
<dimen name="workspace_width_gap">0dp</dimen>
|
||||
<dimen name="workspace_height_gap">32dp</dimen>
|
||||
|
||||
@@ -327,6 +327,10 @@ public class CellLayout extends ViewGroup implements Dimmable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getHover() {
|
||||
return mHover;
|
||||
}
|
||||
|
||||
public void drawChildren(Canvas canvas) {
|
||||
super.dispatchDraw(canvas);
|
||||
}
|
||||
|
||||
@@ -605,6 +605,30 @@ public class Workspace extends SmoothPagedView
|
||||
} else {
|
||||
super.dispatchDraw(canvas);
|
||||
|
||||
final int width = getWidth();
|
||||
final int height = getHeight();
|
||||
|
||||
// In portrait orientation, draw the glowing edge when dragging to adjacent screens
|
||||
if (mInScrollArea && (height > width)) {
|
||||
final int pageHeight = getChildAt(0).getHeight();
|
||||
|
||||
// This determines the height of the glowing edge: 90% of the page height
|
||||
final int padding = (int) ((height - pageHeight) * 0.5f + pageHeight * 0.1f);
|
||||
|
||||
final CellLayout leftPage = (CellLayout) getChildAt(mCurrentPage - 1);
|
||||
final CellLayout rightPage = (CellLayout) getChildAt(mCurrentPage + 1);
|
||||
|
||||
if (leftPage != null && leftPage.getHover()) {
|
||||
final Drawable d = getResources().getDrawable(R.drawable.page_hover_left);
|
||||
d.setBounds(mScrollX, padding, mScrollX + d.getIntrinsicWidth(), height - padding);
|
||||
d.draw(canvas);
|
||||
} else if (rightPage != null && rightPage.getHover()) {
|
||||
final Drawable d = getResources().getDrawable(R.drawable.page_hover_right);
|
||||
d.setBounds(mScrollX + width - d.getIntrinsicWidth(), padding, mScrollX + width, height - padding);
|
||||
d.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
if (mDropView != null) {
|
||||
// We are animating an item that was just dropped on the home screen.
|
||||
// Render its View in the current animation position.
|
||||
@@ -1909,11 +1933,11 @@ public class Workspace extends SmoothPagedView
|
||||
final int screen = getCurrentPage() + ((direction == DragController.SCROLL_LEFT) ? -1 : 1);
|
||||
if (0 <= screen && screen < getChildCount()) {
|
||||
((CellLayout) getChildAt(screen)).setHover(true);
|
||||
}
|
||||
|
||||
if (mDragTargetLayout != null) {
|
||||
mDragTargetLayout.onDragExit();
|
||||
mDragTargetLayout = null;
|
||||
if (mDragTargetLayout != null) {
|
||||
mDragTargetLayout.onDragExit();
|
||||
mDragTargetLayout = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user