1 /*
2  *  tracker/SectionDiskMenu.h
3  *
4  *  Copyright 2009 Peter Barth
5  *
6  *  This file is part of Milkytracker.
7  *
8  *  Milkytracker is free software: you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation, either version 3 of the License, or
11  *  (at your option) any later version.
12  *
13  *  Milkytracker 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 General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with Milkytracker.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 /*
24  *  SectionDiskMenu.h
25  *  MilkyTracker
26  *
27  *  Created by Peter Barth on 08.07.05.
28  *
29  */
30 
31 #ifndef SECTIONDISKMENU__H
32 #define SECTIONDISKMENU__H
33 
34 #include "BasicTypes.h"
35 #include "SimpleVector.h"
36 #include "Event.h"
37 #include "SectionUpperLeft.h"
38 
39 class PPControl;
40 class Tracker;
41 class PPListBoxFileBrowser;
42 
43 class SectionDiskMenu : public SectionUpperLeft
44 {
45 private:
46 	enum ClassicViewStates
47 	{
48 		BrowseAll,
49 		BrowseModules,
50 		BrowseInstruments,
51 		BrowseSamples,
52 		BrowsePatterns,
53 		BrowseTracks,
54 
55 		BrowseLAST // needs to be last
56 	};
57 
58 	bool diskMenuVisible;
59 
60 	PPSimpleVector<PPControl>* normalViewControls;
61 	PPSimpleVector<PPControl>* classicViewControls;
62 	ClassicViewStates classicViewState;
63 	bool classicViewVisible;
64 
65 	bool forceClassicBrowser;
66 	bool moduleTypeAdjust;
67 	bool sortAscending;
68 	bool storePath;
69 
70 	PPControl* lastFocusedControl;
71 
72 	PPListBoxFileBrowser* listBoxFiles;
73 	class PPListBox* editFieldCurrentFile;
74 	class PPRadioGroup* currentActiveRadioGroup;
75 
76 	PPPoint radioGroupLocations[5];
77 
78 	PPSystemString* file;
79 	PPSystemString* fileFullPath;
80 	PPSystemString currentPath;
81 
82 #ifdef __LOWRES__
83 	pp_int32 lastSIPOffsetMove;
84 	PPPoint lastPatternEditorControlLocation;
85 	PPSize lastPatternEditorControlSize;
86 #endif
87 
88 	PPSize fileBrowserExtent;
89 
90 	class ColorQueryListener* colorQueryListener;
91 
92 public:
93 	SectionDiskMenu(Tracker& tracker);
94 	virtual ~SectionDiskMenu();
95 
96 	// Derived from SectionAbstract
97 	virtual pp_int32 handleEvent(PPObject* sender, PPEvent* event);
98 
init()99 	virtual void init() { SectionUpperLeft::init(); }
100 	virtual void init(pp_int32 x, pp_int32 y);
101 	virtual void show(bool bShow);
102 	virtual void update(bool repaint = true);
103 
104 	pp_int32 getCurrentSelectedSampleSaveType();
105 
106 	bool isActiveEditing();
107 	bool isFileBrowserVisible();
108 	bool fileBrowserHasFocus();
109 
110 	void setFileBrowserShowFocus(bool showFocus);
111 
112 	void selectSaveType(pp_uint32 type);
113 
114 	static pp_uint32 getDefaultConfigUInt32();
115 	pp_uint32 getConfigUInt32();
116 	void setConfigUInt32(pp_uint32 config);
117 
118 	PPSystemString getCurrentPath();
119 	void setCurrentPath(const PPSystemString& path, bool reload = true);
120 	PPString getCurrentPathASCII();
121 
setModuleTypeAdjust(bool moduleTypeAdjust)122 	void setModuleTypeAdjust(bool moduleTypeAdjust) { this->moduleTypeAdjust = moduleTypeAdjust; }
123 
isDiskMenuVisible()124 	bool isDiskMenuVisible() { return diskMenuVisible; }
125 	void resizeInstrumentContainer();
126 
127 	void setCycleFilenames(bool cycleFilenames);
128 
getListBoxFiles()129 	PPListBoxFileBrowser* getListBoxFiles() { return listBoxFiles; }
130 
131 private:
132 	void prepareSection();
133 
134 	void showNormalView(bool bShow);
135 
136 	void updateClassicView(bool repaint = true);
137 
138 	void showClassicView(bool bShow);
139 
140 	bool isNormalViewVisible();
141 	bool isClassicViewVisible();
142 
143 	void flip();
144 
145 	void updateFilenameEditFieldExtension(ClassicViewStates viewState);
146 	void updateFilenameEditField(ClassicViewStates viewState);
147 	void updateFilenameEditField(const PPSystemString& fileName);
148 	void updateFilenameEditFieldFromBrowser();
149 
150 	void handleLoadOrStep();
151 	void loadCurrentSelectedFile();
152 
153 	void showOverwriteMessageBox();
154 	void prepareSave();
155 	void saveCurrent();
156 	void showDeleteMessageBox();
157 	void deleteCurrent();
158 
159 	void updateButtonStates(bool repaint = true);
160 	void next(bool repaint = true);
161 	void prev(bool repaint = true);
162 	void parent(bool repaint = true);
163 	void root(bool repaint = true);
164 	void home(bool repaint = true);
165 	void reload(bool repaint = true);
166 
167 	void updateFilter(bool repaint = true);
168 
169 	void switchState(ClassicViewStates viewState);
170 
171 	void resizeBrowserVertically();
172 	void resizeBrowserHorizontally();
173 	void fitDirButtons();
174 
175 	PPString getKeyFromPredefPathButton(PPControl* button);
176 
177 	void assureExtension();
178 
179 	// Responder should be friend
180 	friend class DialogResponderDisk;
181 
182 	friend class Tracker;
183 };
184 
185 #endif
186