1// Aseprite UI Library
2// Copyright (C) 2019-2021 Igara Studio S.A.
3// Copyright (C) 2016 David Capello
4//
5// This file is released under the terms of the MIT license.
6// Read LICENSE.txt for more information.
7
8#ifndef UI_FIT_BOUNDS_H_INCLUDED
9#define UI_FIT_BOUNDS_H_INCLUDED
10#pragma once
11
12#include "gfx/fwd.h"
13
14#include <functional>
15
16namespace ui {
17
18 class Display;
19 class Widget;
20 class Window;
21
22 int fit_bounds(Display* display, int arrowAlign, const gfx::Rect& target, gfx::Rect& bounds);
23
24 // Fits a possible rectangle for the given window fitting it with a
25 // special logic. It works for both cases:
26 // 1. With multiple windows (so the limit is the parentDisplay screen workarea)
27 // 2. Or with one window (so the limit is the just display area)
28 //
29 // The getWidgetBounds() can be used to get other widgets positions
30 // in the "fitLogic" (the bounds will be relative to the screen or
31 // to the display depending if get_multiple_displays() is true or
32 // false).
33 void fit_bounds(const Display* parentDisplay,
34 Window* window,
35 const gfx::Rect& candidateBoundsRelativeToParentDisplay,
36 std::function<void(const gfx::Rect& workarea,
37 gfx::Rect& bounds,
38 std::function<gfx::Rect(Widget*)> getWidgetBounds)> fitLogic = nullptr);
39
40 // The "frame" is a native windows frame bounds.
41 void limit_with_workarea(Display* parentDisplay, gfx::Rect& frame);
42
43} // namespace ui
44
45#endif
46