[haiku-commits] Re: haiku: hrev48491 - src/preferences/filetypes

  • From: Stephan Aßmus <superstippi@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 15 Dec 2014 13:06:45 +0100

Am 15.12.2014 12:55, schrieb Adrien Destugues:
On Mon, Dec 15, 2014 at 12:25:56PM +0100, Stephan Aßmus wrote:
Hi,

Am 15.12.2014 11:52, schrieb Adrien Destugues:
While we are at it, and since I have a similar problem in the
DataTranslations preferences: what would be the correct way to set a
minimal size to a view, so that it still takes the minimal size of the
children into account? Is the only way to override the MinSize method
then?

You mean something different from view->SetExplicitMaxSize(view->MinSize())?

You can call MinSize() or one of the others as soon as all children are
attached to a view. Or lets rephrase that - as soon as the view has all the
information for computing correct sizes. You can do anything with those
values, also computing explicit sizes as you see fit.

In the case of DataTranslations, the problem is that the window size
changes as you swithc between different translators and they are
added/removed to the view. I tried to set an arbitrary minimal size
there so:
- The window has a reasonable size and fits the screen
- Most translators can fit their settings view in the allocated space
- Should a translator need more space, the window could still be made
   bigger

But setting the explicit min size of the window doesn't allow the 3rd
item, as the size of the child view is ignored when an explicit min size
is set.

You just have to take the actual min size into account when setting the explicit min size:

  BSize size = view->MinSize();

  size.width = std::max(size.width, suggestedMinWidth);
  size.height = std::max(size.height, suggestedMinHeight);

  view->SetExplicitMinSize(size);

You just have to do this whenever the contents of the view change and that should have the effect you want on the window size. Usually, suggestedMinSize is larger than the actual min size of the translater views, for the few where it is too small, the view min size will override.

Best regards,
-Stephan


Other related posts: