| 835 | } |
| 836 | |
| 837 | WindowBase* Create( |
| 838 | std::unique_ptr<WindowBase>&& wp, WindowClass cls, ScreenCoordsXY pos, ScreenSize windowSize, |
| 839 | WindowFlags flags) override |
| 840 | { |
| 841 | windowSize.height += wp->getTitleBarDiffTarget(); |
| 842 | |
| 843 | if (flags.has(WindowFlag::autoPosition)) |
| 844 | { |
| 845 | if (flags.has(WindowFlag::centreScreen)) |
| 846 | { |
| 847 | pos = GetCentrePositionForNewWindow(windowSize); |
| 848 | } |
| 849 | else |
| 850 | { |
| 851 | pos = GetAutoPositionForNewWindow(windowSize); |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | windowSize.height -= wp->getTitleBarDiffTarget(); |
| 856 | |
| 857 | // Check if there are any window slots left |
| 858 | // include kWindowLimitReserved for items such as the main viewport and toolbars to not appear to be counted. |
| 859 | if (gWindowList.size() >= static_cast<size_t>(Config::Get().general.windowLimit + kWindowLimitReserved)) |
| 860 | { |
| 861 | // Close least recently used window |
| 862 | for (auto& w : gWindowList) |
| 863 | { |
| 864 | if (w->flags.has(WindowFlag::dead)) |
| 865 | continue; |
| 866 | if (!w->flags.hasAny(WindowFlag::stickToBack, WindowFlag::stickToFront, WindowFlag::noAutoClose)) |
| 867 | { |
| 868 | Close(*w.get()); |
| 869 | break; |
| 870 | } |
| 871 | } |
| 872 | } |
| 873 | |
| 874 | // Find right position to insert new window |
| 875 | auto itDestPos = gWindowList.end(); |
| 876 | if (flags.has(WindowFlag::stickToBack)) |
| 877 | { |
| 878 | for (auto it = gWindowList.begin(); it != gWindowList.end(); it++) |
| 879 | { |
| 880 | if ((*it)->flags.has(WindowFlag::dead)) |
| 881 | continue; |
| 882 | if (!((*it)->flags.has(WindowFlag::stickToBack))) |
| 883 | { |
| 884 | itDestPos = it; |
| 885 | } |
| 886 | } |
| 887 | } |
| 888 | else if (!flags.has(WindowFlag::stickToFront)) |
| 889 | { |
| 890 | for (auto it = gWindowList.rbegin(); it != gWindowList.rend(); it++) |
| 891 | { |
| 892 | if ((*it)->flags.has(WindowFlag::dead)) |
| 893 | continue; |
| 894 | if (!((*it)->flags.has(WindowFlag::stickToFront))) |
nothing calls this directly
no test coverage detected