Commit Graph

649 Commits

Author SHA1 Message Date
Matthias Clasen
bb786ac240 textview: Use a CSS node for selection rendering
Use a CSS node with name selection, like we do for entries
and labels. Unlike those widgets, we currently don't user
gtk_render_background, but just use the background color.
That will require more effort.
2015-11-10 21:18:10 -05:00
Alexander Larsson
0af457639d TextView: Use saner coordinate space in draw_layer.
When I added the draw_layer vfunc it accidentally got passed a cairo_t
that was configured with to draw in the viewport coordinate space (rather
than the buffer coordinate space). This makes things unnecessary complex,
because you have to convert between the two.

The pixel cache is shared between the text and the layers, so there is
no way to use draw_layer to get a stationary overlay effect. Thus it makes
much more sense for the draw_layer vfunc to draw in the buffer space.

Just changing this would break ABI for existing code, so this is fixed
by adding new layer types and deprecating the old ones.

Also, we use the new layer types to fix gtk3-widget-factory.

https://bugzilla.gnome.org/show_bug.cgi?id=757856
2015-11-10 08:39:47 +01:00
Matthias Clasen
a7076d1c4c text view: Add diagram to CSS documentation 2015-11-03 14:27:35 -05:00
Florian Müllner
e364ae3ea8 Use gtk_widget_set_focus_on_click() instead of deprecated setters
https://bugzilla.gnome.org/show_bug.cgi?id=757269
2015-11-03 07:44:17 -05:00
Matthias Clasen
d5ff9af94e entry, textview: Use a dedicated style class for magnifier
This will free up "osd" as an application-level style class,
and lets us style magnifiers differently.
2015-11-02 12:40:38 -05:00
Matthias Clasen
e3ef2c48d5 text view: Add css node docs 2015-10-30 21:00:01 -04:00
Matthias Clasen
844f60f1f2 text view: Convert to CSS nodes
Use subnodes for the border windows, and add children to the right
subnodes.
2015-10-30 19:49:02 -04:00
Matthias Clasen
2b998aaad7 text view: Set an element name
And it will be...drumroll...textview.
2015-10-30 18:11:13 -04:00
Matthias Clasen
95c7a539bf Don't use g_slist_next in gtktextview.c
We generally use ->next directly.
2015-10-20 06:14:57 -04:00
Carlos Garnacho
ab001d01c8 textview: Ensure magnifier popover points within widget area
Otherwise the popopver will be automatically unmapped in
_gtk_popover_update_child_visible() when the X axis (coming more
or less directly from events) goes outside the textview.
2015-10-13 02:07:24 +02:00
Carlos Garnacho
f2fd655754 textview: Look up the drop location iter on the right coordinates on DND
We are passing widget coordinates to gtk_text_view_window_to_buffer_coords()
which expects coordinates to be relative to the text window in this case.
This may result in drop coordinates being displaced if the side windows to
the top/left sides are visible and taking space, so the DnD indicator will
point to the wrong position.

This can be seen on gnome-builder and gedit when displaying line numbers.
2015-09-24 20:47:55 +02:00
Matthias Clasen
525339573e text view: Use qdata with preallocated quarks 2015-09-23 07:01:15 -04:00
Alexander Larsson
d5f1754981 gtk: Stop setting GDK_EXPOSURE_MASK on random widgets
These days exposure happens only on the native windows (generally the
toplevel window) and is propagated down recursively. The expose event
is only useful for backwards compat, and in fact, for double buffered
widgets we totally ignore the event (and non-double buffering breaks
on wayland).

So, by not setting the mask we avoid emitting these events and then
later ignoring them.

We still keep it on eventbox, fixed and layout as these are used
in weird ways that want backwards compat.
2015-09-14 11:01:13 +02:00
Christian Hergert
a3605bc557 textview: give pixelcache access to style context
This changes textview to share the style context with the pixelcache.
Doing so allows pixel cache to optimize the surface creation and use
a CAIRO_CONTENT_COLOR instead of CAIRO_CONTENT_COLOR_ALPHA when
appropriate.

https://bugzilla.gnome.org/show_bug.cgi?id=754658
2015-09-13 13:41:19 -07:00
Matthias Clasen
3526b08e01 Clean up debug features
Introduce a GTK_DEBUG_CHECK() macro and use it to check for
GTK_DEBUG flags everywhere. Also guard all such places by
2015-09-09 06:32:46 -04:00
Matthias Clasen
6457ee59be text view: Drop an unused variable 2015-09-04 02:11:41 -04:00
Matthias Clasen
1dc4eea096 text view: Improve cursor hiding logic
Same as we did for the entry in the previous commit.

Previously, we just hid the cursor if a key event was adding text,
but not when you used backspace, or Ctrl-V. Rearrange things so that
we obscure the cursor whenever the buffer contents change while we
are handling key events.

https://bugzilla.gnome.org/show_bug.cgi?id=754535
2015-09-03 14:00:27 -04:00
Sebastien Lafargue
9ad6ac0b43 GtkTextView: various scroll fixes
The purpose of this patch is to fix regressions in GtkTextView
scroll behaviours due to commit d138156.
( addition of padding and margins to the view )

