FreeRDP
Loading...
Searching...
No Matches
com.freerdp.freerdpcore.presentation.ScrollView2D Class Reference
Inheritance diagram for com.freerdp.freerdpcore.presentation.ScrollView2D:
Collaboration diagram for com.freerdp.freerdpcore.presentation.ScrollView2D:

Data Structures

interface  ScrollView2DListener
 

Public Member Functions

 ScrollView2D (Context context)
 
 ScrollView2D (Context context, AttributeSet attrs)
 
 ScrollView2D (Context context, AttributeSet attrs, int defStyle)
 
void setScrollEnabled (boolean enable)
 
int getMaxScrollAmountVertical ()
 
int getMaxScrollAmountHorizontal ()
 
void addView (View child)
 
void addView (View child, int index)
 
void addView (View child, ViewGroup.LayoutParams params)
 
void addView (View child, int index, ViewGroup.LayoutParams params)
 
boolean onInterceptTouchEvent (MotionEvent ev)
 
boolean onTouchEvent (MotionEvent ev)
 
boolean fullScroll (int direction, boolean horizontal)
 
boolean arrowScroll (int direction, boolean horizontal)
 
final void smoothScrollBy (int dx, int dy)
 
final void smoothScrollTo (int x, int y)
 
void computeScroll ()
 
void requestChildFocus (View child, View focused)
 
boolean requestChildRectangleOnScreen (View child, Rect rectangle, boolean immediate)
 
void requestLayout ()
 
void fling (int velocityX, int velocityY)
 
void scrollTo (int x, int y)
 
void setScrollViewListener (ScrollView2DListener scrollViewListener)
 

Protected Member Functions

float getTopFadingEdgeStrength ()
 
float getBottomFadingEdgeStrength ()
 
float getLeftFadingEdgeStrength ()
 
float getRightFadingEdgeStrength ()
 
int computeVerticalScrollRange ()
 
int computeHorizontalScrollRange ()
 
void measureChild (View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec)
 
void measureChildWithMargins (View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed)
 
int computeScrollDeltaToGetChildRectOnScreen (Rect rect)
 
boolean onRequestFocusInDescendants (int direction, Rect previouslyFocusedRect)
 
void onLayout (boolean changed, int l, int t, int r, int b)
 
void onSizeChanged (int w, int h, int oldw, int oldh)
 
void onScrollChanged (int x, int y, int oldx, int oldy)
 

Detailed Description

Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. A TwoDScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a LinearLayout in a vertical orientation, presenting a vertical array of top-level items that the user can scroll through.

The TextView class also takes care of its own scrolling, so does not require a TwoDScrollView, but using the two together is possible to achieve the effect of a text view within a larger container.

Definition at line 56 of file ScrollView2D.java.

Constructor & Destructor Documentation

◆ ScrollView2D() [1/3]

com.freerdp.freerdpcore.presentation.ScrollView2D.ScrollView2D ( Context  context)
inline

Definition at line 104 of file ScrollView2D.java.

105 {
106 super(context);
107 initTwoDScrollView();
108 }

◆ ScrollView2D() [2/3]

com.freerdp.freerdpcore.presentation.ScrollView2D.ScrollView2D ( Context  context,
AttributeSet  attrs 
)
inline

Definition at line 110 of file ScrollView2D.java.

111 {
112 super(context, attrs);
113 initTwoDScrollView();
114 }

◆ ScrollView2D() [3/3]

com.freerdp.freerdpcore.presentation.ScrollView2D.ScrollView2D ( Context  context,
AttributeSet  attrs,
int  defStyle 
)
inline

Definition at line 116 of file ScrollView2D.java.

117 {
118 super(context, attrs, defStyle);
119 initTwoDScrollView();
120 }

Member Function Documentation

◆ addView() [1/4]

void com.freerdp.freerdpcore.presentation.ScrollView2D.addView ( View  child)
inline

Definition at line 216 of file ScrollView2D.java.

217 {
218 if (getChildCount() > 0)
219 {
220 throw new IllegalStateException("TwoDScrollView can host only one direct child");
221 }
222 super.addView(child);
223 }

◆ addView() [2/4]

void com.freerdp.freerdpcore.presentation.ScrollView2D.addView ( View  child,
int  index 
)
inline

Definition at line 225 of file ScrollView2D.java.

226 {
227 if (getChildCount() > 0)
228 {
229 throw new IllegalStateException("TwoDScrollView can host only one direct child");
230 }
231 super.addView(child, index);
232 }

◆ addView() [3/4]

