* 0x004C9C68 * * @param type @ * @param size.width @ * @param size.height @ * @param flags @ * @param events @ * @return */
| 561 | * @return |
| 562 | */ |
| 563 | Window* createWindow( |
| 564 | WindowType type, |
| 565 | Ui::Size size, |
| 566 | Ui::WindowFlags flags, |
| 567 | const WindowEventList& events) |
| 568 | { |
| 569 | Ui::Point position{}; |
| 570 | |
| 571 | position.x = 0; // dx |
| 572 | position.y = 30; // ax |
| 573 | if (windowFitsWithinSpace(position, size)) |
| 574 | { |
| 575 | return createWindowOnScreen(type, position, size, flags, events); |
| 576 | } |
| 577 | |
| 578 | position.x = Ui::width() - size.width; |
| 579 | position.y = 30; |
| 580 | if (windowFitsWithinSpace(position, size)) |
| 581 | { |
| 582 | return createWindowOnScreen(type, position, size, flags, events); |
| 583 | } |
| 584 | |
| 585 | position.x = 0; |
| 586 | position.y = Ui::height() - size.height - 29; |
| 587 | if (windowFitsWithinSpace(position, size)) |
| 588 | { |
| 589 | return createWindowOnScreen(type, position, size, flags, events); |
| 590 | } |
| 591 | |
| 592 | position.x = Ui::width() - size.width; |
| 593 | position.y = Ui::height() - size.height - 29; |
| 594 | if (windowFitsWithinSpace(position, size)) |
| 595 | { |
| 596 | return createWindowOnScreen(type, position, size, flags, events); |
| 597 | } |
| 598 | |
| 599 | for (const auto& w : _windows) |
| 600 | { |
| 601 | if (w.hasFlags(WindowFlags::stickToBack)) |
| 602 | { |
| 603 | continue; |
| 604 | } |
| 605 | |
| 606 | position.x = w.x + w.width + 2; |
| 607 | position.y = w.y; |
| 608 | if (windowFitsWithinSpace(position, size)) |
| 609 | { |
| 610 | return createWindowOnScreen(type, position, size, flags, events); |
| 611 | } |
| 612 | |
| 613 | position.x = w.x - size.width - 2; |
| 614 | position.y = w.y; |
| 615 | if (windowFitsWithinSpace(position, size)) |
| 616 | { |
| 617 | return createWindowOnScreen(type, position, size, flags, events); |
| 618 | } |
| 619 | |
| 620 | position.x = w.x; |