1 // Aseprite UI Library 2 // Copyright (C) 2001-2017 David Capello 3 // 4 // This file is released under the terms of the MIT license. 5 // Read LICENSE.txt for more information. 6 7 #ifndef UI_POPUP_WINDOW_H_INCLUDED 8 #define UI_POPUP_WINDOW_H_INCLUDED 9 #pragma once 10 11 #include "ui/window.h" 12 13 namespace ui { 14 15 class PopupWindow : public Window { 16 public: 17 enum class ClickBehavior { 18 DoNothingOnClick, 19 CloseOnClickInOtherWindow, 20 CloseOnClickOutsideHotRegion 21 }; 22 23 enum class EnterBehavior { 24 DoNothingOnEnter, 25 CloseOnEnter, 26 }; 27 28 PopupWindow(const std::string& text = "", 29 const ClickBehavior clickBehavior = ClickBehavior::CloseOnClickOutsideHotRegion, 30 const EnterBehavior enterBehavior = EnterBehavior::CloseOnEnter, 31 const bool withCloseButton = false); 32 ~PopupWindow(); 33 34 // Sets the hot region. This region indicates the area where the 35 // mouse can be located and the window will be kept open. 36 void setHotRegion(const gfx::Region& region); 37 void setClickBehavior(ClickBehavior behavior); 38 void setEnterBehavior(EnterBehavior behavior); 39 40 void makeFloating(); 41 void makeFixed(); 42 43 protected: 44 bool onProcessMessage(Message* msg) override; 45 void onHitTest(HitTestEvent& ev) override; 46 47 virtual void onMakeFloating(); 48 virtual void onMakeFixed(); 49 50 private: 51 void startFilteringMessages(); 52 void stopFilteringMessages(); 53 54 ClickBehavior m_clickBehavior; 55 EnterBehavior m_enterBehavior; 56 gfx::Region m_hotRegion; 57 bool m_filtering; 58 bool m_fixed; 59 }; 60 61 class TransparentPopupWindow : public PopupWindow { 62 public: 63 TransparentPopupWindow(ClickBehavior clickBehavior); 64 protected: 65 void onInitTheme(InitThemeEvent& ev) override; 66 }; 67 68 } // namespace ui 69 70 #endif 71