void com.freerdp.freerdpcore.presentation.ScrollView2D.addView ( View  child,
int  index,
ViewGroup.LayoutParams  params 
)
inline

Definition at line 243 of file ScrollView2D.java.

244 {
245 if (getChildCount() > 0)
246 {
247 throw new IllegalStateException("TwoDScrollView can host only one direct child");
248 }
249 super.addView(child, index, params);
250 }

◆ addView() [4/4]

void com.freerdp.freerdpcore.presentation.ScrollView2D.addView ( View  child,
ViewGroup.LayoutParams  params 
)
inline

Definition at line 234 of file ScrollView2D.java.

235 {
236 if (getChildCount() > 0)
237 {
238 throw new IllegalStateException("TwoDScrollView can host only one direct child");
239 }
240 super.addView(child, params);
241 }

◆ arrowScroll()

boolean com.freerdp.freerdpcore.presentation.ScrollView2D.arrowScroll ( int  direction,
boolean  horizontal 
)
inline

Handle scrolling in response to an up or down arrow click.

Parameters
directionThe direction corresponding to the arrow key that was pressed
Returns
True if we consumed the event, false otherwise

Definition at line 698 of file ScrollView2D.java.

699 {
700 View currentFocused = findFocus();
701 if (currentFocused == this)
702 currentFocused = null;
703 View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused, direction);
704 final int maxJump =
705 horizontal ? getMaxScrollAmountHorizontal() : getMaxScrollAmountVertical();
706
707 if (!horizontal)
708 {
709 if (nextFocused != null)
710 {
711 nextFocused.getDrawingRect(mTempRect);
712 offsetDescendantRectToMyCoords(nextFocused, mTempRect);
713 int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
714 doScroll(0, scrollDelta);
715 nextFocused.requestFocus(direction);
716 }
717 else
718 {
719 // no new focus
720 int scrollDelta = maxJump;
721 if (direction == View.FOCUS_UP && getScrollY() < scrollDelta)
722 {
723 scrollDelta = getScrollY();
724 }
725 else if (direction == View.FOCUS_DOWN)
726 {
727 if (getChildCount() > 0)
728 {
729 int daBottom = getChildAt(0).getBottom();
730 int screenBottom = getScrollY() + getHeight();
731 if (daBottom - screenBottom < maxJump)
732 {
733 scrollDelta = daBottom - screenBottom;
734 }
735 }
736 }
737 if (scrollDelta == 0)
738 {
739 return false;
740 }
741 doScroll(0, direction == View.FOCUS_DOWN ? scrollDelta : -scrollDelta);
742 }
743 }
744 else
745 {
746 if (nextFocused != null)
747 {
748 nextFocused.getDrawingRect(mTempRect);
749 offsetDescendantRectToMyCoords(nextFocused, mTempRect);
750 int scrollDelta = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
751 doScroll(scrollDelta, 0);
752 nextFocused.requestFocus(direction);
753 }
754 else
755 {
756 // no new focus
757 int scrollDelta = maxJump;
758 if (direction == View.FOCUS_UP && getScrollY() < scrollDelta)
759 {
760 scrollDelta = getScrollY();
761 }
762 else if (direction == View.FOCUS_DOWN)
763 {
764 if (getChildCount() > 0)
765 {
766 int daBottom = getChildAt(0).getBottom();
767 int screenBottom = getScrollY() + getHeight();
768 if (daBottom - screenBottom < maxJump)
769 {
770 scrollDelta = daBottom - screenBottom;
771 }
772 }
773 }
774 if (scrollDelta == 0)
775 {
776 return false;
777 }
778 doScroll(direction == View.FOCUS_DOWN ? scrollDelta : -scrollDelta, 0);
779 }
780 }
781 return true;
782 }

References com.freerdp.freerdpcore.presentation.ScrollView2D.computeScrollDeltaToGetChildRectOnScreen(), and com.freerdp.freerdpcore.presentation.ScrollView2D.getMaxScrollAmountVertical().

Here is the call graph for this function:

◆ computeHorizontalScrollRange()

int com.freerdp.freerdpcore.presentation.ScrollView2D.computeHorizontalScrollRange ( )
inlineprotected

Definition at line 844 of file ScrollView2D.java.

845 {
846 int count = getChildCount();
847 return count == 0 ? getWidth() : (getChildAt(0)).getRight();
848 }

◆ computeScroll()

void com.freerdp.freerdpcore.presentation.ScrollView2D.computeScroll ( )
inline

Definition at line 877 of file ScrollView2D.java.

