Re: Scaling an image with Gtk2::Gdk::Pixbuf->scale



On Wed, Nov 01, 2017 at 08:10:29PM +0100, Les Trol wrote:
Ok, second intractable problem:

2. The spec also wants to detect mouse clicks on the displayed image. With this
I've barely made any progress at all.

I tried some obvious things. However, Gtk2::TextIter->get_pixbuf() only detects
mouse motion of the left half of the image (for no obvious reason).

Short answer: use 'Gtk2::TextView::get_iter_at_position' instead of '::get_iter_at_location'

The Gtk docs say: "The image will be counted as one character in character
counts...". Alas, Gtk2::TextIter->get_line_offset() seems to count it as two
characters - one for the left half of the image, one for the right half.

Long answer: the rest of that sentence reads "[and] will be represented by the Unicode 'object replacement character' 0xFFFC". So, a two-byte character, which explains all of your observed behavior. 'Gtk2::TextView::window_to_buffer_coords' returns byte coordinates and not character coordinates. When you call 'get_iter_at_location' on these coords, it returns an iter to the byte at that location (more or less), while you want an iter pointing to the character. This is what '::get_iter_at_position' provides.

Regards,
Jeremy


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