1 /*
2  * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3  *           (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
4  *
5  * This file is part of lsp-plugins
6  * Created on: 7 нояб. 2017 г.
7  *
8  * lsp-plugins is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * any later version.
12  *
13  * lsp-plugins is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with lsp-plugins. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef UI_TK_WIDGETS_LSPMOUNTSTUD_H_
23 #define UI_TK_WIDGETS_LSPMOUNTSTUD_H_
24 
25 namespace lsp
26 {
27     namespace tk
28     {
29         class LSPMountStud: public LSPWidget
30         {
31             public:
32                 static const w_class_t    metadata;
33 
34             protected:
35                 LSPFont             sFont;
36                 LSPString           sText;
37                 LSPColor            sColor;
38                 size_t              nAngle;
39                 size_t              nButtons;
40                 bool                bPressed;
41                 realize_t           sLogo;
42 
43             protected:
44                 static status_t slot_on_submit(LSPWidget *sender, void *ptr, void *data);
45 
46                 bool mouse_over_logo(ssize_t x, ssize_t y);
47                 void draw_screw(ISurface *s, ssize_t x, ssize_t y, float angle);
48 
49             public:
50                 explicit LSPMountStud(LSPDisplay *dpy);
51                 virtual ~LSPMountStud();
52 
53                 virtual status_t init();
54                 virtual void destroy();
55 
56             public:
font()57                 inline LSPFont     *font() { return &sFont; }
color()58                 inline LSPColor    *color() { return &sColor; }
text()59                 inline const char  *text() { return sText.get_native(); }
60                 status_t            get_text(LSPString *dst);
angle()61                 inline size_t       angle() const { return nAngle; }
62 
63             public:
64                 status_t            set_text(const char *text);
65                 status_t            set_text(const LSPString *src);
66                 void                set_angle(size_t value);
67 
68             public:
69                 virtual void        draw(ISurface *s);
70 
71                 virtual void        size_request(size_request_t *r);
72 
73                 virtual void        realize(const realize_t *r);
74 
75                 virtual status_t    on_mouse_down(const ws_event_t *e);
76 
77                 virtual status_t    on_mouse_up(const ws_event_t *e);
78 
79                 virtual status_t    on_mouse_move(const ws_event_t *e);
80 
81                 virtual status_t    on_submit();
82         };
83 
84     } /* namespace tk */
85 } /* namespace lsp */
86 
87 #endif /* UI_TK_WIDGETS_LSPMOUNTSTUD_H_ */
88