Commit Graph

25 Commits

Author SHA1 Message Date
Matthias Clasen
d4e8a501a0 GtkTextHandle: Better draw() implementation
Conceptually, text handles are boxes, whose content is a 'handle',
so draw background, frame and handle. With this, and the previous
commit, the cursor-handle theming in Adwaita now works as intended.
2014-07-13 13:58:16 -04:00
Carlos Garnacho
ca1510177c texthandle: Mind the invisible area when moving the handle
The handle is still centered horizontally, but the extra vertical
space wasn't taken into account, leading to misplacing the dragging
point (and the handle) during motion events.
2014-05-23 19:54:33 +02:00
Carlos Garnacho
2ba89256f4 texthandle: Make a bigger hit area around texthandles
The hit area now extends to all sides around the handle, instead
of just towards where the text is. This makes it easier to grab
handles once shown.
2014-05-23 19:54:32 +02:00
Matthias Clasen
479babf339 GtkTextHandle: Deal with parent_scrollable going away
Use a weak reference to notice when parent_scrollable is
going away.

https://bugzilla.gnome.org/show_bug.cgi?id=724392
2014-02-19 00:24:30 -05:00
Carlos Garnacho
9fe26a93eb texthandle: Update child visibility of handles within scrollables
If the rect a handle points to starts falling outside of the parent
scrollable allocation, the handle will be automatically hidden, and
shown again when the rectangle is visible too.
2014-01-22 17:10:07 +01:00
Carlos Garnacho
328404795b texthandle: Track parent scrollable adjustments
This makes sure texthandles follow the parent if it is contained within a
GtkScrollable.
2014-01-22 17:10:07 +01:00
Carlos Garnacho
360d5f04c0 texthandle: ensure handles are recreated on parent hierarchy changes
This ensures the handles come out right even if the parent widget is
reparented to a different toplevel.
2014-01-22 17:10:07 +01:00
Carlos Garnacho
834ad653ea texthandle: Use GtkWindow private popover API. 2014-01-22 17:10:07 +01:00
Carlos Garnacho
31042fe95f popover: Fix memory management of popovers
Popovers are strange in the sense that they aren't attached to a
parent directly, they rely on the relative_to widget so the toplevel
is shared, and when they have a parent, it is the toplevel itself,
not relative_to. This also means that there are conditions where the
popover loses it's parent, so they must survive unparenting.

The previous code would be floating the last reference as soon as the
parent is gone, but it was non-obvious who'd own that reference. So
fix this situation by granting the ownership of popovers to their
relative_to widget, an extra reference may be held by the toplevel
when the popover has a parent, but the popover object will be
guaranteed to be alive as long as the parent lives.

This way, memory management of popovers is as hidden from the user
as regular widgets within containers are, users are free to call
gtk_widget_destroy() on a popover, but it'd eventually become
destructed when relative_to is.
2014-01-22 17:10:06 +01:00
Carlos Garnacho
bd5490ad62 texthandle: Fix arguments in ::style-updated callback 2014-01-22 17:10:06 +01:00
Carlos Garnacho
4a8a2286e1 texthandle: Remove relative_to API
It's unused now, GtkTextHandle uses widget coordinates.
2014-01-22 17:10:05 +01:00
Carlos Garnacho
844c6b8951 texthandles: Use GtkWindow popovers API
This offers the same behavior, but GDK_WINDOW_TEMP windows aren't used
anymore, involving less translations from/to root coordinates, plus no
glitches in having handles snap to content as windows move.
2014-01-22 17:10:05 +01:00
Benjamin Otte
7f0c29bcd7 texthandle: Use the parent widget's style context
... instead of creating our own.
2013-10-05 13:57:51 +02:00
Emmanuele Bassi
0899ef7cc9 gtk: Use new macros for defining private data
https://bugzilla.gnome.org/show_bug.cgi?id=702996
2013-07-09 09:30:02 +01:00
Carlos Garnacho
a97178af65 texthandle: Set a bigger input shape, covering the line height
Now, even if the handles being rendered are small, the handle touch
input shape will be as wide as the visible part of the rendered asset, and
high enough to cover both the handle and the height of the line where
the selection bound is.

