11/*
2- * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3- * (C) 2020 Vladimir Sadovnikov <[email protected] > 2+ * Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
3+ * (C) 2024 Vladimir Sadovnikov <[email protected] > 44 *
55 * This file is part of lsp-tk-lib
66 * Created on: 6 июл. 2017 г.
@@ -65,6 +65,16 @@ namespace lsp
6565 F_MOUSE_IGN = 1 << 2 ,
6666 };
6767
68+ typedef struct estimation_t
69+ {
70+ LSPString text;
71+ float scaling;
72+ float fscaling;
73+ ws::size_limit_t *r;
74+ ws::font_parameters_t fp;
75+ ws::text_parameters_t tp;
76+ } estimation_t ;
77+
6878 protected:
6979 size_t nMFlags;
7080 size_t nState;
@@ -79,21 +89,24 @@ namespace lsp
7989 prop::SizeConstraints sConstraints ; // Size constraints
8090 prop::Padding sIPadding ; // Internal padding
8191 prop::WidgetPtr<Menu> sPopup ; // Popup menu
92+ lltl::parray<prop::String> vEstimations; // Estimation string
8293
8394 protected:
8495 static status_t slot_on_submit (Widget *sender, void *ptr, void *data);
8596 static status_t slot_on_before_popup (Widget *sender, void *ptr, void *data);
8697 static status_t slot_on_popup (Widget *sender, void *ptr, void *data);
8798
8899 protected:
89- virtual void size_request (ws::size_limit_t *r);
90- virtual void property_changed (Property *prop);
100+ void estimate_string_size (estimation_t *e, tk::String *s);
101+
102+ virtual void size_request (ws::size_limit_t *r) override ;
103+ virtual void property_changed (Property *prop) override ;
91104
92105 public:
93106 explicit Label (Display *dpy);
94- virtual ~Label ();
107+ virtual ~Label () override ;
95108
96- virtual status_t init ();
109+ virtual status_t init () override ;
97110
98111 public:
99112 LSP_TK_PROPERTY (TextLayout, text_layout, &sTextLayout )
@@ -108,22 +121,20 @@ namespace lsp
108121 LSP_TK_PROPERTY (WidgetPtr<Menu>, popup, &sPopup )
109122
110123 public:
111- virtual void draw (ws::ISurface *s);
112-
113- virtual status_t on_mouse_in (const ws::event_t *e);
114-
115- virtual status_t on_mouse_out (const ws::event_t *e);
116-
117- virtual status_t on_mouse_move (const ws::event_t *e);
124+ void clear_text_estimations ();
125+ tk::String *add_text_estimation ();
118126
119- virtual status_t on_mouse_down (const ws::event_t *e);
120-
121- virtual status_t on_mouse_up (const ws::event_t *e);
127+ public:
128+ virtual void draw (ws::ISurface *s) override ;
129+ virtual status_t on_mouse_in (const ws::event_t *e) override ;
130+ virtual status_t on_mouse_out (const ws::event_t *e) override ;
131+ virtual status_t on_mouse_move (const ws::event_t *e) override ;
132+ virtual status_t on_mouse_down (const ws::event_t *e) override ;
133+ virtual status_t on_mouse_up (const ws::event_t *e) override ;
122134
135+ public:
123136 virtual status_t on_before_popup (Menu *menu);
124-
125137 virtual status_t on_popup (Menu *menu);
126-
127138 virtual status_t on_submit ();
128139 };
129140
0 commit comments