LMMS
Loading...
Searching...
No Matches
Fl_Osc_Pane.cpp
Go to the documentation of this file.
1/*
2 ZynAddSubFX - a software synthesizer
3
4 Fl_Osc_Pane.cpp - OSC Subwindow
5 Copyright (C) 2016 Mark McCurry
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
11*/
12#include "Fl_Osc_Pane.H"
13#include "Fl_Osc_Widget.H"
14#include <cassert>
15#include <cstdio>
16
20
21
22Fl_Osc_Window::Fl_Osc_Window(int w, int h, const char *L)
23 :Fl_Double_Window(w,h,L), title_ext(NULL)
24{}
25
26void Fl_Osc_Window::init(Fl_Osc_Interface *osc_, std::string loc_)
27{
28 title_ext = new Osc_DataModel(osc_);
29 title_ext->doUpdate("/ui/title");
30#if 0
31 title_ext->callback = [this](string next) {
32 rewrite_rule = next;
33 //printf("old: %s\n", title_orig.c_str());
34 const char *orig = title_orig.c_str();
35 // 12345678901
36 const char *sub = strstr(orig, "zynaddsubfx");
37 if(!sub)
38 sub = strstr(orig, "ZynAddSubFX");
39 title_new = "";
40 while(*orig) {
41 if(orig == sub) {
42 title_new += next;
43 orig += 11;
44 } else
45 title_new += *orig++;
46 }
47 //title_new = title_orig + next;
48 this->label(title_new.c_str());
49 };
50#else
51 title_ext->callback = [this](string next) {};
52#endif
53 title_orig = label();
54
55 osc = osc_;
56 base = loc_;
57}
58
63
64std::string Fl_Osc_Window::loc(void) const
65{
66 return base;
67}
68
69static void nested_update(Fl_Group *g)
70{
71 unsigned nchildren = g->children();
72 for(unsigned i=0; i < nchildren; ++i) {
73 Fl_Widget *widget = g->child(i);
74 if(Fl_Osc_Widget *o = dynamic_cast<Fl_Osc_Widget*>(widget)) {
75 o->update();
76 } else if(Fl_Group *o = dynamic_cast<Fl_Group*>(widget)) {
78 }
79
80 }
81}
82
84{
85 unsigned nchildren = this->children();
86 for(unsigned i=0; i < nchildren; ++i) {
87 Fl_Widget *widget = this->child(i);
88 if(Fl_Osc_Widget *o = dynamic_cast<Fl_Osc_Widget*>(widget)) {
89 o->update();
90 }
91 if(dynamic_cast<Fl_Group*>(widget))
92 nested_update(dynamic_cast<Fl_Group*>(widget));
93 }
94}
95
97{
98 title_orig = label();
99 title_ext->callback(rewrite_rule);
100}
101
102static void nested_rebase(Fl_Group *g, std::string new_base)
103{
104 unsigned nchildren = g->children();
105 for(unsigned i=0; i < nchildren; ++i) {
106 Fl_Widget *widget = g->child(i);
107 if(Fl_Osc_Widget *o = dynamic_cast<Fl_Osc_Widget*>(widget)) {
108 o->rebase(new_base);
109 } else if(Fl_Osc_Group *o = dynamic_cast<Fl_Osc_Group*>(widget)) {
110 o->rebase(new_base);
111 } else if(Fl_Group *o = dynamic_cast<Fl_Group*>(widget)) {
112 nested_rebase(o, new_base);
113 }
114
115 }
116}
117
118void Fl_Osc_Window::rebase(std::string new_base)
119{
120 unsigned nchildren = this->children();
121 for(unsigned i=0; i < nchildren; ++i) {
122 Fl_Widget *widget = this->child(i);
123 if(Fl_Osc_Widget *o = dynamic_cast<Fl_Osc_Widget*>(widget)) {
124 o->rebase(new_base);
125 }
126 if(Fl_Osc_Group *o = dynamic_cast<Fl_Osc_Group*>(widget))
127 o->rebase(new_base);
128 else if(dynamic_cast<Fl_Group*>(widget))
129 nested_rebase(dynamic_cast<Fl_Group*>(widget), new_base);
130 }
131 base = new_base;
132}
133
134static Fl_Osc_Pane *find_osc_pane(Fl_Widget *root)
135{
136 if(!root)
137 return NULL;
138 Fl_Group *next = root->parent();
139
140 if(auto *p = dynamic_cast<Fl_Osc_Pane*>(next))
141 return p;
142 else
143 return find_osc_pane(next);
144}
145
146Fl_Osc_Group::Fl_Osc_Group(int x, int y, int w, int h, const char *L)
147:Fl_Group(x,y,w,h,L)
148{
149 if(auto *p = find_osc_pane(this)) {
150 osc = p->osc;
151 base = p->loc();
152 assert(osc);
153 }
154};
155
156
157std::string Fl_Osc_Group::loc(void) const
158{
159 return base + ext;
160}
161
162
163void Fl_Osc_Group::rebase(std::string new_base)
164{
165 nested_rebase(this, new_base+ext);
166 base = new_base;
167}
168
169void Fl_Osc_Group::reext(std::string new_ext)
170{
171 nested_rebase(this, base+new_ext);
172 ext = new_ext;
173}
#define NULL
Definition CarlaBridgeFormat.cpp:30
static void nested_rebase(Fl_Group *g, std::string new_base)
Definition Fl_Osc_Pane.cpp:102
static Fl_Osc_Pane * find_osc_pane(Fl_Widget *root)
Definition Fl_Osc_Pane.cpp:134
static void nested_update(Fl_Group *g)
Definition Fl_Osc_Pane.cpp:69
assert(0)
Definition Fl_Osc_Pane.H:48
virtual void rebase(std::string new_ext)
Definition Fl_Osc_Pane.cpp:163
std::string ext
Definition Fl_Osc_Pane.H:52
Fl_Osc_Group(int x, int y, int w, int h, const char *L=0)
Definition Fl_Osc_Pane.cpp:146
virtual std::string loc(void) const
Definition Fl_Osc_Pane.cpp:157
virtual void reext(std::string new_base)
Definition Fl_Osc_Pane.cpp:169
Definition Fl_Osc_Interface.h:56
Definition Fl_Osc_Pane.H:20
Fl_Osc_Pane(void)
Definition Fl_Osc_Pane.cpp:17
std::string base
Definition Fl_Osc_Pane.H:24
class Fl_Osc_Interface * osc
Definition Fl_Osc_Pane.H:23
Definition Fl_Osc_Widget.H:21
std::string rewrite_rule
Definition Fl_Osc_Pane.H:32
std::string title_new
Definition Fl_Osc_Pane.H:34
std::string title_orig
Definition Fl_Osc_Pane.H:33
~Fl_Osc_Window(void)
Definition Fl_Osc_Pane.cpp:59
Fl_Osc_Window(int w, int h, const char *L=0)
Definition Fl_Osc_Pane.cpp:22
void update()
Definition Fl_Osc_Pane.cpp:83
virtual void rebase(std::string new_base)
Definition Fl_Osc_Pane.cpp:118
virtual std::string loc(void) const
Definition Fl_Osc_Pane.cpp:64
Osc_DataModel * title_ext
Definition Fl_Osc_Pane.H:31
void init(Fl_Osc_Interface *osc_, std::string loc_)
Definition Fl_Osc_Pane.cpp:26
void update_title()
Definition Fl_Osc_Pane.cpp:96
Definition Osc_DataModel.h:19
UINT_D64 w
Definition inflate.c:942
int y
Definition inflate.c:1588
int g
Definition inflate.c:1573
register unsigned i
Definition inflate.c:1575
unsigned x[BMAX+1]
Definition inflate.c:1586
uch * p
Definition crypt.c:594
uch h[RAND_HEAD_LEN]
Definition crypt.c:459