878 {
879 if (mScroller.computeScrollOffset())
880 {
881 // This is called at drawing time by ViewGroup. We don't want to
882 // re-show the scrollbars at this point, which scrollTo will do,
883 // so we replicate most of scrollTo here.
884 //
885 // It's a little odd to call onScrollChanged from inside the drawing.
886 //
887 // It is, except when you remember that computeScroll() is used to
888 // animate scrolling. So unless we want to defer the onScrollChanged()
889 // until the end of the animated scrolling, we don't really have a
890 // choice here.
891 //
892 // I agree. The alternative, which I think would be worse, is to post
893 // something and tell the subclasses later. This is bad because there
894 // will be a window where mScrollX/Y is different from what the app
895 // thinks it is.
896 //
897 int oldX = getScrollX();
898 int oldY = getScrollY();
899 int x = mScroller.getCurrX();
900 int y = mScroller.getCurrY();
901 if (getChildCount() > 0)
902 {
903 View child = getChildAt(0);
904 scrollTo(
905 clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth()),
906 clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(),
907 child.getHeight()));
908 }
909 else
910 {
911 scrollTo(x, y);
912 }
913 if (oldX != getScrollX() || oldY != getScrollY())
914 {
915 onScrollChanged(getScrollX(), getScrollY(), oldX, oldY);
916 }
917
918 // Keep on drawing until the animation has finished.
919 postInvalidate();
920 }
921 }

◆ computeScrollDeltaToGetChildRectOnScreen()

int com.freerdp.freerdpcore.presentation.ScrollView2D.computeScrollDeltaToGetChildRectOnScreen ( Rect  rect)
inlineprotected

Compute the amount to scroll in the Y direction in order to get a rectangle completely on the screen (or, if taller than the screen, at least the first screen size chunk of it).

Parameters
rectThe rect.
Returns
The scroll delta.

Definition at line 974 of file ScrollView2D.java.

975 {
976 if (getChildCount() == 0)
977 return 0;
978 int height = getHeight();
979 int screenTop = getScrollY();
980 int screenBottom = screenTop + height;
981 int fadingEdge = getVerticalFadingEdgeLength();
982 // leave room for top fading edge as long as rect isn't at very top
983 if (rect.top > 0)
984 {
985 screenTop += fadingEdge;
986 }
987
988 // leave room for bottom fading edge as long as rect isn't at very bottom
989 if (rect.bottom < getChildAt(0).getHeight())
990 {
991 screenBottom -= fadingEdge;
992 }
993 int scrollYDelta = 0;
994 if (rect.bottom > screenBottom && rect.top > screenTop)
995 {
996 // need to move down to get it in view: move down just enough so
997 // that the entire rectangle is in view (or at least the first
998 // screen size chunk).
999 if (rect.height() > height)
1000 {
1001 // just enough to get screen size chunk on
1002 scrollYDelta += (rect.top - screenTop);
1003 }
1004 else
1005 {
1006 // get entire rect at bottom of screen
1007 scrollYDelta += (rect.bottom - screenBottom);
1008 }
1009
1010 // make sure we aren't scrolling beyond the end of our content
1011 int bottom = getChildAt(0).getBottom();
1012 int distanceToBottom = bottom - screenBottom;
1013 scrollYDelta = Math.min(scrollYDelta, distanceToBottom);
1014 }
1015 else if (rect.top < screenTop && rect.bottom < screenBottom)
1016 {
1017 // need to move up to get it in view: move up just enough so that
1018 // entire rectangle is in view (or at least the first screen
1019 // size chunk of it).
1020
1021 if (rect.height() > height)
1022 {
1023 // screen size chunk
1024 scrollYDelta -= (screenBottom - rect.bottom);
1025 }
1026 else
1027 {
1028 // entire rect at top
1029 scrollYDelta -= (screenTop - rect.top);
1030 }
1031
1032 // make sure we aren't scrolling any further than the top our content
1033 scrollYDelta = Math.max(scrollYDelta, -getScrollY());
1034 }
1035 return scrollYDelta;
1036 }

Referenced by com.freerdp.freerdpcore.presentation.ScrollView2D.arrowScroll().

Here is the caller graph for this function:

◆ computeVerticalScrollRange()

int com.freerdp.freerdpcore.presentation.ScrollView2D.computeVerticalScrollRange ( )
inlineprotected

The scroll range of a scroll view is the overall height of all of its children.

Definition at line 838 of file ScrollView2D.java.

839 {
840 int count = getChildCount();
841 return count == 0 ? getHeight() : (getChildAt(0)).getBottom();
842 }

◆ fling()

void com.freerdp.freerdpcore.presentation.ScrollView2D.fling ( int  velocityX,
int  velocityY 
)
inline

