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: 17 июл. 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 #include <ui/ctl/ctl.h> 23 24 namespace lsp 25 { 26 namespace ctl 27 { 28 const ctl_class_t CtlGroup::metadata = { "CtlGroup", &CtlWidget::metadata }; 29 CtlGroup(CtlRegistry * src,LSPGroup * widget)30 CtlGroup::CtlGroup(CtlRegistry *src, LSPGroup *widget): CtlWidget(src, widget) 31 { 32 pClass = &metadata; 33 } 34 ~CtlGroup()35 CtlGroup::~CtlGroup() 36 { 37 do_destroy(); 38 } 39 init()40 void CtlGroup::init() 41 { 42 CtlWidget::init(); 43 44 if (pWidget == NULL) 45 return; 46 LSPGroup *grp = static_cast<LSPGroup *>(pWidget); 47 48 // Initialize color controllers 49 sColor.init_hsl(pRegistry, grp, grp->color(), A_COLOR, A_HUE_ID, A_SAT_ID, A_LIGHT_ID); 50 sTextColor.init_basic(pRegistry, grp, grp->text_color(), A_TEXT_COLOR); 51 } 52 destroy()53 void CtlGroup::destroy() 54 { 55 CtlWidget::destroy(); 56 do_destroy(); 57 } 58 do_destroy()59 void CtlGroup::do_destroy() 60 { 61 sEmbed.destroy(); 62 } 63 set(const char * name,const char * value)64 void CtlGroup::set(const char *name, const char *value) 65 { 66 LSPGroup *grp = widget_cast<LSPGroup>(pWidget); 67 if (grp != NULL) 68 set_lc_attr(A_TEXT, grp->text(), name, value); 69 70 CtlWidget::set(name, value); 71 } 72 set(widget_attribute_t att,const char * value)73 void CtlGroup::set(widget_attribute_t att, const char *value) 74 { 75 LSPGroup *grp = widget_cast<LSPGroup>(pWidget); 76 77 switch (att) 78 { 79 case A_BORDER: 80 if (grp != NULL) 81 PARSE_INT(value, grp->set_border(__)); 82 break; 83 case A_RADIUS: 84 if (grp != NULL) 85 PARSE_INT(value, grp->set_radius(__)); 86 break; 87 case A_EMBED: 88 BIND_EXPR(sEmbed, value); 89 break; 90 default: 91 { 92 sColor.set(att, value); 93 sTextColor.set(att, value); 94 CtlWidget::set(att, value); 95 break; 96 } 97 } 98 } 99 add(CtlWidget * child)100 status_t CtlGroup::add(CtlWidget *child) 101 { 102 if (pWidget == NULL) 103 return STATUS_BAD_STATE; 104 105 LSPGroup *grp = widget_cast<LSPGroup>(pWidget); 106 return grp->add(child->widget()); 107 } 108 notify(CtlPort * port)109 void CtlGroup::notify(CtlPort *port) 110 { 111 CtlWidget::notify(port); 112 113 LSPGroup *grp = widget_cast<LSPGroup>(pWidget); 114 if (grp == NULL) 115 return; 116 117 if (sEmbed.valid()) 118 { 119 float value = sEmbed.evaluate(); 120 grp->set_embed(value >= 0.5f); 121 } 122 } 123 124 } /* namespace ctl */ 125 } /* namespace lsp */ 126