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