aseprite/src/ui/popup_window.h

75 lines
1.9 KiB
C
Raw Normal View History

// Aseprite UI Library
// Copyright (C) 2021 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// 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
namespace ui {
2015-12-05 18:56:32 +00:00
class PopupWindow : public Window {
public:
2015-12-05 18:56:32 +00:00
enum class ClickBehavior {
DoNothingOnClick,
CloseOnClickInOtherWindow,
CloseOnClickOutsideHotRegion
};
2015-12-05 18:56:32 +00:00
enum class EnterBehavior {
DoNothingOnEnter,
CloseOnEnter,
};
PopupWindow(const std::string& text = "",
const ClickBehavior clickBehavior = ClickBehavior::CloseOnClickOutsideHotRegion,
const EnterBehavior enterBehavior = EnterBehavior::CloseOnEnter,
const bool withCloseButton = false);
2012-07-09 02:24:42 +00:00
~PopupWindow();
// Sets the hot region. This region indicates the area where the
// mouse can be located and the window will be kept open.
//
// The screenRegion must be specified in native screen coordinates.
void setHotRegion(const gfx::Region& screenRegion);
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 = false;
bool m_fixed = false;
};
class TransparentPopupWindow : public PopupWindow {
public:
TransparentPopupWindow(ClickBehavior clickBehavior);
protected:
void onInitTheme(InitThemeEvent& ev) override;
};
} // namespace ui
2010-03-07 18:10:48 +00:00
#endif