Note that there are some explanatory texts on larger screens.

plurals
  1. POZoomable image viewer for GTKmm
    primarykey
    data
    text
    <p>I need a simple image viewer widget to display a Pixbuf, with a zoom factor that can be changed using the scroll wheel (integer factors only, nearest neighbor interpolation), zooming in should adjust the scroll position such that the current center or mouse position will be the origin. Clicking and dragging the mouse should move the surface accordingly; basically what <code>eog</code> or <code>evince</code> do.</p> <p>There was once an external <em>gtk-image-viewer</em> component for GTK2, but I haven't found anything else…</p> <p>So I tried implementing my own and this is how far I came:</p> <pre><code>struct ZoomableImage : public Gtk::Scrollable, public Gtk::DrawingArea { ZoomableImage() { auto h = get_hadjustment(); } }; </code></pre> <p>Which leads to a warning</p> <pre><code>gtk_scrollable_get_hadjustment: assertion `GTK_IS_SCROLLABLE (scrollable)' failed </code></pre> <p>I couldn't find any proper documentation about how to inherit interfaces in GTKmm, the headers hide a constructor from doxygen which is supposed to be called with the result of a base class's <code>init()</code> function?! Some examples initialize <code>Glib::ObjectBase(typeid(ZoomableImage))</code>, which only adds more errors.</p> <p>(My idea was to put my ZoomableImage in a ScrolledWindow which should provide me with H/V-adjustments, these range from 0 to the image's real height/width, in <code>on_draw</code>, I would read the adjustment's value, apply the zoom factor and draw the Pixbuf accordingly. Would this make sense?)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload