Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
6d9af889
Kaydet (Commit)
6d9af889
authored
Nis 08, 2015
tarafından
Tomaž Vajngerl
Kaydeden (comit)
Miklos Vajna
Nis 13, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
android: add Cursor class for drawing the cursor to the canvas
Change-Id: I5d8191ffb3d3dd3d3ab11c757a3b7d5dc3fb2e82
üst
4e0d2fcd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
23 deletions
+57
-23
Cursor.java
...al/LOAndroid3/src/java/org/libreoffice/canvas/Cursor.java
+38
-0
TextCursorView.java
...oid3/src/java/org/libreoffice/overlay/TextCursorView.java
+19
-23
No files found.
android/experimental/LOAndroid3/src/java/org/libreoffice/canvas/Cursor.java
0 → 100644
Dosyayı görüntüle @
6d9af889
package
org
.
libreoffice
.
canvas
;
import
android.graphics.Canvas
;
import
android.graphics.Color
;
import
android.graphics.Paint
;
import
android.graphics.RectF
;
public
class
Cursor
extends
CommonCanvasElement
{
private
static
final
float
CURSOR_WIDTH
=
2
f
;
private
final
Paint
mCursorPaint
=
new
Paint
();
public
RectF
mPosition
=
new
RectF
();
public
RectF
mScaledPosition
=
new
RectF
();
public
int
mAlpha
=
0
;
public
Cursor
()
{
mCursorPaint
.
setColor
(
Color
.
BLACK
);
mCursorPaint
.
setAlpha
(
0xFF
);
}
@Override
public
boolean
onHitTest
(
float
x
,
float
y
)
{
return
false
;
}
@Override
public
void
onDraw
(
Canvas
canvas
)
{
canvas
.
drawRect
(
mScaledPosition
,
mCursorPaint
);
}
public
void
reposition
(
RectF
rect
)
{
mScaledPosition
=
rect
;
mScaledPosition
.
right
=
mScaledPosition
.
left
+
CURSOR_WIDTH
;
}
public
void
cycleAlpha
()
{
mCursorPaint
.
setAlpha
(
mCursorPaint
.
getAlpha
()
==
0
?
0xFF
:
0
);
}
}
android/experimental/LOAndroid3/src/java/org/libreoffice/overlay/TextCursorView.java
Dosyayı görüntüle @
6d9af889
...
@@ -23,6 +23,7 @@ import android.view.View;
...
@@ -23,6 +23,7 @@ import android.view.View;
import
org.libreoffice.LOKitShell
;
import
org.libreoffice.LOKitShell
;
import
org.libreoffice.R
;
import
org.libreoffice.R
;
import
org.libreoffice.canvas.Cursor
;
import
org.libreoffice.canvas.GraphicSelection
;
import
org.libreoffice.canvas.GraphicSelection
;
import
org.libreoffice.canvas.SelectionHandle
;
import
org.libreoffice.canvas.SelectionHandle
;
import
org.libreoffice.canvas.SelectionHandleEnd
;
import
org.libreoffice.canvas.SelectionHandleEnd
;
...
@@ -40,15 +41,10 @@ import java.util.List;
...
@@ -40,15 +41,10 @@ import java.util.List;
*/
*/
public
class
TextCursorView
extends
View
implements
View
.
OnTouchListener
{
public
class
TextCursorView
extends
View
implements
View
.
OnTouchListener
{
private
static
final
String
LOGTAG
=
TextCursorView
.
class
.
getSimpleName
();
private
static
final
String
LOGTAG
=
TextCursorView
.
class
.
getSimpleName
();
private
static
final
float
CURSOR_WIDTH
=
2
f
;
private
static
final
int
CURSOR_BLINK_TIME
=
500
;
private
static
final
int
CURSOR_BLINK_TIME
=
500
;
private
boolean
mInitialized
=
false
;
private
boolean
mInitialized
=
false
;
private
RectF
mCursorPosition
=
new
RectF
();
private
RectF
mCursorScaledPosition
=
new
RectF
();
private
Paint
mCursorPaint
=
new
Paint
();
private
int
mCursorAlpha
=
0
;
private
boolean
mCursorVisible
;
private
List
<
RectF
>
mSelections
=
new
ArrayList
<
RectF
>();
private
List
<
RectF
>
mSelections
=
new
ArrayList
<
RectF
>();
private
List
<
RectF
>
mScaledSelections
=
new
ArrayList
<
RectF
>();
private
List
<
RectF
>
mScaledSelections
=
new
ArrayList
<
RectF
>();
...
@@ -65,6 +61,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
...
@@ -65,6 +61,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
private
SelectionHandle
mHandleStart
;
private
SelectionHandle
mHandleStart
;
private
SelectionHandle
mHandleEnd
;
private
SelectionHandle
mHandleEnd
;
private
Cursor
mCursor
;
private
SelectionHandle
mDragHandle
=
null
;
private
SelectionHandle
mDragHandle
=
null
;
public
TextCursorView
(
Context
context
)
{
public
TextCursorView
(
Context
context
)
{
...
@@ -87,9 +85,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
...
@@ -87,9 +85,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
setOnTouchListener
(
this
);
setOnTouchListener
(
this
);
mLayerView
=
layerView
;
mLayerView
=
layerView
;
mCursorPaint
.
setColor
(
Color
.
BLACK
);
mCursor
=
new
Cursor
();
mCursorPaint
.
setAlpha
(
0xFF
);
mCursor
.
setVisible
(
false
);
mCursorVisible
=
false
;
mSelectionPaint
.
setColor
(
Color
.
BLUE
);
mSelectionPaint
.
setColor
(
Color
.
BLUE
);
mSelectionPaint
.
setAlpha
(
50
);
mSelectionPaint
.
setAlpha
(
50
);
...
@@ -113,10 +110,10 @@ public class TextCursorView extends View implements View.OnTouchListener {
...
@@ -113,10 +110,10 @@ public class TextCursorView extends View implements View.OnTouchListener {
* @param position - new position of the cursor
* @param position - new position of the cursor
*/
*/
public
void
changeCursorPosition
(
RectF
position
)
{
public
void
changeCursorPosition
(
RectF
position
)
{
if
(
RectUtils
.
fuzzyEquals
(
mCursorPosition
,
position
))
{
if
(
RectUtils
.
fuzzyEquals
(
mCursor
.
m
Position
,
position
))
{
return
;
return
;
}
}
mCursorPosition
=
position
;
mCursor
.
m
Position
=
position
;
ImmutableViewportMetrics
metrics
=
mLayerView
.
getViewportMetrics
();
ImmutableViewportMetrics
metrics
=
mLayerView
.
getViewportMetrics
();
repositionWithViewport
(
metrics
.
viewportRectLeft
,
metrics
.
viewportRectTop
,
metrics
.
zoomFactor
);
repositionWithViewport
(
metrics
.
viewportRectLeft
,
metrics
.
viewportRectTop
,
metrics
.
zoomFactor
);
...
@@ -149,10 +146,10 @@ public class TextCursorView extends View implements View.OnTouchListener {
...
@@ -149,10 +146,10 @@ public class TextCursorView extends View implements View.OnTouchListener {
}
}
public
void
repositionWithViewport
(
float
x
,
float
y
,
float
zoom
)
{
public
void
repositionWithViewport
(
float
x
,
float
y
,
float
zoom
)
{
mCursorScaledPosition
=
convertToScreen
(
mCursor
Position
,
x
,
y
,
zoom
);
RectF
rect
=
convertToScreen
(
mCursor
.
m
Position
,
x
,
y
,
zoom
);
mCursor
ScaledPosition
.
right
=
mCursorScaledPosition
.
left
+
CURSOR_WIDTH
;
mCursor
.
reposition
(
rect
)
;
RectF
rect
=
convertToScreen
(
mHandleMiddle
.
mDocumentPosition
,
x
,
y
,
zoom
);
rect
=
convertToScreen
(
mHandleMiddle
.
mDocumentPosition
,
x
,
y
,
zoom
);
mHandleMiddle
.
reposition
(
rect
.
left
,
rect
.
bottom
);
mHandleMiddle
.
reposition
(
rect
.
left
,
rect
.
bottom
);
rect
=
convertToScreen
(
mHandleStart
.
mDocumentPosition
,
x
,
y
,
zoom
);
rect
=
convertToScreen
(
mHandleStart
.
mDocumentPosition
,
x
,
y
,
zoom
);
...
@@ -189,9 +186,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
...
@@ -189,9 +186,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
protected
void
onDraw
(
Canvas
canvas
)
{
protected
void
onDraw
(
Canvas
canvas
)
{
super
.
onDraw
(
canvas
);
super
.
onDraw
(
canvas
);
if
(
mCursorVisible
)
{
mCursor
.
draw
(
canvas
);
canvas
.
drawRect
(
mCursorScaledPosition
,
mCursorPaint
);
}
mHandleMiddle
.
draw
(
canvas
);
mHandleMiddle
.
draw
(
canvas
);
mHandleStart
.
draw
(
canvas
);
mHandleStart
.
draw
(
canvas
);
mHandleEnd
.
draw
(
canvas
);
mHandleEnd
.
draw
(
canvas
);
...
@@ -211,8 +207,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
...
@@ -211,8 +207,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
*/
*/
private
Runnable
cursorAnimation
=
new
Runnable
()
{
private
Runnable
cursorAnimation
=
new
Runnable
()
{
public
void
run
()
{
public
void
run
()
{
if
(
mCursor
Visible
)
{
if
(
mCursor
.
isVisible
()
)
{
mCursor
Paint
.
setAlpha
(
mCursorPaint
.
getAlpha
()
==
0
?
0xFF
:
0
);
mCursor
.
cycleAlpha
(
);
invalidate
();
invalidate
();
}
}
postDelayed
(
cursorAnimation
,
CURSOR_BLINK_TIME
);
postDelayed
(
cursorAnimation
,
CURSOR_BLINK_TIME
);
...
@@ -223,8 +219,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
...
@@ -223,8 +219,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
* Show the cursor on the view.
* Show the cursor on the view.
*/
*/
public
void
showCursor
()
{
public
void
showCursor
()
{
if
(!
mCursor
Visible
)
{
if
(!
mCursor
.
isVisible
()
)
{
mCursor
Visible
=
true
;
mCursor
.
setVisible
(
true
)
;
invalidate
();
invalidate
();
}
}
}
}
...
@@ -233,8 +229,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
...
@@ -233,8 +229,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
* Hide the cursor.
* Hide the cursor.
*/
*/
public
void
hideCursor
()
{
public
void
hideCursor
()
{
if
(
mCursor
Visible
)
{
if
(
mCursor
.
isVisible
()
)
{
mCursor
Visible
=
false
;
mCursor
.
setVisible
(
false
)
;
invalidate
();
invalidate
();
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment