1// Aseprite UI Library
2// Copyright (C) 2018-2020 Igara Studio S.A.
3// Copyright (C) 2001-2015 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_OVERLAY_MANAGER_H_INCLUDED
9#define UI_OVERLAY_MANAGER_H_INCLUDED
10#pragma once
11
12#include "base/ref.h"
13#include "gfx/rect.h"
14#include "ui/base.h"
15#include "ui/overlay.h"
16
17#include <vector>
18
19namespace os { class Surface; }
20
21namespace ui {
22
23 class OverlayManager {
24 friend class UISystem; // So it can call destroyInstance() from ~UISystem
25 static OverlayManager* m_singleton;
26
27 OverlayManager();
28 ~OverlayManager();
29
30 public:
31 static OverlayManager* instance();
32
33 void addOverlay(const OverlayRef& overlay);
34 void removeOverlay(const OverlayRef& overlay);
35
36 void drawOverlays();
37 void restoreOverlappedAreas(const gfx::Rect& bounds);
38
39 private:
40 static void destroyInstance();
41
42 typedef std::vector<OverlayRef> OverlayList;
43 typedef OverlayList::iterator iterator;
44
45 iterator begin() { return m_overlays.begin(); }
46 iterator end() { return m_overlays.end(); }
47
48 OverlayList m_overlays;
49 };
50
51} // namespace ui
52
53#endif
54