Fling the scroll view

Parameters
velocityYThe initial velocity in the Y direction. Positive numbers mean that the finger/curor is moving down the screen, which means we want to scroll towards the top.

Definition at line 1178 of file ScrollView2D.java.

1179 {
1180 if (getChildCount() > 0)
1181 {
1182 int height = getHeight() - getPaddingBottom() - getPaddingTop();
1183 int bottom = getChildAt(0).getHeight();
1184 int width = getWidth() - getPaddingRight() - getPaddingLeft();
1185 int right = getChildAt(0).getWidth();
1186
1187 mScroller.fling(getScrollX(), getScrollY(), velocityX, velocityY, 0, right - width, 0,
1188 bottom - height);
1189
1190 final boolean movingDown = velocityY > 0;
1191 final boolean movingRight = velocityX > 0;
1192
1193 View newFocused = findFocusableViewInMyBounds(
1194 movingRight, mScroller.getFinalX(), movingDown, mScroller.getFinalY(), findFocus());
1195 if (newFocused == null)
1196 {
1197 newFocused = this;
1198 }
1199
1200 if (newFocused != findFocus() &&
1201 newFocused.requestFocus(movingDown ? View.FOCUS_DOWN : View.FOCUS_UP))
1202 {
1203 mTwoDScrollViewMovedFocus = true;
1204 mTwoDScrollViewMovedFocus = false;
1205 }
1206
1207 awakenScrollBars(mScroller.getDuration());
1208 invalidate();
1209 }
1210 }

◆ fullScroll()

boolean com.freerdp.freerdpcore.presentation.ScrollView2D.fullScroll ( int  direction,
boolean  horizontal 
)
inline

Handles scrolling in response to a "home/end" shortcut press. This method will scroll the view to the top or bottom and give the focus to the topmost/bottommost component in the new visible area. If no component is a good candidate for focus, this scrollview reclaims the focus.

Parameters
directionthe scroll direction: android.view.View#FOCUS_UP to go the top of the view or android.view.View#FOCUS_DOWN to go the bottom
Returns
true if the key event is consumed by this method, false otherwise

Definition at line 602 of file ScrollView2D.java.

603 {
604 if (!horizontal)
605 {
606 boolean down = direction == View.FOCUS_DOWN;
607 int height = getHeight();
608 mTempRect.top = 0;
609 mTempRect.bottom = height;
610 if (down)
611 {
612 int count = getChildCount();
613 if (count > 0)
614 {
615 View view = getChildAt(count - 1);
616 mTempRect.bottom = view.getBottom();
617 mTempRect.top = mTempRect.bottom - height;
618 }
619 }
620 return scrollAndFocus(direction, mTempRect.top, mTempRect.bottom, 0, 0, 0);
621 }
622 else
623 {
624 boolean right = direction == View.FOCUS_DOWN;
625 int width = getWidth();
626 mTempRect.left = 0;
627 mTempRect.right = width;
628 if (right)
629 {
630 int count = getChildCount();
631 if (count > 0)
632 {
633 View view = getChildAt(count - 1);
634 mTempRect.right = view.getBottom();
635 mTempRect.left = mTempRect.right - width;
636 }
637 }
638 return scrollAndFocus(0, 0, 0, direction, mTempRect.top, mTempRect.bottom);
639 }
640 }

◆ getBottomFadingEdgeStrength()

float com.freerdp.freerdpcore.presentation.ScrollView2D.getBottomFadingEdgeStrength ( )
inlineprotected

Definition at line 136 of file ScrollView2D.java.

137 {
138 if (getChildCount() == 0)
139 {
140 return 0.0f;
141 }
142 final int length = getVerticalFadingEdgeLength();
143 final int bottomEdge = getHeight() - getPaddingBottom();
144 final int span = getChildAt(0).getBottom() - getScrollY() - bottomEdge;
145 if (span < length)
146 {
147 return span / (float)length;
148 }
149 return 1.0f;
150 }

◆ getLeftFadingEdgeStrength()

float com.freerdp.freerdpcore.presentation.ScrollView2D.getLeftFadingEdgeStrength ( )
inlineprotected

Definition at line 152 of file ScrollView2D.java.

153 {
154 if (getChildCount() == 0)
155 {
156 return 0.0f;
157 }
158 final int length = getHorizontalFadingEdgeLength();
159 if (getScrollX() < length)
160 {
161 return getScrollX() / (float)length;
162 }
163 return 1.0f;
164 }

◆ getMaxScrollAmountHorizontal()

