|
| 1 | +/* |
| 2 | + * Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 | + * (C) 2025 Vladimir Sadovnikov <[email protected]> |
| 4 | + * |
| 5 | + * This file is part of lsp-tk-lib |
| 6 | + * Created on: 2 апр. 2025 г. |
| 7 | + * |
| 8 | + * lsp-tk-lib 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-tk-lib 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-tk-lib. If not, see <https://www.gnu.org/licenses/>. |
| 20 | + */ |
| 21 | + |
| 22 | +#ifndef LSP_PLUG_IN_TK_PROP_FLAGS_BORDERROUNDING_H_ |
| 23 | +#define LSP_PLUG_IN_TK_PROP_FLAGS_BORDERROUNDING_H_ |
| 24 | + |
| 25 | +namespace lsp |
| 26 | +{ |
| 27 | + namespace tk |
| 28 | + { |
| 29 | + class Display; |
| 30 | + class Widget; |
| 31 | + |
| 32 | + class BorderRounding: public BitEnum |
| 33 | + { |
| 34 | + protected: |
| 35 | + static const prop::enum_t ENUM[]; |
| 36 | + |
| 37 | + protected: |
| 38 | + explicit BorderRounding(prop::Listener *listener = NULL): BitEnum(ENUM, listener) {}; |
| 39 | + BorderRounding(const BorderRounding &) = delete; |
| 40 | + BorderRounding(BorderRounding &&) = delete; |
| 41 | + |
| 42 | + BorderRounding & operator = (const BorderRounding &) = delete; |
| 43 | + BorderRounding & operator = (BorderRounding &&) = delete; |
| 44 | + |
| 45 | + public: |
| 46 | + inline bool left_top() const { return nValue & ws::CORNER_LEFT_TOP; } |
| 47 | + inline bool right_top() const { return nValue & ws::CORNER_RIGHT_TOP; } |
| 48 | + inline bool left_bottom() const { return nValue & ws::CORNER_LEFT_BOTTOM; } |
| 49 | + inline bool right_bottom() const { return nValue & ws::CORNER_RIGHT_BOTTOM; } |
| 50 | + inline bool left() const { return (nValue & ws::CORNERS_LEFT) == ws::CORNERS_LEFT; } |
| 51 | + inline bool right() const { return (nValue & ws::CORNERS_RIGHT) == ws::CORNERS_RIGHT; } |
| 52 | + inline bool top() const { return (nValue & ws::CORNERS_TOP) == ws::CORNERS_TOP; } |
| 53 | + inline bool bottom() const { return (nValue & ws::CORNERS_BOTTOM) == ws::CORNERS_BOTTOM; } |
| 54 | + inline bool all() const { return nValue == ws::CORNERS_ALL; } |
| 55 | + inline size_t corners() const { return nValue; } |
| 56 | + |
| 57 | + public: |
| 58 | + inline void set_corners(size_t flags) { xset_all(flags & ws::CORNERS_ALL); } |
| 59 | + inline void toggle_corners(size_t flags) { xset_all((nValue ^ flags) & ws::CORNERS_ALL); } |
| 60 | + inline void add_corners(size_t flags) { xset_all((nValue | flags) & ws::CORNERS_ALL); } |
| 61 | + inline void remove_corners(size_t flags) { xset_all((nValue & (~flags)) & ws::CORNERS_ALL); } |
| 62 | + |
| 63 | + inline void set(ws::corner_t c) { xset(c); } |
| 64 | + inline void toggle(ws::corner_t c) { xtoggle(c); } |
| 65 | + inline void add(ws::corner_t c) { xset(c); } |
| 66 | + inline void remove(ws::corner_t c) { xunset(c); } |
| 67 | + |
| 68 | + inline void set_left_top() { xset(ws::CORNER_LEFT_TOP); } |
| 69 | + inline void set_left_top(bool value) { xset(ws::CORNER_LEFT_TOP, value); } |
| 70 | + inline void set_right_top() { xset(ws::CORNER_RIGHT_TOP); } |
| 71 | + inline void set_right_top(bool value) { xset(ws::CORNER_RIGHT_TOP, value); } |
| 72 | + inline void set_left_bottom() { xset(ws::CORNER_LEFT_BOTTOM); } |
| 73 | + inline void set_left_bottom(bool value) { xset(ws::CORNER_LEFT_BOTTOM, value); } |
| 74 | + inline void set_right_bottom() { xset(ws::CORNER_RIGHT_BOTTOM); } |
| 75 | + inline void set_right_bottom(bool value) { xset(ws::CORNER_RIGHT_BOTTOM, value); } |
| 76 | + |
| 77 | + inline void set_all() { xset_all(ws::CORNERS_ALL); } |
| 78 | + inline void remove_all() { xset_all(ws::CORNERS_NONE); } |
| 79 | + inline void set_none() { xset_all(ws::CORNERS_NONE); } |
| 80 | + inline void toggle_all() { xset_all(nValue ^ ws::CORNERS_ALL); } |
| 81 | + }; |
| 82 | + |
| 83 | + namespace prop |
| 84 | + { |
| 85 | + class BorderRounding: public tk::BorderRounding |
| 86 | + { |
| 87 | + public: |
| 88 | + explicit BorderRounding(prop::Listener *listener = NULL): tk::BorderRounding(listener) {}; |
| 89 | + BorderRounding(const BorderRounding &) = delete; |
| 90 | + BorderRounding(BorderRounding &&) = delete; |
| 91 | + |
| 92 | + BorderRounding & operator = (const BorderRounding &) = delete; |
| 93 | + BorderRounding & operator = (BorderRounding &&) = delete; |
| 94 | + |
| 95 | + public: |
| 96 | + /** |
| 97 | + * Bind property with specified name to the style of linked widget |
| 98 | + */ |
| 99 | + inline status_t bind(atom_t property, Style *style) { return tk::BorderRounding::bind(property, style); } |
| 100 | + inline status_t bind(const char *property, Style *style) { return tk::BorderRounding::bind(property, style); } |
| 101 | + inline status_t bind(const LSPString *property, Style *style) { return tk::BorderRounding::bind(property, style); } |
| 102 | + |
| 103 | + /** |
| 104 | + * Unbind property |
| 105 | + */ |
| 106 | + inline status_t unbind() { return tk::BorderRounding::unbind(); }; |
| 107 | + }; |
| 108 | + |
| 109 | + } /* namespace prop */ |
| 110 | + } /* namespace tk */ |
| 111 | +} /* namespace lsp */ |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +#endif /* LSP_PLUG_IN_TK_PROP_FLAGS_BORDERROUNDING_H_ */ |
0 commit comments