forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup_window.h
70 lines (55 loc) · 1.77 KB
/
popup_window.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Aseprite UI Library
// Copyright (C) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef UI_POPUP_WINDOW_H_INCLUDED
#define UI_POPUP_WINDOW_H_INCLUDED
#pragma once
#include "ui/window.h"
namespace ui {
class PopupWindow : public Window {
public:
enum class ClickBehavior {
DoNothingOnClick,
CloseOnClickInOtherWindow,
CloseOnClickOutsideHotRegion
};
enum class EnterBehavior {
DoNothingOnEnter,
CloseOnEnter,
};
PopupWindow(const std::string& text = "",
const ClickBehavior clickBehavior = ClickBehavior::CloseOnClickOutsideHotRegion,
const EnterBehavior enterBehavior = EnterBehavior::CloseOnEnter,
const bool withCloseButton = false);
~PopupWindow();
// Sets the hot region. This region indicates the area where the
// mouse can be located and the window will be kept open.
void setHotRegion(const gfx::Region& region);
void setClickBehavior(ClickBehavior behavior);
void setEnterBehavior(EnterBehavior behavior);
void makeFloating();
void makeFixed();
protected:
bool onProcessMessage(Message* msg) override;
void onHitTest(HitTestEvent& ev) override;
virtual void onMakeFloating();
virtual void onMakeFixed();
private:
void startFilteringMessages();
void stopFilteringMessages();
ClickBehavior m_clickBehavior;
EnterBehavior m_enterBehavior;
gfx::Region m_hotRegion;
bool m_filtering;
bool m_fixed;
};
class TransparentPopupWindow : public PopupWindow {
public:
TransparentPopupWindow(ClickBehavior clickBehavior);
protected:
void onInitTheme(InitThemeEvent& ev) override;
};
} // namespace ui
#endif