Squashed 'libraries/ZWidget/' changes from 96501b6ef..cecd34301
cecd34301 Delay load DPI-related functions bfc172f70 Added exception to some unimplemented functions 7c8d469bc Added item modifications functions 847d0e6d9 Improved keyboard navigation 8c4270e0f Dropdown can now be closed by re-selecting it 91402c31e Fix dropdown positioning in x11 and win32 02da8cdc0 Added ListView::GetPreferredWidth, ListView::GetPreferredHeight, ListView::GetMinHeight 04bf153d9 Added event subscriber system 1ce55e5da Added Dropdown Known issues: does not hide when parent widget's visibility changes git-subtree-dir: libraries/ZWidget git-subtree-split: cecd34301d369400227eb0f27bad2ab41ad756d2
This commit is contained in:
parent
d9b2c00228
commit
31c8dde32f
12 changed files with 648 additions and 13 deletions
|
|
@ -4,6 +4,7 @@
|
|||
#include <memory>
|
||||
#include <variant>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include "canvas.h"
|
||||
#include "rect.h"
|
||||
#include "colorf.h"
|
||||
|
|
@ -11,6 +12,7 @@
|
|||
|
||||
class Canvas;
|
||||
class Timer;
|
||||
class Dropdown;
|
||||
|
||||
enum class WidgetType
|
||||
{
|
||||
|
|
@ -19,6 +21,13 @@ enum class WidgetType
|
|||
Popup
|
||||
};
|
||||
|
||||
enum class WidgetEvent
|
||||
{
|
||||
VisibilityChange,
|
||||
|
||||
// TODO: add more events
|
||||
};
|
||||
|
||||
class Widget : DisplayWindowHost
|
||||
{
|
||||
public:
|
||||
|
|
@ -93,6 +102,9 @@ public:
|
|||
void ShowNormal();
|
||||
void Hide();
|
||||
|
||||
void Subscribe(Widget* subscriber);
|
||||
void Unsubscribe(Widget* subscriber);
|
||||
|
||||
void ActivateWindow();
|
||||
|
||||
void Close();
|
||||
|
|
@ -178,6 +190,8 @@ protected:
|
|||
virtual void OnLostFocus() { }
|
||||
virtual void OnEnableChanged() { }
|
||||
|
||||
virtual void Notify(Widget* source, const WidgetEvent type) { };
|
||||
|
||||
private:
|
||||
void DetachFromParent();
|
||||
|
||||
|
|
@ -201,6 +215,8 @@ private:
|
|||
void OnWindowDeactivated() override;
|
||||
void OnWindowDpiScaleChanged() override;
|
||||
|
||||
void NotifySubscribers(const WidgetEvent type);
|
||||
|
||||
WidgetType Type = {};
|
||||
|
||||
Widget* ParentObj = nullptr;
|
||||
|
|
@ -234,8 +250,12 @@ private:
|
|||
Widget(const Widget&) = delete;
|
||||
Widget& operator=(const Widget&) = delete;
|
||||
|
||||
std::unordered_set<Widget*> Subscribers;
|
||||
std::unordered_set<Widget*> Subscriptions;
|
||||
|
||||
friend class Timer;
|
||||
friend class OpenFileDialog;
|
||||
friend class OpenFolderDialog;
|
||||
friend class SaveFileDialog;
|
||||
friend class Dropdown;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue