2013-08-09 00:01:20 +00:00
|
|
|
// Aseprite UI Library
|
2021-03-19 21:57:56 +00:00
|
|
|
// Copyright (C) 2021 Igara Studio S.A.
|
2017-02-17 17:18:47 +00:00
|
|
|
// Copyright (C) 2001-2017 David Capello
|
2010-09-27 22:18:17 +00:00
|
|
|
//
|
2014-03-29 23:08:05 +00:00
|
|
|
// This file is released under the terms of the MIT license.
|
|
|
|
// Read LICENSE.txt for more information.
|
2010-03-07 18:10:48 +00:00
|
|
|
|
2012-07-09 02:24:42 +00:00
|
|
|
#ifndef UI_POPUP_WINDOW_H_INCLUDED
|
|
|
|
#define UI_POPUP_WINDOW_H_INCLUDED
|
2014-03-29 22:40:17 +00:00
|
|
|
#pragma once
|
2010-03-07 18:10:48 +00:00
|
|
|
|
2012-07-09 02:24:42 +00:00
|
|
|
#include "ui/window.h"
|
2010-03-07 18:10:48 +00:00
|
|
|
|
2012-06-18 01:02:54 +00:00
|
|
|
namespace ui {
|
|
|
|
|
2015-12-05 18:56:32 +00:00
|
|
|
class PopupWindow : public Window {
|
2012-06-18 01:02:54 +00:00
|
|
|
public:
|
2015-12-05 18:56:32 +00:00
|
|
|
enum class ClickBehavior {
|
|
|
|
DoNothingOnClick,
|
|
|
|
CloseOnClickInOtherWindow,
|
|
|
|
CloseOnClickOutsideHotRegion
|
2014-04-13 22:25:06 +00:00
|
|
|
};
|
|
|
|
|
2015-12-05 18:56:32 +00:00
|
|
|
enum class EnterBehavior {
|
|
|
|
DoNothingOnEnter,
|
|
|
|
CloseOnEnter,
|
2015-10-19 18:32:44 +00:00
|
|
|
};
|
|
|
|
|
2015-12-10 19:51:48 +00:00
|
|
|
PopupWindow(const std::string& text = "",
|
2016-12-01 18:15:16 +00:00
|
|
|
const ClickBehavior clickBehavior = ClickBehavior::CloseOnClickOutsideHotRegion,
|
|
|
|
const EnterBehavior enterBehavior = EnterBehavior::CloseOnEnter,
|
|
|
|
const bool withCloseButton = false);
|
2012-07-09 02:24:42 +00:00
|
|
|
~PopupWindow();
|
2012-06-18 01:02:54 +00:00
|
|
|
|
2015-12-17 18:46:13 +00:00
|
|
|
// Sets the hot region. This region indicates the area where the
|
|
|
|
// mouse can be located and the window will be kept open.
|
2021-03-19 21:57:56 +00:00
|
|
|
//
|
|
|
|
// The screenRegion must be specified in native screen coordinates.
|
|
|
|
void setHotRegion(const gfx::Region& screenRegion);
|
|
|
|
|
2015-12-11 15:48:11 +00:00
|
|
|
void setClickBehavior(ClickBehavior behavior);
|
|
|
|
void setEnterBehavior(EnterBehavior behavior);
|
2012-06-18 01:02:54 +00:00
|
|
|
|
|
|
|
void makeFloating();
|
|
|
|
void makeFixed();
|
|
|
|
|
|
|
|
protected:
|
2014-08-15 02:07:47 +00:00
|
|
|
bool onProcessMessage(Message* msg) override;
|
2015-01-19 23:44:47 +00:00
|
|
|
void onHitTest(HitTestEvent& ev) override;
|
2012-06-18 01:02:54 +00:00
|
|
|
|
2016-09-08 22:48:29 +00:00
|
|
|
virtual void onMakeFloating();
|
|
|
|
virtual void onMakeFixed();
|
|
|
|
|
2012-06-18 01:02:54 +00:00
|
|
|
private:
|
|
|
|
void startFilteringMessages();
|
|
|
|
void stopFilteringMessages();
|
|
|
|
|
2014-04-13 22:25:06 +00:00
|
|
|
ClickBehavior m_clickBehavior;
|
2015-10-19 18:32:44 +00:00
|
|
|
EnterBehavior m_enterBehavior;
|
2013-01-14 01:39:44 +00:00
|
|
|
gfx::Region m_hotRegion;
|
2021-03-19 21:57:56 +00:00
|
|
|
bool m_filtering = false;
|
|
|
|
bool m_fixed = false;
|
2012-06-18 01:02:54 +00:00
|
|
|
};
|
|
|
|
|
2017-02-17 17:18:47 +00:00
|
|
|
class TransparentPopupWindow : public PopupWindow {
|
|
|
|
public:
|
|
|
|
TransparentPopupWindow(ClickBehavior clickBehavior);
|
2017-08-15 13:39:06 +00:00
|
|
|
protected:
|
|
|
|
void onInitTheme(InitThemeEvent& ev) override;
|
2017-02-17 17:18:47 +00:00
|
|
|
};
|
|
|
|
|
2012-06-18 01:02:54 +00:00
|
|
|
} // namespace ui
|
2010-03-07 18:10:48 +00:00
|
|
|
|
|
|
|
#endif
|