After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 528165 - Enhance the scale operation of the screenshot image when there is no data in the tree model
Enhance the scale operation of the screenshot image when there is no data in ...
Status: RESOLVED FIXED
Product: gnome-utils
Classification: Deprecated
Component: baobab
unspecified
Other All
: Normal enhancement
: ---
Assigned To: Fabio Marzocca
gnome-utils Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-04-15 08:38 UTC by Alejandro G. Castro
Modified: 2008-05-08 18:37 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
simple patch for ringchart scaling (899 bytes, patch)
2008-04-15 17:36 UTC, Víctor Manuel Jáquez Leal
none Details | Review
scale operation enhancement (1.20 KB, patch)
2008-04-21 08:05 UTC, Víctor Manuel Jáquez Leal
none Details | Review
scale operation enhacement 3 (1.22 KB, patch)
2008-04-21 16:11 UTC, Víctor Manuel Jáquez Leal
none Details | Review

Description Alejandro G. Castro 2008-04-15 08:38:01 UTC
Please describe the problem:
Currently we are just adapting the screenshot to the place we have to paint the widget when there is no information in the tree model, we are not considering any proportion. We should scale it keeping the proportion because in other case the drawing is distorted. The code of this scaling can be found in the expose function:

      if (priv->memento != NULL)
        { 
          gint w, h;

          w = cairo_image_surface_get_width (priv->memento);
          h = cairo_image_surface_get_height (priv->memento);

          cairo_clip (cr);

          cairo_scale (cr, 
                       (gdouble) rchart->allocation.width/w,
                       (gdouble) rchart->allocation.height/h);
 
          cairo_set_source_surface (cr, 
                                    priv->memento,
                                    0, 0);
          cairo_paint (cr);
        }         

The problem is described and was pointed out in this bug:

https://bugs.edge.launchpad.net/ubuntu/+source/gnome-utils/+bug/216804


Steps to reproduce:
You can check the problem in all the versions, just resize the window when rescanning a directory. In that moment the tree model is empty and the widget stored a screenshot of the last ringschart which it is going to use to draw it with a grey transparency over it.


Actual results:


Expected results:


Does this happen every time?
Yes

Other information:
Comment 1 Víctor Manuel Jáquez Leal 2008-04-15 17:36:07 UTC
Created attachment 109324 [details] [review]
simple patch for ringchart scaling

simple patch for the scalation issue in the ringchart widget
Comment 2 Víctor Manuel Jáquez Leal 2008-04-15 17:38:30 UTC
Comment on attachment 109324 [details] [review]
simple patch for ringchart scaling

This is a first and simplistic approach to solve this bug: the scalation factor is proportional to the minimal side size.
Comment 3 Paolo Borelli 2008-04-16 07:26:04 UTC
the logic sounds correct to me. I have not checked the reusult though, so a couple of questions:
 - is the resulting drawing still centered?
 - is the sourrounding area (the part of the largest size where we don't draw anymore) all cleared and repainted so that there are no leftover artifacts?

If the answer is yes to both those questions the patch looks good to commit to me.
Comment 4 Víctor Manuel Jáquez Leal 2008-04-16 07:44:27 UTC
- No :S
- Yes

But even the main problem is not fixed. I'm sorry about this lousy patch. I was excited because it was my first one, and I didn't verify it correctly. I'll give it another try. 
Comment 5 Víctor Manuel Jáquez Leal 2008-04-21 08:05:54 UTC
Created attachment 109612 [details] [review]
scale operation enhancement

This is an improvement of the previous patch. Now the scaling operation is smooth without deformations nor clipping, as a user would expect. I think the patch is correct now.
Comment 6 Alejandro G. Castro 2008-04-21 08:15:18 UTC
Last patch apparently works well, and the patch looks good. if no one finds any problem I'm going to upload the patch. 

Thanks Víctor :-)
Comment 7 Paolo Borelli 2008-04-21 14:54:52 UTC
looks good to me, my only concern is:

+              p = MIN (rchart->allocation.width / (1.0 * w),
+                       rchart->allocation.height / (1.0 * h));


can w or h be 0 under some pathologic conditions? If yes we need to check that to avoid division by 0. 
Comment 8 Víctor Manuel Jáquez Leal 2008-04-21 16:11:57 UTC
Created attachment 109632 [details] [review]
scale operation enhacement 3

I can't foresee any scenario where the w or the h could be equal to zero. Any way, this new patch could deal with that situation preventing the division by zero.
Comment 9 Alejandro G. Castro 2008-05-08 18:37:20 UTC
Uploaded the patch to the svn, thanks Victor ;-)