ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SIDPlayer/src/prefs_window.cpp
Revision: 1.2
Committed: 2001-01-21T18:04:46Z (23 years, 3 months ago) by cebix
Branch: MAIN
Changes since 1.1: +1 -1 lines
Log Message:
- fixed compilation problems under BeOS
- updated copyright year 2000->2001

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * prefs_window.cpp - Preferences window
3     *
4 cebix 1.2 * SIDPlayer (C) Copyright 1996-2001 Christian Bauer
5 cebix 1.1 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19     */
20    
21     #include "sys.h"
22    
23     #include "prefs_window.h"
24     #include "prefs.h"
25    
26    
27     // Global variables
28     bool prefs_window_open = false;
29    
30    
31     // Message codes
32     const uint32 MSG_FILTERS = 'filt';
33     const uint32 MSG_SID_TYPE = 'sidt';
34     const uint32 MSG_EFFECT_NONE = 'enon';
35     const uint32 MSG_EFFECT_REVERB = 'ervb';
36     const uint32 MSG_EFFECT_SPATIAL = 'espt';
37    
38    
39     // Panning slider
40     class PanSlider : public BSlider {
41     public:
42     PanSlider(BRect frame, const char *name, const char *prefs) : BSlider(frame, name, NULL, NULL, -0x100, 0x100, B_TRIANGLE_THUMB), prefs_name(prefs)
43     {
44     SetHashMarks(B_HASH_MARKS_TOP);
45     SetHashMarkCount(3);
46     const rgb_color bar_color = {128, 128, 216, 0};
47     SetBarColor(bar_color);
48     SetValue(PrefsFindInt32(prefs_name));
49     }
50     virtual ~PanSlider() {}
51     virtual void SetValue(int32 value)
52     {
53     BSlider::SetValue(value);
54     PrefsReplaceInt32(prefs_name, value);
55     }
56    
57     private:
58     const char *prefs_name;
59     };
60    
61    
62     // Volume slider
63     class VolumeSlider : public BSlider {
64     public:
65     VolumeSlider(BRect frame, const char *name, const char *prefs, int32 max = 0x180) : BSlider(frame, name, NULL, NULL, 0, max), prefs_name(prefs)
66     {
67     SetHashMarks(B_HASH_MARKS_NONE);
68     const rgb_color fill_color = {128, 216, 128, 0};
69     UseFillColor(true, &fill_color);
70     SetValue(PrefsFindInt32(prefs_name));
71     }
72     virtual ~VolumeSlider() {}
73     virtual void SetValue(int32 value)
74     {
75     BSlider::SetValue(value);
76     PrefsReplaceInt32(prefs_name, value);
77     }
78    
79     private:
80     const char *prefs_name;
81     };
82    
83    
84     /*
85     * Prefs window constructor
86     */
87    
88     PrefsWindow::PrefsWindow() : BWindow(BRect(0, 0, 400, 94), "SIDPlayer Sound Control", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS)
89     {
90     rgb_color fill_color = ui_color(B_PANEL_BACKGROUND_COLOR);
91     Lock();
92     BRect b = Bounds();
93    
94     // Move window to right position
95     MoveTo(80, 80 + 124);
96    
97     // Light gray background
98     BView *top = new BView(BRect(0, 0, b.right, b.bottom), "main", B_FOLLOW_NONE, B_WILL_DRAW);
99     AddChild(top);
100     top->SetViewColor(fill_color);
101    
102     // Audio effects popup menu
103     BMenuField *menu_field;
104     BPopUpMenu *menu = new BPopUpMenu("");
105     menu_field = new BMenuField(BRect(8, 8, 180, 9), "audioeffect", "Effect", menu);
106     menu_field->SetDivider(60);
107     menu->AddItem(new BMenuItem("None", new BMessage(MSG_EFFECT_NONE)));
108     menu->AddItem(new BMenuItem("Reverb", new BMessage(MSG_EFFECT_REVERB)));
109     menu->AddItem(new BMenuItem("Spatial", new BMessage(MSG_EFFECT_SPATIAL)));
110     top->AddChild(menu_field);
111     menu->ItemAt(PrefsFindInt32("audioeffect"))->SetMarked(true);
112    
113     // Reverb feedback/delay sliders
114     BStringView *label;
115     top->AddChild(label = new BStringView(BRect(8, 32, 60, 51), "delay_title", "Delay"));
116     label->SetViewColor(fill_color);
117     top->AddChild(new VolumeSlider(BRect(60, 35, 180, 36), "delay", "revdelay", 500));
118     top->AddChild(label = new BStringView(BRect(8, 52, 60, 71), "feedback_title", "Feedback"));
119     label->SetViewColor(fill_color);
120     top->AddChild(new VolumeSlider(BRect(60, 55, 180, 56), "feedback", "revfeedback", 0x100));
121    
122     // Filter enable/disable checkbox
123     top->AddChild(filter_view = new BCheckBox(BRect(8, 75, 90, 90), "filters", "Filters", new BMessage(MSG_FILTERS)));
124     filter_view->SetViewColor(fill_color);
125     filter_view->SetValue(PrefsFindBool("filters") ? B_CONTROL_ON : B_CONTROL_OFF);
126    
127     // New SID chip checkbox
128     top->AddChild(sid_type_view = new BCheckBox(BRect(90, 75, 200, 90), "sid_type", "New SID Chip", new BMessage(MSG_SID_TYPE)));
129     sid_type_view->SetViewColor(fill_color);
130     sid_type_view->SetValue(strcmp(PrefsFindString("sidtype"), "8580") ? B_CONTROL_OFF : B_CONTROL_ON);
131    
132     // Volume/panning sliders
133     top->AddChild(label = new BStringView(BRect(190, 12, 203, 31), "v1_title", "1"));
134     label->SetViewColor(fill_color);
135     label->SetAlignment(B_ALIGN_CENTER);
136     top->AddChild(label = new BStringView(BRect(190, 32, 203, 51), "v2_title", "2"));
137     label->SetViewColor(fill_color);
138     label->SetAlignment(B_ALIGN_CENTER);
139     top->AddChild(label = new BStringView(BRect(190, 52, 203, 71), "v3_title", "3"));
140     label->SetViewColor(fill_color);
141     label->SetAlignment(B_ALIGN_CENTER);
142     top->AddChild(label = new BStringView(BRect(190, 72, 203, 91), "v4_title", "4"));
143     label->SetViewColor(fill_color);
144     label->SetAlignment(B_ALIGN_CENTER);
145    
146     top->AddChild(label = new BStringView(BRect(204, 2, 304, 15), "panning_title", "Panning"));
147     label->SetViewColor(fill_color);
148     label->SetAlignment(B_ALIGN_CENTER);
149    
150     top->AddChild(new PanSlider(BRect(204, 15, 304, 16), "pan_0", "v1pan"));
151     top->AddChild(new PanSlider(BRect(204, 35, 304, 36), "pan_1", "v2pan"));
152     top->AddChild(new PanSlider(BRect(204, 55, 304, 56), "pan_2", "v3pan"));
153     top->AddChild(new PanSlider(BRect(204, 75, 304, 76), "pan_3", "v4pan"));
154    
155     top->AddChild(label = new BStringView(BRect(309, 2, 397, 15), "volume_title", "Volume"));
156     label->SetViewColor(fill_color);
157     label->SetAlignment(B_ALIGN_CENTER);
158    
159     top->AddChild(new VolumeSlider(BRect(309, 15, 397, 16), "volume_0", "v1volume"));
160     top->AddChild(new VolumeSlider(BRect(309, 35, 397, 36), "volume_1", "v2volume"));
161     top->AddChild(new VolumeSlider(BRect(309, 55, 397, 56), "volume_2", "v3volume"));
162     top->AddChild(new VolumeSlider(BRect(309, 75, 397, 76), "volume_3", "v4volume"));
163    
164     // Show window
165     top->MakeFocus();
166     Show();
167     Unlock();
168     prefs_window_open = true;
169     }
170    
171    
172     /*
173     * Prefs window asked to quit
174     */
175    
176     bool PrefsWindow::QuitRequested(void)
177     {
178     prefs_window_open = false;
179     return true;
180     }
181    
182    
183     /*
184     * Prefs window message handler
185     */
186    
187     void PrefsWindow::MessageReceived(BMessage *msg)
188     {
189     switch (msg->what) {
190     case MSG_FILTERS:
191     PrefsReplaceBool("filters", filter_view->Value() == B_CONTROL_ON);
192     break;
193    
194     case MSG_SID_TYPE:
195     if (sid_type_view->Value() == B_CONTROL_ON)
196     PrefsReplaceString("sidtype", "8580");
197     else
198     PrefsReplaceString("sidtype", "6581");
199     break;
200    
201     case MSG_EFFECT_NONE:
202     PrefsReplaceInt32("audioeffect", 0);
203     break;
204     case MSG_EFFECT_REVERB:
205     PrefsReplaceInt32("audioeffect", 1);
206     break;
207     case MSG_EFFECT_SPATIAL:
208     PrefsReplaceInt32("audioeffect", 2);
209     break;
210     }
211     }