int com.freerdp.freerdpcore.presentation.ScrollView2D.getMaxScrollAmountHorizontal ( )
inline

Definition at line 199 of file ScrollView2D.java.

200 {
201 return (int)(MAX_SCROLL_FACTOR * getWidth());
202 }

◆ getMaxScrollAmountVertical()

int com.freerdp.freerdpcore.presentation.ScrollView2D.getMaxScrollAmountVertical ( )
inline
Returns
The maximum amount this scroll view will scroll in response to an arrow event.

Definition at line 194 of file ScrollView2D.java.

195 {
196 return (int)(MAX_SCROLL_FACTOR * getHeight());
197 }

Referenced by com.freerdp.freerdpcore.presentation.ScrollView2D.arrowScroll().

Here is the caller graph for this function:

◆ getRightFadingEdgeStrength()

float com.freerdp.freerdpcore.presentation.ScrollView2D.getRightFadingEdgeStrength ( )
inlineprotected

Definition at line 166 of file ScrollView2D.java.

167 {
168 if (getChildCount() == 0)
169 {
170 return 0.0f;
171 }
172 final int length = getHorizontalFadingEdgeLength();
173 final int rightEdge = getWidth() - getPaddingRight();
174 final int span = getChildAt(0).getRight() - getScrollX() - rightEdge;
175 if (span < length)
176 {
177 return span / (float)length;
178 }
179 return 1.0f;
180 }

◆ getTopFadingEdgeStrength()

float com.freerdp.freerdpcore.presentation.ScrollView2D.getTopFadingEdgeStrength ( )
inlineprotected

Definition at line 122 of file ScrollView2D.java.

123 {
124 if (getChildCount() == 0)
125 {
126 return 0.0f;
127 }
128 final int length = getVerticalFadingEdgeLength();
129 if (getScrollY() < length)
130 {
131 return getScrollY() / (float)length;
132 }
133 return 1.0f;
134 }

◆ measureChild()

void com.freerdp.freerdpcore.presentation.ScrollView2D.measureChild ( View  child,
int  parentWidthMeasureSpec,
int  parentHeightMeasureSpec 
)
inlineprotected

Definition at line 851 of file ScrollView2D.java.

852 {
853 ViewGroup.LayoutParams lp = child.getLayoutParams();
854 int childWidthMeasureSpec;
855 int childHeightMeasureSpec;
856
857 childWidthMeasureSpec = getChildMeasureSpec(parentWidthMeasureSpec,
858 getPaddingLeft() + getPaddingRight(), lp.width);
859 childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
860
861 child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
862 }

◆ measureChildWithMargins()

void com.freerdp.freerdpcore.presentation.ScrollView2D.measureChildWithMargins ( View  child,
int  parentWidthMeasureSpec,
int  widthUsed,
int  parentHeightMeasureSpec,
int  heightUsed 
)
inlineprotected

Definition at line 865 of file ScrollView2D.java.

867 {
868 final MarginLayoutParams lp = (MarginLayoutParams)child.getLayoutParams();
869 final int childWidthMeasureSpec =
870 MeasureSpec.makeMeasureSpec(lp.leftMargin + lp.rightMargin, MeasureSpec.UNSPECIFIED);
871 final int childHeightMeasureSpec =
872 MeasureSpec.makeMeasureSpec(lp.topMargin + lp.bottomMargin, MeasureSpec.UNSPECIFIED);
873
874 child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
875 }

◆ onInterceptTouchEvent()

boolean com.freerdp.freerdpcore.presentation.ScrollView2D.onInterceptTouchEvent ( MotionEvent  ev)
inline

Definition at line 270 of file ScrollView2D.java.

271 {
272 /*
273 * This method JUST determines whether we want to intercept the motion.
274 * If we return true, onMotionEvent will be called and we do the actual
275 * scrolling there.
276 *
277 * Shortcut the most recurring case: the user is in the dragging
278 * state and he is moving his finger. We want to intercept this
279 * motion.
280 */
281 final int action = ev.getAction();
282 if ((action == MotionEvent.ACTION_MOVE) && (mIsBeingDragged))
283 {
284 return true;
285 }
286 if (!canScroll())
287 {
288 mIsBeingDragged = false;
289 return false;
290 }
291 final float y = ev.getY();
292 final float x = ev.getX();
293 switch (action)
294 {
295 case MotionEvent.ACTION_MOVE:
296 /*
297 * mIsBeingDragged == false, otherwise the shortcut would have caught it. Check
298 * whether the user has moved far enough from his original down touch.
299 */
300 /*
301 * Locally do absolute value. mLastMotionY is set to the y value
302 * of the down event.
303 */
304 final int yDiff = (int)Math.abs(y - mLastMotionY);
305 final int xDiff = (int)Math.abs(x - mLastMotionX);
306 if (yDiff > mTouchSlop || xDiff > mTouchSlop)
307 {
308 mIsBeingDragged = true;
309 }
310 break;
311
312 case MotionEvent.ACTION_DOWN:
313 /* Remember location of down touch */
314 mLastMotionY = y;
315 mLastMotionX = x;
316
317 /*
318 * If being flinged and user touches the screen, initiate drag;
319 * otherwise don't. mScroller.isFinished should be false when
320 * being flinged.
321 */
322 mIsBeingDragged = !mScroller.isFinished();
323 break;
324
325 case MotionEvent.ACTION_CANCEL:
326 case MotionEvent.ACTION_UP:
327 /* Release the drag */
328 mIsBeingDragged = false;
329 break;
330 }
331
332 /*
333 * The only time we want to intercept motion events is if we are in the
334 * drag mode.
335 */
336 return mIsBeingDragged;
337 }

◆ onLayout()

void com.freerdp.freerdpcore.presentation.ScrollView2D.onLayout ( boolean  changed,
int  l,
int  t,
int  r,
int  b 
)
inlineprotected

Definition at line 1103 of file ScrollView2D.java.

1104 {
1105 super.onLayout(changed, l, t, r, b);
1106 mIsLayoutDirty = false;
1107 // Give a child focus if it needs it
1108 if (mChildToScrollTo != null && isViewDescendantOf(mChildToScrollTo, this))
1109 {
1110 scrollToChild(mChildToScrollTo);
1111 }
1112 mChildToScrollTo = null;
1113
1114 // Center the content area (excluding touch-pointer padding) within the viewport.
1115 // This keeps the RDP surface visually centered regardless of pointer padding changes.
1116 if (getChildCount() > 0)
1117 {
1118 View child = getChildAt(0);
1119 int ptw = 0, pth = 0;
1120 if (child instanceof SessionView)
1121 {
1122 ptw = ((SessionView)child).getTouchPointerPaddingWidth();
1123 pth = ((SessionView)child).getTouchPointerPaddingHeight();
1124 }
1125 int contentW = child.getMeasuredWidth() - ptw;
1126 int contentH = child.getMeasuredHeight() - pth;
1127 int usableW = getWidth() - getPaddingLeft() - getPaddingRight();
1128 int usableH = getHeight() - getPaddingTop() - getPaddingBottom();
1129 int left = getPaddingLeft() + Math.max(0, (usableW - contentW) / 2);
1130 int top = getPaddingTop() + Math.max(0, (usableH - contentH) / 2);
1131 child.layout(left, top, left + child.getMeasuredWidth(),
1132 top + child.getMeasuredHeight());
1133 }
1134
1135 // Calling this with the present values causes it to re-clamp them
1136 scrollTo(getScrollX(), getScrollY());
1137 }

◆ onRequestFocusInDescendants()

boolean com.freerdp.freerdpcore.presentation.ScrollView2D.onRequestFocusInDescendants ( int  direction,
Rect  previouslyFocusedRect 
)
inlineprotected

When looking for focus in children of a scroll view, need to be a little more careful not to give focus to something that is scrolled off screen.

This is more expensive than the default android.view.ViewGroup implementation, otherwise this behavior might have been made the default.

Definition at line 1063 of file ScrollView2D.java.

1064 {
1065 // convert from forward / backward notation to up / down / left / right
1066 // (ugh).
1067 if (direction == View.FOCUS_FORWARD)
1068 {
1069 direction = View.FOCUS_DOWN;
1070 }
1071 else if (direction == View.FOCUS_BACKWARD)
1072 {
1073 direction = View.FOCUS_UP;
1074 }
1075
1076 final View nextFocus = previouslyFocusedRect == null
1077 ? FocusFinder.getInstance().findNextFocus(this, null, direction)
1078 : FocusFinder.getInstance().findNextFocusFromRect(
1079 this, previouslyFocusedRect, direction);
1080
1081 if (nextFocus == null)
1082 {
1083 return false;
1084 }
1085
1086 return nextFocus.requestFocus(direction, previouslyFocusedRect);
1087 }

◆ onScrollChanged()

void com.freerdp.freerdpcore.presentation.ScrollView2D.onScrollChanged ( int  x,
int  y,
int  oldx,
int  oldy 
)
inlineprotected

Definition at line 1270 of file ScrollView2D.java.

