[gnome-builder] source-view: improve scroll-offset with large value
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] source-view: improve scroll-offset with large value
- Date: Tue, 7 Apr 2015 22:13:46 +0000 (UTC)
commit 6a03f3e9ccce55410b3a993297d7a1d9c7605275
Author: Christian Hergert <christian hergert me>
Date: Tue Apr 7 15:13:40 2015 -0700
source-view: improve scroll-offset with large value
Setting a scroll offset of 999 should keep the current line pinned to the
center of the screen when possible. We had some strange situations where
we would actually move a little bit which was jarring.
This doesn't get at the root of the issue, but it does mitigate it enough
to be much more useful.
libide/ide-source-view.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 2d1ec7f..afacf34 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -6410,6 +6410,7 @@ ide_source_view_scroll_to_iter (IdeSourceView *self,
GdkRectangle iter_rect;
gdouble yvalue;
gdouble xvalue;
+ gdouble orig_yalign;
gint xoffset;
gint yoffset;
@@ -6474,12 +6475,28 @@ ide_source_view_scroll_to_iter (IdeSourceView *self,
* now convert those back to alignments in the real visible area, but leave
* enough space for an input character.
*/
+ orig_yalign = yalign;
xalign = xoffset / (gdouble)real_visible_rect.width;
yalign = yoffset / (gdouble)(real_visible_rect.height + priv->cached_char_height);
yvalue = iter_rect.y - (yalign * real_visible_rect.height);
xvalue = iter_rect.x - (xalign * real_visible_rect.width);
+ /*
+ * FIXME:
+ *
+ * We need to understand better why this phenomina exists.
+ *
+ * 0.0 and 1.0 at visible boundaries creates some interesting artifacts.
+ * This works around the phenomina at to ensure we are pinned inside the
+ * visible area we care about. We probably need to take this into account
+ * in the alignment calculations in a previous step.
+ */
+ if (orig_yalign == 1.0)
+ yvalue += (priv->cached_char_height / 2);
+ else if (orig_yalign == 0.0)
+ yvalue -= (priv->cached_char_height / 2);
+
frame_clock = gtk_widget_get_frame_clock (GTK_WIDGET (self));
if (animate_scroll)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]