Also, make handles have the same virtual distance to the line top/bottom
when a drag starts, so the handle doesn't jump to another line after a
too short threshold.
2013-03-05 16:47:58 -05:00
Carlos Garnacho
d97861bd8b texthandles: Keep state internally to avoid X overhead
Handles now do sync X calls less often. As visibility state
is kept, it now can move+resize+show handles at once instead
of in separated steps.
2013-03-05 16:47:58 -05:00
Alexander Larsson
c6bbfc8e3d Add a few missing gtk_widget_unregister_window calls
This was causing warnings on widget unparent like:

Gdk-CRITICAL **: gdk_window_has_native: assertion `GDK_IS_WINDOW (window)' failed

Becasue the window was not properly removed from the lists on unrealize.
2013-02-18 09:35:58 +01:00
Alexander Larsson
ebb84e8d19 TextHandle: Don't draw handles if not visible
When calling gtk_widget_draw() on the entry gtk_cairo_should_draw_window()
will return TRUE for all windows. This is used when rendering a widget to
somewhere other than the screen, and its now used for transparent widgets.
This caused the texthandle to always draw itself and terminate the draw
handler for the entry.

Instead we now only draw the markers when really visible, plus we return
FALSE to avoid stopping the entry drawing.

https://bugzilla.gnome.org/show_bug.cgi?id=687842
2013-02-07 11:11:38 +01:00
Alexander Larsson
3d4cd4db3e Add gtk_widget_(un)register_window
This replaces the previously hardcoded calls to gdk_window_set_user_data,
and also lets us track which windows are a part of a widget. Old code
should continue working as is, but new features that require the
windows may not work perfectly.

We need this for the transparent widget support to work, as we need
to specially mark the windows of child widgets.

https://bugzilla.gnome.org/show_bug.cgi?id=687842
2013-02-07 11:11:37 +01:00
Carlos Garnacho
63c75a2384 texthandles: Add an extra style class to the cursor-mode handle
Themes may want to render handles differently depending on whether
the widget is in selection mode (2 handles enclosing a selection) or
cursor mode (one handle pointing out the insertion cursor).
2012-10-26 18:38:38 +02:00
Carlos Garnacho
0eb09ac0f2 texthandles: set input shape on handles' window
This improves both interaction and theming, as it allows
arbitrary handle shapes while just being draggable from
the visible areas.

This way themes can set up handles with the hotspot visually
displaced from the horizontal center, as long as the hotspot
lies centered in the image/svg asset.
2012-10-26 18:35:24 +02:00
Carlos Garnacho
f6952ceb82 texthandle: Fix shape setup on non-composited environments
The check on the handle to be drawn on the mask was based on the yet to
be set priv->windows pointers, pass explicitly the handle position to
have the shape correctly initialized on non-composited environments
2012-10-26 17:46:40 +02:00
Alexander Larsson
f9d77959a4 Don't create GdkWindows with NULL parents
This is not multi-display safe, you always need to pick the right
parent based on which screen your widget is at.
2012-09-27 13:46:26 +02:00
Carlos Garnacho
81045779f6 Improve CSS styling of touch text selection handles
Don't hook on the widget style context and set up instead
a widget path for itself. Also use a common style class
for both handles, with an extra top/bottom class for each
handle.
2012-09-03 17:08:02 +02:00
Carlos Garnacho
1f7e375c33 Add GtkTextHandle
This is a helper object to allow text widgets to implement
text selection on touch devices. It allows for both cursor
placement and text selection, displaying draggable handles
on/around the cursor and selection bound positions.

Currently, this is private to GTK+, and only available to
GtkEntry and GtkTextView.
2012-09-03 00:19:03 -04:00