1 /*
2  *  tracker/SectionSamples.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  *  SectionSamples.h
25  *  MilkyTracker
26  *
27  *  Created by Peter Barth on 15.04.05.
28  *
29  */
30 
31 #ifndef SECTIONSAMPLES__H
32 #define SECTIONSAMPLES__H
33 
34 #include "BasicTypes.h"
35 #include "Event.h"
36 #include "SectionAbstract.h"
37 
38 class PPControl;
39 class SampleEditorControl;
40 
41 class SectionSamples : public SectionAbstract
42 {
43 private:
44 	PPContainer* containerEntire;
45 
46 	bool visible;
47 	SampleEditorControl* sampleEditorControl;
48 	pp_int32 currentSamplePlayNote;
49 
50 	PPSize oldInstrumentListSize;
51 	PPPoint oldInstrumentListLocation;
52 	PPSize oldSampleListSize;
53 	PPPoint oldSampleListLocation;
54 	PPSize oldInstrumentListContainerSize;
55 	PPPoint oldInstrumentListContainerLocation;
56 	PPPoint p[4];
57 
58 	bool showRangeOffsets;
59 	pp_uint32 offsetFormat;
60 
61 protected:
62 	virtual void showSection(bool bShow);
63 
64 public:
65 	SectionSamples(Tracker& tracker);
66 	virtual ~SectionSamples();
67 
68 	// PPEvent listener
69 	virtual pp_int32 handleEvent(PPObject* sender, PPEvent* event);
70 
71 	virtual void init();
72 
73 	virtual void init(pp_int32 x, pp_int32 y);
74 
75 	void realign();
76 
77 	virtual void show(bool bShow);
78 	virtual void update(bool repaint = true);
79 
80 	virtual void notifyTabSwitch();
81 
82 	void refresh(bool repaint = true);
83 	void realUpdate(bool repaint, bool force, bool reAttach);
84 	void updateSampleWindow(bool repaint = true);
85 	void updateAfterLoad();
86 
87 	SampleEditorControl* getSampleEditorControl(bool forceAttach = true);
88 
89 	void resetSampleEditor();
90 
91 	bool isEmptySample();
92 
93 	void setOffsetFormat(pp_uint32 offsetFormat);
getOffsetFormat()94 	pp_uint32 getOffsetFormat() const { return offsetFormat; }
95 	void toggleOffsetFormat();
96 
getCurrentSamplePlayNote()97 	pp_int32 getCurrentSamplePlayNote() const { return currentSamplePlayNote; }
98 
isVisible()99 	bool isVisible() const { return visible; }
100 
101 	void setOffsetText(pp_uint32 ID, pp_uint32 offset);
102 
103 private:
104 	void handleClearSample();
105 	void handleCropSample();
106 	void handleMinimizeSample();
107 	void handleConvertSampleResolution();
108 
109 	// Responder should be friend
110 	friend class DialogResponderSamples;
111 
112 	friend class Tracker;
113 };
114 
115 #endif
116