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
205b6952
Kaydet (Commit)
205b6952
authored
Mar 23, 2015
tarafından
Tomaž Vajngerl
Kaydeden (comit)
Miklos Vajna
Mar 23, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
android: extract drawing of selection into its own class
Change-Id: I8e94edeafbf5b7fd5f02a1429893c4b803c71afa
üst
19c59a34
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
32 deletions
+102
-32
DrawElementGraphicSelection.java
...src/java/org/libreoffice/DrawElementGraphicSelection.java
+66
-0
TextCursorView.java
...l/LOAndroid3/src/java/org/libreoffice/TextCursorView.java
+36
-32
No files found.
android/experimental/LOAndroid3/src/java/org/libreoffice/DrawElementGraphicSelection.java
0 → 100644
Dosyayı görüntüle @
205b6952
package
org
.
libreoffice
;
import
android.graphics.Canvas
;
import
android.graphics.Paint
;
import
android.graphics.PointF
;
import
android.graphics.RectF
;
/**
* This class is responsible to draw and reposition the selection
* rectangle.
*/
public
class
DrawElementGraphicSelection
{
private
final
Paint
mGraphicSelectionPaint
;
public
RectF
mRectangle
=
new
RectF
();
public
RectF
mScaledRectangle
=
new
RectF
();
private
RectF
mDrawRectangle
=
new
RectF
();
private
DragType
mType
=
DragType
.
NONE
;
private
PointF
mStartDragPosition
;
public
DrawElementGraphicSelection
(
Paint
graphicSelectionPaint
)
{
mGraphicSelectionPaint
=
graphicSelectionPaint
;
}
public
void
reposition
(
RectF
scaledRectangle
)
{
mScaledRectangle
=
scaledRectangle
;
mDrawRectangle
=
scaledRectangle
;
}
public
boolean
contains
(
float
x
,
float
y
)
{
return
mScaledRectangle
.
contains
(
x
,
y
);
}
public
void
draw
(
Canvas
canvas
)
{
canvas
.
drawRect
(
mDrawRectangle
,
mGraphicSelectionPaint
);
}
public
void
dragStart
(
DragType
type
,
PointF
position
)
{
mType
=
type
;
mStartDragPosition
=
position
;
}
public
void
dragging
(
PointF
position
)
{
if
(
mType
==
DragType
.
MOVE
)
{
float
deltaX
=
position
.
x
-
mStartDragPosition
.
x
;
float
deltaY
=
position
.
y
-
mStartDragPosition
.
y
;
mDrawRectangle
=
new
RectF
(
mScaledRectangle
);
mDrawRectangle
.
offset
(
deltaX
,
deltaY
);
}
else
if
(
mType
==
DragType
.
EXTEND
)
{
mDrawRectangle
=
new
RectF
(
mScaledRectangle
);
mDrawRectangle
.
union
(
position
.
x
,
position
.
y
);
}
}
public
void
dragEnd
()
{
mType
=
DragType
.
NONE
;
mDrawRectangle
=
mScaledRectangle
;
}
enum
DragType
{
NONE
,
MOVE
,
EXTEND
}
}
android/experimental/LOAndroid3/src/java/org/libreoffice/TextCursorView.java
Dosyayı görüntüle @
205b6952
...
...
@@ -48,14 +48,16 @@ public class TextCursorView extends View implements View.OnTouchListener {
private
Paint
mSelectionPaint
=
new
Paint
();
private
boolean
mSelectionsVisible
;
private
RectF
mGraphicSelection
=
new
RectF
();
private
RectF
mGraphicScaledSelection
=
new
RectF
();
private
Paint
mGraphicSelectionPaint
=
new
Paint
();
private
boolean
mGraphicSelectionVisible
;
private
DrawElementGraphicSelection
mGraphicSelection
;
private
PointF
mTouchStart
=
new
PointF
();
private
PointF
mDeltaPoint
=
new
PointF
();
private
boolean
mGraphicSelectionVisible
;
private
boolean
mGraphicSelectionMove
=
false
;
private
LayerView
mLayerView
;
private
DrawElementHandle
mHandles
[]
=
new
DrawElementHandle
[
8
];
...
...
@@ -94,6 +96,9 @@ public class TextCursorView extends View implements View.OnTouchListener {
mGraphicSelectionPaint
.
setStyle
(
Paint
.
Style
.
STROKE
);
mGraphicSelectionPaint
.
setColor
(
Color
.
BLACK
);
mGraphicSelectionPaint
.
setStrokeWidth
(
2
);
mGraphicSelection
=
new
DrawElementGraphicSelection
(
mGraphicSelectionPaint
);
mGraphicSelectionVisible
=
false
;
mHandles
[
0
]
=
new
DrawElementHandle
(
mGraphicSelectionPaint
);
...
...
@@ -144,39 +149,43 @@ public class TextCursorView extends View implements View.OnTouchListener {
return
;
}
mGraphicSelection
=
rectangle
;
mGraphicSelection
.
mRectangle
=
rectangle
;
ImmutableViewportMetrics
metrics
=
layerView
.
getViewportMetrics
();
repositionWithViewport
(
metrics
.
viewportRectLeft
,
metrics
.
viewportRectTop
,
metrics
.
zoomFactor
);
}
public
void
repositionWithViewport
(
float
x
,
float
y
,
float
zoom
)
{
mCursorScaledPosition
=
RectUtils
.
scale
(
mCursorPosition
,
zoom
);
mCursorScaledPosition
.
offset
(-
x
,
-
y
);
mCursorScaledPosition
=
convertPosition
(
mCursorPosition
,
x
,
y
,
zoom
);
mCursorScaledPosition
.
right
=
mCursorScaledPosition
.
left
+
CURSOR_WIDTH
;
mScaledSelections
.
clear
();
for
(
RectF
selection
:
mSelections
)
{
RectF
scaledSelection
=
RectUtils
.
scale
(
selection
,
zoom
);
scaledSelection
.
offset
(-
x
,
-
y
);
RectF
scaledSelection
=
convertPosition
(
selection
,
x
,
y
,
zoom
);
mScaledSelections
.
add
(
scaledSelection
);
}
mGraphicScaledSelection
=
RectUtils
.
scale
(
mGraphicSelection
,
zoom
);
mGraphicS
caledSelection
.
offset
(-
x
,
-
y
);
RectF
scaledGraphicSelection
=
convertPosition
(
mGraphicSelection
.
mRectangle
,
x
,
y
,
zoom
);
mGraphicS
election
.
reposition
(
scaledGraphicSelection
);
mHandles
[
0
].
reposition
(
mGraphicScaledSelection
.
left
,
mGraphicScaled
Selection
.
top
);
mHandles
[
1
].
reposition
(
mGraphicScaledSelection
.
centerX
(),
mGraphicScaled
Selection
.
top
);
mHandles
[
2
].
reposition
(
mGraphicScaledSelection
.
right
,
mGraphicScaled
Selection
.
top
);
mHandles
[
3
].
reposition
(
mGraphicScaledSelection
.
left
,
mGraphicScaled
Selection
.
centerY
());
mHandles
[
4
].
reposition
(
mGraphicScaledSelection
.
right
,
mGraphicScaled
Selection
.
centerY
());
mHandles
[
5
].
reposition
(
mGraphicScaledSelection
.
left
,
mGraphicScaled
Selection
.
bottom
);
mHandles
[
6
].
reposition
(
mGraphicScaledSelection
.
centerX
(),
mGraphicScaled
Selection
.
bottom
);
mHandles
[
7
].
reposition
(
mGraphicScaledSelection
.
right
,
mGraphicScaled
Selection
.
bottom
);
mHandles
[
0
].
reposition
(
scaledGraphicSelection
.
left
,
scaledGraphic
Selection
.
top
);
mHandles
[
1
].
reposition
(
scaledGraphicSelection
.
centerX
(),
scaledGraphic
Selection
.
top
);
mHandles
[
2
].
reposition
(
scaledGraphicSelection
.
right
,
scaledGraphic
Selection
.
top
);
mHandles
[
3
].
reposition
(
scaledGraphicSelection
.
left
,
scaledGraphic
Selection
.
centerY
());
mHandles
[
4
].
reposition
(
scaledGraphicSelection
.
right
,
scaledGraphic
Selection
.
centerY
());
mHandles
[
5
].
reposition
(
scaledGraphicSelection
.
left
,
scaledGraphic
Selection
.
bottom
);
mHandles
[
6
].
reposition
(
scaledGraphicSelection
.
centerX
(),
scaledGraphic
Selection
.
bottom
);
mHandles
[
7
].
reposition
(
scaledGraphicSelection
.
right
,
scaledGraphic
Selection
.
bottom
);
invalidate
();
}
private
RectF
convertPosition
(
RectF
cursorPosition
,
float
x
,
float
y
,
float
zoom
)
{
RectF
cursor
=
RectUtils
.
scale
(
cursorPosition
,
zoom
);
cursor
.
offset
(-
x
,
-
y
);
return
cursor
;
}
@Override
protected
void
onDraw
(
Canvas
canvas
)
{
super
.
onDraw
(
canvas
);
...
...
@@ -189,6 +198,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
}
}
if
(
mGraphicSelectionVisible
)
{
mGraphicSelection
.
draw
(
canvas
);
if
(
mGraphicSelectionMove
)
{
for
(
DrawElementHandle
handle
:
mHandles
)
{
if
(
mDragHandle
==
handle
)
{
...
...
@@ -197,20 +208,7 @@ public class TextCursorView extends View implements View.OnTouchListener {
handle
.
draw
(
canvas
);
}
}
RectF
selectionRect
=
new
RectF
(
mGraphicScaledSelection
);
if
(
mDragHandle
!=
null
)
{
PointF
dragPosition
=
new
PointF
(
mDragHandle
.
mPosition
.
x
,
mDragHandle
.
mPosition
.
y
);
dragPosition
.
offset
(
mDeltaPoint
.
x
,
mDeltaPoint
.
y
);
selectionRect
.
union
(
dragPosition
.
x
,
dragPosition
.
y
);
canvas
.
drawRect
(
selectionRect
,
mGraphicSelectionPaint
);
}
else
{
selectionRect
.
offset
(
mDeltaPoint
.
x
,
mDeltaPoint
.
y
);
canvas
.
drawRect
(
selectionRect
,
mGraphicSelectionPaint
);
}
}
else
{
canvas
.
drawRect
(
mGraphicScaledSelection
,
mGraphicSelectionPaint
);
for
(
DrawElementHandle
handle
:
mHandles
)
{
handle
.
draw
(
canvas
);
}
...
...
@@ -286,6 +284,7 @@ public class TextCursorView extends View implements View.OnTouchListener {
if
(
mGraphicSelectionVisible
&&
mGraphicSelectionMove
)
{
mDeltaPoint
.
x
=
event
.
getX
()
-
mTouchStart
.
x
;
mDeltaPoint
.
y
=
event
.
getY
()
-
mTouchStart
.
y
;
mGraphicSelection
.
dragging
(
new
PointF
(
event
.
getX
(),
event
.
getY
()));
invalidate
();
return
true
;
}
...
...
@@ -301,13 +300,15 @@ public class TextCursorView extends View implements View.OnTouchListener {
if
(
handle
.
contains
(
mTouchStart
.
x
,
mTouchStart
.
y
))
{
mDragHandle
=
handle
;
mGraphicSelectionMove
=
true
;
mGraphicSelection
.
dragStart
(
DrawElementGraphicSelection
.
DragType
.
EXTEND
,
mTouchStart
);
sendGraphicSelectionStart
(
handle
.
mPosition
);
return
true
;
}
}
// Check if inside graphic selection was hit
if
(
mGraphicS
caledS
election
.
contains
(
mTouchStart
.
x
,
mTouchStart
.
y
))
{
if
(
mGraphicSelection
.
contains
(
mTouchStart
.
x
,
mTouchStart
.
y
))
{
mGraphicSelectionMove
=
true
;
mGraphicSelection
.
dragStart
(
DrawElementGraphicSelection
.
DragType
.
MOVE
,
mTouchStart
);
sendGraphicSelectionStart
(
mTouchStart
);
return
true
;
}
...
...
@@ -316,6 +317,7 @@ public class TextCursorView extends View implements View.OnTouchListener {
private
boolean
stopGraphicSelection
()
{
mGraphicSelectionMove
=
false
;
PointF
point
=
new
PointF
();
if
(
mDragHandle
!=
null
)
{
point
.
x
=
mDragHandle
.
mPosition
.
x
;
...
...
@@ -326,6 +328,8 @@ public class TextCursorView extends View implements View.OnTouchListener {
}
point
.
offset
(
mDeltaPoint
.
x
,
mDeltaPoint
.
y
);
sendGraphicSelectionEnd
(
point
);
mGraphicSelection
.
dragEnd
();
invalidate
();
return
true
;
}
...
...
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