[gtk+: 35/54] entry: Improve positioning of touch selection magnifier



commit d105a3a36a98d8de1f69e407a10ccdff2804def2
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jan 13 12:01:43 2014 +0100

    entry: Improve positioning of touch selection magnifier
    
    Always show completely above or below entry to avoid covering
    content, and limit horizontal position so it doesn't overflow
    to the right.

 gtk/gtkentry.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 9086824..c60bf61 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -4473,16 +4473,18 @@ gtk_entry_show_magnifier (GtkEntry *entry,
   get_icon_allocations (entry, &primary, &secondary);
 
   priv = entry->priv;
-  rect.x = CLAMP (x, 0, allocation.width);
-  rect.y = CLAMP (y, 0, allocation.height);
-  rect.width = rect.height = 1;
+  rect.x = CLAMP (x, 0, allocation.width - primary.width - secondary.width);
+  rect.width = 1;
+  rect.y = 0;
+  rect.height = allocation.height;
 
   if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL)
     rect.x += secondary.width;
   else
     rect.x += primary.width;
 
-  _gtk_magnifier_set_coords (GTK_MAGNIFIER (priv->magnifier), rect.x, rect.y);
+  _gtk_magnifier_set_coords (GTK_MAGNIFIER (priv->magnifier), rect.x,
+                             rect.y + allocation.height / 2);
   gtk_popover_set_pointing_to (GTK_POPOVER (priv->magnifier_popover),
                                &rect);
   gtk_widget_show (priv->magnifier_popover);
@@ -6465,6 +6467,7 @@ gtk_entry_handle_dragged (GtkTextHandle         *handle,
 {
   gint cursor_pos, selection_bound_pos, tmp_pos;
   GtkEntryPrivate *priv = entry->priv;
+  GtkAllocation primary, secondary;
   GtkTextHandleMode mode;
   gint *min, *max;
 
@@ -6473,6 +6476,14 @@ gtk_entry_handle_dragged (GtkTextHandle         *handle,
   cursor_pos = priv->current_pos;
   selection_bound_pos = priv->selection_bound;
   mode = _gtk_text_handle_get_mode (handle);
+
+  get_icon_allocations (entry, &primary, &secondary);
+
+  if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL)
+    x -= secondary.width;
+  else
+    x -= primary.width;
+
   tmp_pos = gtk_entry_find_position (entry, x + priv->scroll_offset);
 
   if (mode == GTK_TEXT_HANDLE_MODE_CURSOR ||


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]