* Decide whether a given rectangle is a good place to open a mostly visible new window. * The new window should be mostly within screen borders, and not overlap with another already * existing window (except for the main window in the background). * @param left Left edge of the rectangle * @param top Top edge of the rectangle * @param width Width of the rectangle * @param height He
| 1576 | * @return Boolean indication that the rectangle is a good place for the new window |
| 1577 | */ |
| 1578 | static bool IsGoodAutoPlace2(int left, int top, int width, int height, int toolbar_y, Point &pos) |
| 1579 | { |
| 1580 | bool rtl = _current_text_dir == TD_RTL; |
| 1581 | |
| 1582 | /* Left part of the rectangle may be at most 1/4 off-screen, |
| 1583 | * right part of the rectangle may be at most 1/2 off-screen |
| 1584 | */ |
| 1585 | if (rtl) { |
| 1586 | if (left < -(width >> 1) || left > _screen.width - (width >> 2)) return false; |
| 1587 | } else { |
| 1588 | if (left < -(width >> 2) || left > _screen.width - (width >> 1)) return false; |
| 1589 | } |
| 1590 | |
| 1591 | /* Bottom part of the rectangle may be at most 1/4 off-screen */ |
| 1592 | if (top < toolbar_y || top > _screen.height - (height >> 2)) return false; |
| 1593 | |
| 1594 | /* Make sure it is not obscured by any window. */ |
| 1595 | for (const Window *w : Window::Iterate()) { |
| 1596 | if (w->window_class == WC_MAIN_WINDOW) continue; |
| 1597 | |
| 1598 | if (left + width > w->left && |
| 1599 | w->left + w->width > left && |
| 1600 | top + height > w->top && |
| 1601 | w->top + w->height > top) { |
| 1602 | return false; |
| 1603 | } |
| 1604 | } |
| 1605 | |
| 1606 | pos.x = left; |
| 1607 | pos.y = top; |
| 1608 | return true; |
| 1609 | } |
| 1610 | |
| 1611 | /** |
| 1612 | * Find a good place for opening a new window of a given width and height. |
no outgoing calls
no test coverage detected