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
be777142
Kaydet (Commit)
be777142
authored
Şub 10, 2015
tarafından
Miklos Vajna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
lokdocview: allow dragging the selection end handle
Change-Id: I977e93657c52a66f10762293835ead28451b5406
üst
565a9f3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
13 deletions
+52
-13
LibreOfficeKitGtk.h
include/LibreOfficeKit/LibreOfficeKitGtk.h
+4
-0
lokdocview.c
libreofficekit/source/gtk/lokdocview.c
+48
-13
No files found.
include/LibreOfficeKit/LibreOfficeKitGtk.h
Dosyayı görüntüle @
be777142
...
@@ -66,6 +66,10 @@ struct _LOKDocView
...
@@ -66,6 +66,10 @@ struct _LOKDocView
gboolean
m_bInDragMiddleHandle
;
gboolean
m_bInDragMiddleHandle
;
/// Bitmap of the text selection end handle.
/// Bitmap of the text selection end handle.
cairo_surface_t
*
m_pHandleEnd
;
cairo_surface_t
*
m_pHandleEnd
;
/// Rectangle of the text selection end handle, to know if the user clicked on it or not
GdkRectangle
m_aHandleEndRect
;
/// If we are in the middle of a drag of the text selection end handle.
gboolean
m_bInDragEndHandle
;
};
};
struct
_LOKDocViewClass
struct
_LOKDocViewClass
...
...
libreofficekit/source/gtk/lokdocview.c
Dosyayı görüntüle @
be777142
...
@@ -42,28 +42,49 @@ void lcl_onDestroy( LOKDocView* pDocView, gpointer pData )
...
@@ -42,28 +42,49 @@ void lcl_onDestroy( LOKDocView* pDocView, gpointer pData )
pDocView
->
pDocument
=
NULL
;
pDocView
->
pDocument
=
NULL
;
}
}
/**
* The user drags the handle, which is below the cursor, but wants to move the
* cursor accordingly.
*
* @param pHandle the rectangle of the handle
* @param pEvent the motion event
* @param pPoint the computed point (output parameter)
*/
void
lcl_getDragPoint
(
GdkRectangle
*
pHandle
,
GdkEventButton
*
pEvent
,
GdkPoint
*
pPoint
)
{
GdkPoint
aCursor
,
aHandle
;
// Center of the cursor rectangle: we know that it's above the handle.
aCursor
.
x
=
pHandle
->
x
+
pHandle
->
width
/
2
;
aCursor
.
y
=
pHandle
->
y
-
pHandle
->
height
/
2
;
// Center of the handle rectangle.
aHandle
.
x
=
pHandle
->
x
+
pHandle
->
width
/
2
;
aHandle
.
y
=
pHandle
->
y
+
pHandle
->
height
/
2
;
// Our target is the original cursor position + the dragged offset.
pPoint
->
x
=
aCursor
.
x
+
(
pEvent
->
x
-
aHandle
.
x
);
pPoint
->
y
=
aCursor
.
y
+
(
pEvent
->
y
-
aHandle
.
y
);
}
gboolean
lcl_signalMotion
(
GtkWidget
*
pEventBox
,
GdkEventButton
*
pEvent
,
LOKDocView
*
pDocView
)
gboolean
lcl_signalMotion
(
GtkWidget
*
pEventBox
,
GdkEventButton
*
pEvent
,
LOKDocView
*
pDocView
)
{
{
(
void
)
pEventBox
;
(
void
)
pEventBox
;
if
(
pDocView
->
m_bInDragMiddleHandle
)
if
(
pDocView
->
m_bInDragMiddleHandle
)
{
{
// The user drags the handle, which is below the cursor, but wants to move the cursor accordingly.
GdkPoint
aPoint
;
GdkPoint
aCursor
,
aHandle
,
aPoint
;
g_info
(
"lcl_signalMotion: dragging the middle handle"
);
g_info
(
"lcl_signalMotion: dragging the middle handle"
);
// Center of the cursor rectangle: we know that it's above the handle.
lcl_getDragPoint
(
&
pDocView
->
m_aHandleMiddleRect
,
pEvent
,
&
aPoint
);
aCursor
.
x
=
pDocView
->
m_aHandleMiddleRect
.
x
+
pDocView
->
m_aHandleMiddleRect
.
width
/
2
;
aCursor
.
y
=
pDocView
->
m_aHandleMiddleRect
.
y
-
pDocView
->
m_aHandleMiddleRect
.
height
/
2
;
// Center of the handle rectangle.
aHandle
.
x
=
pDocView
->
m_aHandleMiddleRect
.
x
+
pDocView
->
m_aHandleMiddleRect
.
width
/
2
;
aHandle
.
y
=
pDocView
->
m_aHandleMiddleRect
.
y
+
pDocView
->
m_aHandleMiddleRect
.
height
/
2
;
// Our target is the original cursor position + the dragged offset.
aPoint
.
x
=
aCursor
.
x
+
(
pEvent
->
x
-
aHandle
.
x
);
aPoint
.
y
=
aCursor
.
y
+
(
pEvent
->
y
-
aHandle
.
y
);
pDocView
->
pDocument
->
pClass
->
postMouseEvent
(
pDocView
->
pDocument
,
LOK_MOUSEEVENT_MOUSEBUTTONDOWN
,
pixelToTwip
(
aPoint
.
x
),
pixelToTwip
(
aPoint
.
y
),
1
);
pDocView
->
pDocument
->
pClass
->
postMouseEvent
(
pDocView
->
pDocument
,
LOK_MOUSEEVENT_MOUSEBUTTONDOWN
,
pixelToTwip
(
aPoint
.
x
),
pixelToTwip
(
aPoint
.
y
),
1
);
pDocView
->
pDocument
->
pClass
->
postMouseEvent
(
pDocView
->
pDocument
,
LOK_MOUSEEVENT_MOUSEBUTTONUP
,
pixelToTwip
(
aPoint
.
x
),
pixelToTwip
(
aPoint
.
y
),
1
);
pDocView
->
pDocument
->
pClass
->
postMouseEvent
(
pDocView
->
pDocument
,
LOK_MOUSEEVENT_MOUSEBUTTONUP
,
pixelToTwip
(
aPoint
.
x
),
pixelToTwip
(
aPoint
.
y
),
1
);
}
}
else
if
(
pDocView
->
m_bInDragEndHandle
)
{
GdkPoint
aPoint
;
g_info
(
"lcl_signalMotion: dragging the end handle"
);
lcl_getDragPoint
(
&
pDocView
->
m_aHandleEndRect
,
pEvent
,
&
aPoint
);
pDocView
->
pDocument
->
pClass
->
setTextSelection
(
pDocView
->
pDocument
,
LOK_SETTEXTSELECTION_END
,
pixelToTwip
(
aPoint
.
x
),
pixelToTwip
(
aPoint
.
y
));
}
return
FALSE
;
return
FALSE
;
}
}
...
@@ -79,6 +100,12 @@ gboolean lcl_signalButton(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocVi
...
@@ -79,6 +100,12 @@ gboolean lcl_signalButton(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocVi
pDocView
->
m_bInDragMiddleHandle
=
FALSE
;
pDocView
->
m_bInDragMiddleHandle
=
FALSE
;
return
FALSE
;
return
FALSE
;
}
}
else
if
(
pDocView
->
m_bInDragEndHandle
&&
pEvent
->
type
==
GDK_BUTTON_RELEASE
)
{
g_info
(
"lcl_signalButton: end of drag end handle"
);
pDocView
->
m_bInDragEndHandle
=
FALSE
;
return
FALSE
;
}
if
(
pDocView
->
m_bEdit
)
if
(
pDocView
->
m_bEdit
)
{
{
...
@@ -93,6 +120,12 @@ gboolean lcl_signalButton(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocVi
...
@@ -93,6 +120,12 @@ gboolean lcl_signalButton(GtkWidget* pEventBox, GdkEventButton* pEvent, LOKDocVi
pDocView
->
m_bInDragMiddleHandle
=
TRUE
;
pDocView
->
m_bInDragMiddleHandle
=
TRUE
;
return
FALSE
;
return
FALSE
;
}
}
else
if
(
gdk_rectangle_intersect
(
&
aClick
,
&
pDocView
->
m_aHandleEndRect
,
NULL
)
&&
pEvent
->
type
==
GDK_BUTTON_PRESS
)
{
g_info
(
"lcl_signalButton: start of drag end handle"
);
pDocView
->
m_bInDragEndHandle
=
TRUE
;
return
FALSE
;
}
}
}
lok_docview_set_edit
(
pDocView
,
TRUE
);
lok_docview_set_edit
(
pDocView
,
TRUE
);
...
@@ -191,6 +224,8 @@ static void lok_docview_init( LOKDocView* pDocView )
...
@@ -191,6 +224,8 @@ static void lok_docview_init( LOKDocView* pDocView )
pDocView
->
m_pHandleEnd
=
NULL
;
pDocView
->
m_pHandleEnd
=
NULL
;
memset
(
&
pDocView
->
m_aHandleMiddleRect
,
0
,
sizeof
(
pDocView
->
m_aHandleMiddleRect
));
memset
(
&
pDocView
->
m_aHandleMiddleRect
,
0
,
sizeof
(
pDocView
->
m_aHandleMiddleRect
));
pDocView
->
m_bInDragMiddleHandle
=
FALSE
;
pDocView
->
m_bInDragMiddleHandle
=
FALSE
;
memset
(
&
pDocView
->
m_aHandleEndRect
,
0
,
sizeof
(
pDocView
->
m_aHandleEndRect
));
pDocView
->
m_bInDragEndHandle
=
FALSE
;
gtk_signal_connect
(
GTK_OBJECT
(
pDocView
),
"destroy"
,
gtk_signal_connect
(
GTK_OBJECT
(
pDocView
),
"destroy"
,
GTK_SIGNAL_FUNC
(
lcl_onDestroy
),
NULL
);
GTK_SIGNAL_FUNC
(
lcl_onDestroy
),
NULL
);
...
@@ -332,7 +367,7 @@ static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpoint
...
@@ -332,7 +367,7 @@ static gboolean renderOverlay(GtkWidget* pWidget, GdkEventExpose* pEvent, gpoint
// Have a start position: we need an end handle.
// Have a start position: we need an end handle.
if
(
!
pDocView
->
m_pHandleEnd
)
if
(
!
pDocView
->
m_pHandleEnd
)
pDocView
->
m_pHandleEnd
=
cairo_image_surface_create_from_png
(
CURSOR_HANDLE_DIR
"handle_end.png"
);
pDocView
->
m_pHandleEnd
=
cairo_image_surface_create_from_png
(
CURSOR_HANDLE_DIR
"handle_end.png"
);
lcl_renderHandle
(
pCairo
,
&
pDocView
->
m_aTextSelectionEnd
,
pDocView
->
m_pHandleEnd
,
NULL
);
lcl_renderHandle
(
pCairo
,
&
pDocView
->
m_aTextSelectionEnd
,
pDocView
->
m_pHandleEnd
,
&
pDocView
->
m_aHandleEndRect
);
}
}
}
}
...
...
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