1 /**
2  * File name: ViewState.h
3  * Project: Geonkick (A kick synthesizer)
4  *
5  * Copyright (C) 2020 Iurie Nistor <http://iuriepage.wordpress.com>
6  *
7  * This file is part of Geonkick.
8  *
9  * GeonKick is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */
23 
24 #ifndef GEONGKICK_VIEW_STATE_H
25 #define GEONGKICK_VIEW_STATE_H
26 
27 #include "globals.h"
28 #include "geonkick_api.h"
29 #include "envelope.h"
30 
31 #include <RkObject.h>
32 
33 class ViewState: public RkObject {
34  public:
35         enum class View : int {
36                 Controls = 0,
37                 Kit      = 1,
38                 Presets  = 2,
39                 Samples  = 3
40         };
41 
42         using Oscillator = GeonkickApi::OscillatorType;
43 
44         ViewState(RkObject *parent);
45         RK_DECL_ACT(mainViewChanged,
46                     mainViewChanged(ViewState::View view),
47                     RK_ARG_TYPE(ViewState::View),
48                     RK_ARG_VAL(view));
49         RK_DECL_ACT(samplesBrowserPathChanged,
50                     samplesBrowserPathChanged(const std::string &path),
51                     RK_ARG_TYPE(const std::string&),
52                     RK_ARG_VAL(path));
53         RK_DECL_ACT(samplesBrowserOscChanged,
54                     samplesBrowserOscChanged(ViewState::Oscillator osc),
55                     RK_ARG_TYPE(ViewState::Oscillator),
56                     RK_ARG_VAL(osc));
57         RK_DECL_ACT(envelopeCategoryChanged,
58                     envelopeCategoryChanged(Envelope::Category category),
59                     RK_ARG_TYPE(Envelope::Category),
60                     RK_ARG_VAL(category));
61         RK_DECL_ACT(envelopeTypeChanged,
62                     envelopeTypeChanged(Envelope::Type envelope),
63                     RK_ARG_TYPE(Envelope::Type),
64                     RK_ARG_VAL(envelope));
65         RK_DECL_ACT(envelopeChanged,
66                     envelopeChanged(Envelope::Category category, Envelope::Type envelope),
67                     RK_ARG_TYPE(Envelope::Category, Envelope::Type),
68                     RK_ARG_VAL(category, envelope));
69 
70 
71         ViewState::View getMainView() const;
72         void setMainView(ViewState::View view);
73         void setSamplesBrowserPath(const std::string &path);
74         void setSamplesBrowserPreviewFile(const std::string &file);
75         std::string samplesBrowserPath() const;
76         std::string samplesBrowserPreviewFile() const;
77         void setSamplesBrowserOscillator(Oscillator osc);
78         Oscillator samplesBrowserOscillator() const;
79         void setEnvelope(Envelope::Category category, Envelope::Type envelope);
80         void setEnvelopeCategory(Envelope::Category category);
81         Envelope::Category getEnvelopeCategory() const;
82         void setEnvelopeType(Envelope::Type envelope);
83         Envelope::Type getEnvelopeType() const;
84 
85  private:
86         struct SamplesBrowser {
87                 std::string currentDirectory;
88                 std::string previewFile;
89                 Oscillator oscillator;
90         };
91 
92         ViewState::View mainView;
93         SamplesBrowser samplesBrowser;
94         Envelope::Type envelopeType;
95         Envelope::Category envelopeCategory;
96 };
97 
98 #endif // GEONGKICK_VIEW_STATE_H
99