picoe / Eto

Cross platform GUI framework for desktop and mobile applications in .NET
Other
3.66k stars 333 forks source link

Resizing ImageViews to a smaller size than its image on Gtk2/3 platforms does not work #912

Open Sejsel opened 6 years ago

Sejsel commented 6 years ago

In a DynamicLayout an ImageView will not allow itself to be resized to a smaller size than its image, regardless of xscale and yscale settings (which I am still not sure how exactly they are supposed to work).

Expected Behavior

An ImageView can be freely resized when the layout needs it, even to make the image smaller.

Actual Behavior

An ImageView will gladly extend itself and increase the size of the image when a form containing it is enlarged, however it will not get smaller than its image.

In addition, the behavior is different between Gtk2 and Gtk3. In Gtk3, when an ImageView is the only thing in a layout, it will actually allow itself to be resized to a smaller size.

Also, with Gtk3 the image is only correctly downsized when the image is made smaller only in one dimension. If both width and height of the ImageView are smaller than the image, it will get rendered lower than it should.

Steps to Reproduce the Problem

  1. Run the following code with Gtk2 or Gtk3 and try to make the form smaller (same behavior)
  2. Remove the AddSeparateRow method call
  3. Run the code with Gtk2 and try to make the form smaller (will not work)
  4. Run the code with Gtk3 and try to make the form smaller (will work, but wrong)

Code that Demonstrates the Problem

class TestForm : Form
{
    private TestForm()
    {
        Title = "Image scaling issue";
        var layout = new DynamicLayout();

        // This ImageView should allow itself to be resized
        // under 300x300, but it forces its minimum size
        var imageView = new ImageView();
        imageView.Image = new Bitmap(300, 300, PixelFormat.Format24bppRgb);

        // Remove the following line and the Form can be 
        // made smaller than the image on Gtk3, but not on Gtk2:
        layout.AddSeparateRow(new Label {Text = "Label"});

        layout.Add(imageView);

        Content = layout;
    }
}

Specifications

cwensley commented 6 years ago

Thanks for submitting the issue!