1271 {
1272 super.onScrollChanged(x, y, oldx, oldy);
1273 if (scrollView2DListener != null)
1274 {
1275 scrollView2DListener.onScrollChanged(this, x, y, oldx, oldy);
1276 }
1277 }

◆ onSizeChanged()

void com.freerdp.freerdpcore.presentation.ScrollView2D.onSizeChanged ( int  w,
int  h,
int  oldw,
int  oldh 
)
inlineprotected

Definition at line 1139 of file ScrollView2D.java.

1140 {
1141 super.onSizeChanged(w, h, oldw, oldh);
1142
1143 View currentFocused = findFocus();
1144 if (null == currentFocused || this == currentFocused)
1145 return;
1146
1147 // If the currently-focused view was visible on the screen when the
1148 // screen was at the old height, then scroll the screen to make that
1149 // view visible with the new screen height.
1150 currentFocused.getDrawingRect(mTempRect);
1151 offsetDescendantRectToMyCoords(currentFocused, mTempRect);
1152 int scrollDeltaX = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
1153 int scrollDeltaY = computeScrollDeltaToGetChildRectOnScreen(mTempRect);
1154 doScroll(scrollDeltaX, scrollDeltaY);
1155 }

◆ onTouchEvent()

boolean com.freerdp.freerdpcore.presentation.ScrollView2D.onTouchEvent ( MotionEvent  ev)
inline

Definition at line 339 of file ScrollView2D.java.

340 {
341
342 if (ev.getAction() == MotionEvent.ACTION_DOWN && ev.getEdgeFlags() != 0)
343 {
344 // Don't handle edge touches immediately -- they may actually belong to one of our
345 // descendants.
346 return false;
347 }
348
349 if (!canScroll())
350 {
351 return false;
352 }
353
354 if (mVelocityTracker == null)
355 {
356 mVelocityTracker = VelocityTracker.obtain();
357 }
358 mVelocityTracker.addMovement(ev);
359
360 final int action = ev.getAction();
361 final float y = ev.getY();
362 final float x = ev.getX();
363
364 switch (action)
365 {
366 case MotionEvent.ACTION_DOWN:
367 /*
368 * If being flinged and user touches, stop the fling. isFinished
369 * will be false if being flinged.
370 */
371 if (!mScroller.isFinished())
372 {
373 mScroller.abortAnimation();
374 }
375
376 // Remember where the motion event started
377 mLastMotionY = y;
378 mLastMotionX = x;
379 break;
380 case MotionEvent.ACTION_MOVE:
381 // Scroll to follow the motion event
382 int deltaX = (int)(mLastMotionX - x);
383 int deltaY = (int)(mLastMotionY - y);
384 mLastMotionX = x;
385 mLastMotionY = y;
386
387 if (deltaX < 0)
388 {
389 if (getScrollX() < 0)
390 {
391 deltaX = 0;
392 }
393 }
394 else if (deltaX > 0)
395 {
396 final int rightEdge = getWidth() - getPaddingRight();
397 final int availableToScroll =
398 getChildAt(0).getRight() - getScrollX() - rightEdge;
399 if (availableToScroll > 0)
400 {
401 deltaX = Math.min(availableToScroll, deltaX);
402 }
403 else
404 {
405 deltaX = 0;
406 }
407 }
408 if (deltaY < 0)
409 {
410 if (getScrollY() < 0)
411 {
412 deltaY = 0;
413 }
414 }
415 else if (deltaY > 0)
416 {
417 final int bottomEdge = getHeight() - getPaddingBottom();
418 final int availableToScroll =
419 getChildAt(0).getBottom() - getScrollY() - bottomEdge;
420 if (availableToScroll > 0)
421 {
422 deltaY = Math.min(availableToScroll, deltaY);
423 }
424 else
425 {
426 deltaY = 0;
427 }
428 }
429 if (deltaY != 0 || deltaX != 0)
430 scrollBy(deltaX, deltaY);
431 break;
432 case MotionEvent.ACTION_UP:
433 final VelocityTracker velocityTracker = mVelocityTracker;
434 velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
435 int initialXVelocity = (int)velocityTracker.getXVelocity();
436 int initialYVelocity = (int)velocityTracker.getYVelocity();
437 if ((Math.abs(initialXVelocity) + Math.abs(initialYVelocity) > mMinimumVelocity) &&
438 getChildCount() > 0)
439 {
440 fling(-initialXVelocity, -initialYVelocity);
441 }
442 if (mVelocityTracker != null)
443 {
444 mVelocityTracker.recycle();
445 mVelocityTracker = null;
446 }
447 }
448 return true;
449 }

◆ requestChildFocus()

void com.freerdp.freerdpcore.presentation.ScrollView2D.requestChildFocus ( View  child,
View  focused 
)
inline

Definition at line 1038 of file ScrollView2D.java.

1039 {
1040 if (!mTwoDScrollViewMovedFocus)
1041 {
1042 if (!mIsLayoutDirty)
1043 {
1044 scrollToChild(focused);
1045 }
1046 else
1047 {
1048 // The child may not be laid out yet, we can't compute the scroll yet
1049 mChildToScrollTo = focused;
1050 }
1051 }
1052 super.requestChildFocus(child, focused);
1053 }

◆ requestChildRectangleOnScreen()

boolean com.freerdp.freerdpcore.presentation.ScrollView2D.requestChildRectangleOnScreen ( View  child,
Rect  rectangle,
boolean  immediate 
)
inline

Definition at line 1090 of file ScrollView2D.java.

1091 {
1092 // offset into coordinate space of this scroll view
1093 rectangle.offset(child.getLeft() - child.getScrollX(), child.getTop() - child.getScrollY());
1094 return scrollToChildRect(rectangle, immediate);
1095 }

◆ requestLayout()

void com.freerdp.freerdpcore.presentation.ScrollView2D.requestLayout ( )
inline

Definition at line 1097 of file ScrollView2D.java.

1098 {
1099 mIsLayoutDirty = true;
1100 super.requestLayout();
1101 }

◆ scrollTo()

void com.freerdp.freerdpcore.presentation.ScrollView2D.scrollTo ( int  x,
int  y 
)
inline

This version also clamps the scrolling to the bounds of our child.

Definition at line 1217 of file ScrollView2D.java.

1218 {
1219 // we rely on the fact the View.scrollBy calls scrollTo.
1220 if (getChildCount() > 0)
1221 {
1222 View child = getChildAt(0);
1223 x = clamp(x, getWidth() - getPaddingRight() - getPaddingLeft(), child.getWidth());
1224 y = clamp(y, getHeight() - getPaddingBottom() - getPaddingTop(), child.getHeight());
1225 if (x != getScrollX() || y != getScrollY())
1226 {
1227 super.scrollTo(x, y);
1228 }
1229 }
1230 }

◆ setScrollEnabled()

void com.freerdp.freerdpcore.presentation.ScrollView2D.setScrollEnabled ( boolean  enable)
inline

Disable/Enable scrolling

Definition at line 185 of file ScrollView2D.java.

186 {
187 scrollEnabled = enable;
188 }

◆ setScrollViewListener()

void com.freerdp.freerdpcore.presentation.ScrollView2D.setScrollViewListener ( ScrollView2DListener  scrollViewListener)
inline

Definition at line 1265 of file ScrollView2D.java.

1266 {
1267 this.scrollView2DListener = scrollViewListener;
1268 }

◆ smoothScrollBy()

final void com.freerdp.freerdpcore.presentation.ScrollView2D.smoothScrollBy ( int  dx,
int  dy 
)
inline

Like View#scrollBy, but scroll smoothly instead of immediately.

Parameters
dxthe number of pixels to scroll by on the X axis
dythe number of pixels to scroll by on the Y axis

Definition at line 803 of file ScrollView2D.java.

804 {
805 long duration = AnimationUtils.currentAnimationTimeMillis() - mLastScroll;
806 if (duration > ANIMATED_SCROLL_GAP)
807 {
808 mScroller.startScroll(getScrollX(), getScrollY(), dx, dy);
809 awakenScrollBars(mScroller.getDuration());
810 invalidate();
811 }
812 else
813 {
814 if (!mScroller.isFinished())
815 {
816 mScroller.abortAnimation();
817 }
818 scrollBy(dx, dy);
819 }
820 mLastScroll = AnimationUtils.currentAnimationTimeMillis();
821 }

Referenced by com.freerdp.freerdpcore.presentation.ScrollView2D.smoothScrollTo().

Here is the caller graph for this function:

◆ smoothScrollTo()

final void com.freerdp.freerdpcore.presentation.ScrollView2D.smoothScrollTo ( int  x,
int  y 
)
inline

Like scrollTo, but scroll smoothly instead of immediately.

Parameters
xthe position where to scroll on the X axis
ythe position where to scroll on the Y axis

Definition at line 829 of file ScrollView2D.java.

830 {
831 smoothScrollBy(x - getScrollX(), y - getScrollY());
832 }

References com.freerdp.freerdpcore.presentation.ScrollView2D.smoothScrollBy().

Here is the call graph for this function:

The documentation for this class was generated from the following file: