gammasoft71 / xtd

Free open-source modern C++17 / C++20 framework to create console, GUI (forms like WinForms) and unit test applications and libraries on Microsoft Windows, Apple macOS and Linux.
https://gammasoft71.github.io/xtd
MIT License
779 stars 59 forks source link

[BUG] xtd.forms - combo_box in vertical_layout_panel produces warning on macOS #195

Closed jimorc closed 2 years ago

jimorc commented 2 years ago

Describe the bug

See the sample program below:

#include <xtd/xtd>
#include <iostream>

using namespace xtd;
using namespace xtd::forms;

class form1 : public form
{
    public:
        form1()
        {
            box.height(21);
            box.drop_down_style(combo_box_style::drop_down_list);
            box.items().push_back_range({"Item 3", "Item 4"});
//            *this << box; //  activate this line
            vlp << box;     // and comment out this line
            *this << vlp;
        }
    private:
        vertical_layout_panel vlp;
        combo_box box;
};
int main()
{
    form1 f;
    application::run(f);
    return EXIT_SUCCESS;
}

As written, the program outputs two messages on macOS when run:

...
The domain/default pair of (kCFPreferencesAnyApplication, AppleInterfaceStyle) does not exist
... This application is trying to draw a very large combo box, 32 points tall.  Vertically resizable combo boxes are not supported,
 but it happens that 10.4 and previous drew something that looked kind of sort of okay.  The art in 10.5 does not break up in a
 way that supports that drawing.  This application should be revised to stop using large combo boxes.  This warning will appear
 once per app launch.

If the line *this << box; is activated, and the line immediately below it is commented out, then only the first message is output. This holds as long as the combo_box height is set to 21 or less.

To Reproduce

Steps to reproduce the behavior:

  1. Build and execute the program. Messages as shown are printed.
  2. Activate *this << box; and comment out line below it.
  3. Build and execute the program. Only the first message is printed.

Expected behaviour

Only the first message should be printed.

Screenshots

N/A

Desktop (please complete the following information)

Additional context

N/A

Workaround

Live with it.

gammasoft71 commented 2 years ago

On macOS if the height of the combo_box is greater than 32 pixels, macOS does not draw the combo_box correctly. This will result in a display error between the border and the text of the control (see the print screen below).

When you run an application that uses a combo_box with a height greater than 32 pixels, macOS displays the following message:

"This application is trying to draw a very large combo box, 32 points tall. Vertically resizable combo boxes are not supported, but it happens that 10.4 and previous drew something that looked kind of sort of okay. The art in 10.5 does not break up in a way that supports that drawing. This application should be revised to stop using large combo boxes. This warning will appear once per app launch."

image

jimorc commented 2 years ago

Did you actually look at the description and then perform the steps to reproduce the bug? The combo_box height is set to 21, which is the largest value that does not produce the message when the combo_box is inserted directly into the form. If the combo_box is inserted into a vertical_layout_panel which is then inserted into the form, there is no combo_box height that does not result in the message being displayed. Therefore, this issue should be reopened. Why is the message displayed when the combo_box is inserted into a vertical_layout_panel and not when inserted directly into the form?

gammasoft71 commented 2 years ago

The vertical_layout_panel does not use the user defined size but uses the default size of the control and or the width and height of the vertical_layout_panel depending on the options. By default, the height of a combo_box is 26.

==> Output the macOS log message.

gammasoft71 commented 2 years ago

We are still in the same case

jimorc commented 2 years ago

Please accept my apologies for continuing to harp on this. In one case (combo_box inserted directly into a form), I can get rid of the message by setting the height of the combo_box appropriately. In the second case (combo_box inserted into layout_panel, which is then inserted into a form), the message is displayed. You explain this by saying that in the first case, you use the height that was set for the combo_box, but in the second case, you use the default height for the combo_box. Why not use the set height in the layout_panel as well? If you must use the default height, can the default height be set to 21 instead of 26 so that the message is not output?

gammasoft71 commented 2 years ago

My explanation is a bit confusing. But to try to be more clear. The control is setter with its default size value. Then the user defined value is applied according to the options. Hence the display of the message.

If we want to have no message at all we would have to completely revise the way layout panels work. But for the moment I prefer to keep it in “known bug". Because it doesn't prevent the framework from working.

jimorc commented 2 years ago

Thank you. A much better explanation.

gammasoft71 commented 2 years ago

After some thought, there is a very simple solution to this problem. Just set the default height value to 21 and not 26.

The default height will then be :

gammasoft71 commented 2 years ago

Thank you for insisting, it led to more reflection. Sometimes it's the most simple and obvious things that don't come out. 😃