Adding some padding is done by, for example, in inspector css tab with:

GtkTextView {
  padding: 10px 10px 10px 10px;
}

and adding margins, by changing one of *-margin properties
( * standing for left/right/top/bottom ) or the corresponding
accessor functions.

Understand that none of these bugs are easy to trigger.
What's happened is that a old and wrong version of the code of the code
( lost in the mean time ) was pushed.

These bugs are best seen with wrap mode set to off.

The commit 8baab8f fix a first regression.

This one is about:

- Cursor going out of the view at line ends instead of being visible
  or triggering the horizontal scroll.

- Padding not displayed correctly
  when moving cursor at beginning/end of lines

- When horizontal scroll position not at left, cursor can make scroll
  by more than one character (you need left padding to see this )

- Moving the cursor arround, the rendered text can be shitted in x or y.
  ( fixed by converting adjustment float values
  to integer before calculations )

  It can be observed by going down with the cursor more
  than the view height then going up

- retval return value of _gtk_text_view_scroll_to_iter wrong in some cases

In addition, this patch re-factor priv->top_border
in screen_dest.y calculation

Of course, all GtkTextView and GtkSourceView based app were impacted
by these bugs ( gedit for example, see bug 754147 )

https://bugzilla.gnome.org/show_bug.cgi?id=753815

https://bugzilla.gnome.org/show_bug.cgi?id=75815
2015-09-01 22:42:23 -04:00
Matthias Clasen
e50c37c8a3 Revert "GtkTextView: various scroll fixes"
This reverts commit 016f6596e7.

Pushed prematurely by accident.
2015-09-01 01:04:53 -04:00
Sebastien Lafargue
016f6596e7 GtkTextView: various scroll fixes
Due to the introduction of view's margin and padding,
some bugs in scrolling behaviour have come.
This commit fix them.

https://bugzilla.gnome.org/show_bug.cgi?id=753815
2015-08-31 23:59:34 -04:00
Christian Hergert
04f3b52c38 textview: handle NULL cursors gracefully
Under some cases, we can get NULL back for the cursor. Simply use
g_clear_object() to handle that case gracefully.
2015-08-31 05:18:29 -07:00
Sebastien Lafargue
8baab8f33d GtkTextView: fix margin/padding scroll behaviour
When you move line by line, only padding is
automaticly shown and you need to use Page key to show margin.

This commit also fix cursor going out of the screen bug.
2015-08-19 22:51:39 +02:00
Sebastien Lafargue
d1381569fd text view: add padding and margin
Add API to set top and bottom margins, and add the CSS padding
from the theme to the programmatically set margins.

https://bugzilla.gnome.org/show_bug.cgi?id=406159
2015-08-17 01:40:32 -04:00
Matthias Clasen
72d0b4d2c2 text view: Use gtk_simulate_touchscreen
Instead of repeated manual tests.
2015-07-31 13:46:34 -04:00
Matthias Clasen
5c2759af3c Use standard cursor names
This changes GTK+ to use gdk_cursor_new_from_name() with the
'standard' css names, instead of GdkCursorType.

https://bugzilla.gnome.org/show_bug.cgi?id=652085
2015-07-26 01:45:06 -04:00
Cosimo Cecchi
e6f97f10dd textview: don't call gtk_style_context_set_background() 2015-07-01 16:09:23 -07:00
Cosimo Cecchi
15908cfdf9 treeview: don't call gtk_style_context_set_background() 2015-07-01 16:09:23 -07:00
Carlos Garnacho
5c38991367 textview: Set handles' mode to "none" if showing the bubble
show_or_hide_handles() tries to disable visibility when the popover is
shown, although it triggers a bit late, and lets the handles flash briefly
if both popover and handles try to show at the same time (eg. when
pressing on the selection of a previously unfocused textview, the handles
were previously hidden, so they try to show again on focus in).
2015-06-12 13:04:45 +02:00
Carlos Garnacho
c11906fcdb textview: Perform tougher handle visibility checks after hiding the popover
The handles might fall outside the visible area, and shouldn't be shown
then. Just call gtk_text_view_update_handles() which will perform these
checks, and keep the handle conveniently hidden.

This was leading to unexpectedly visible handles (and in the
wrong/previous position, the handle code doesn't relocate the widget
it's about to hide) when "select all" was selected in the popover on
a textview needing scrollbars.
and extending the selection beyond the view above and/or below.
2015-06-12 12:45:03 +02:00
Carlos Garnacho
8d56346f9b textview: set text direction information on text handles
This makes them point to the correct place, given the theme supports
this.
2015-06-11 17:14:23 +02:00
Matthias Clasen
ac5fcc6b72 text view: Select word on double tap
This is an initial attempt at implementing double-tap selection.
2015-06-09 23:31:00 -04:00
Matthias Clasen
8ad0ef27a1 text view: Make touch selection work with mouse
The buttons on the popover where stealing the focus from the text
view on click, causing the popover to be dismissed before the action
was taken. Fix this by making the buttons not take focus on click.
2015-06-09 15:49:10 -04:00
Matthias Clasen
0a2b1b68fa text view: Always clear handles for mouse interaction
There were some cases where we left a handle visible
during mouse interaction, which is a little weird.
2015-06-08 06:56:12 -04:00
Matthias Clasen
76836dcd81 text view: Move touch selection a little further away
Otherwise, it looks cramped, and we end up under the finger.
2015-06-08 06:55:21 -04:00
Matthias Clasen
4511ff76fa text view: Use the drag-started signal
Use the drag-started signal to differentiate between drags that
move a handle and taps on a handle. Show the touch selection popup
for the latter, but not the former.
2015-06-08 06:55:21 -04:00
Matthias Clasen
32be35010f text view: Don't popup after drag selection
Don't show the touch selection popover after a selection drag
ends. Instead, the popover will be triggered by an explicit
touch on the selection.
2015-06-08 06:55:21 -04:00
Matthias Clasen
aff47da950 text view: Never show handles and popover at the same time
Hide the handles when the popover appears, and brind them back
when it disappears. This will need revisiting if we start using
the popover for mouse interaction as well, where we may not
want handles to show up.
2015-06-08 06:55:21 -04:00
Matthias Clasen
0c6205d538 text view: Shorten touch selection timeout
We don't want the popover to appear spontaneously, so eventually
the timeout may go away altogether. For now, shorten it to 50ms,
to avoid rewriting all the places where the timeout is set or
unset.
2015-06-08 06:51:08 -04:00
Matthias Clasen
6bbaa70c4c Update touch selection style
Update style for touch selection in GtkEntry and GtkTextView
according to https://wiki.gnome.org/Design/OS/Selections

Add 'Select All' to the default actions, change actions
to use icons and move the popover to the bottom. If there is
no selection, just offer to paste.
2015-06-07 01:08:33 -04:00
Carlos Garnacho
243cfd21a2 textview: Update handles after flushing scroll changes
Text insertion/pasting might trigger scroll, so we'd have to wait
until the text was revalidated and the scrolling truly happened
before we can check the new handle(s) position.
2015-06-02 17:30:09 +02:00
Carlos Garnacho
b54031d505 textview: Avoid usage of gdk_window_get_device_position() during DnD
Just use the last coordinates given on XdndPosition/drag_motion() in
order to trigger scrolling.

When running on Xwayland, the pointer position is unknown at this
stage on the X11 side, so the coordinates given here are bogus.
This change avoids both roundtrips and this situation.

https://bugzilla.gnome.org/show_bug.cgi?id=749679
2015-05-21 18:11:21 +02:00
Matthias Clasen
eea16f03f5 Stop using GDK_POINTER_MOTION_HINT_MASK in widgets
It is deprecated and no longer needed, and,as observed in
https://bugzilla.gnome.org/show_bug.cgi?id=746253 it
interferes with turning off event compression.
2015-03-22 17:33:38 -04:00
Matthias Clasen
c723eba135 text view: Avoid clang compiler warnings
Again, our habit to use -1 as an unset value for enum types.
2015-03-22 15:19:17 -04:00
Philip Withnall
4fc6880d83 gtktextview: Fix a definite use of an uninitialised variable
This seems to have been a typo in the original code, and allowed access
to virtual_cursor_y when it was uninitialised.

Found by scan-build.

https://bugzilla.gnome.org/show_bug.cgi?id=712760
2015-03-09 13:41:37 +00:00
Matthias Clasen
1aee4f0384 Fix a typo
commit aa1b7fab9c introduced a misuse of G_UNLIKELY in
several places. Fix all those.
2015-01-28 10:08:13 -05:00
Benjamin Otte
aa1b7fab9c css: Remove _gtk_css_style_property_changes_affect_size()
... and _gtk_css_style_property_changes_affect_font().

Replace it with _gtk_css_style_property_get_mask_affecting().
2015-01-27 05:04:34 +01:00
Nelson Benitez Leon
885b36a6d5 GtkTextView: allow to extend text selection with mouse scrollwheel
Fixes bug 710612
2015-01-10 14:36:17 -05:00
Christian Hergert
21360a453c textview: fix duplicated binding entries. use kp variants instead.
This appears to have accidentally used the normal keypresses twice instead
of the KP variants. This resulted in shift+insert pasting twice.

https://bugzilla.gnome.org/show_bug.cgi?id=742170
2014-12-31 23:27:55 -08:00
Matthias Clasen
52b3b4207f GtkTextView: disconnect the magifier on destroy
This prevents warnings that would otherwise happen when
the magifier is finalized.
2014-12-20 19:19:24 -05:00
Carlos Garnacho
51e1e3b416 textview: make magnifier size dependent on text size
The magnifier is now set enough height to show the line being currently
manipulated, which makes it just big enough to show the layout height at
that size and magnification.
2014-12-18 21:21:33 +01:00