~ubuntu-branches/ubuntu/vivid/guayadeque/vivid-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
// -------------------------------------------------------------------------------- //
//	Copyright (C) 2008-2013 J.Rios
//	anonbeat@gmail.com
//
//    This Program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 3, or (at your option)
//    any later version.
//
//    This Program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program; see the file LICENSE.  If not, write to
//    the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
//    http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef TRACKEDIT_H
#define TRACKEDIT_H

#include "DbLibrary.h"
#include "LyricsPanel.h"
#include "MusicBrainz.h"
#include "RatingCtrl.h"
#include "TagInfo.h"

#include <wx/wx.h>
#include <wx/notebook.h>
#include <wx/statline.h>
#include <wx/splitter.h>

WX_DEFINE_ARRAY_PTR( wxImage *, guImagePtrArray );

extern const wxEventType guTrackEditEvent;
#define guTRACKEDIT_EVENT_MBRAINZ_TRACKS        1000

class guTrackEditor;

// -------------------------------------------------------------------------------- //
void guImagePtrArrayClean( guImagePtrArray * images );

// -------------------------------------------------------------------------------- //
class guMusicBrainzMetadataThread : public wxThread
{
  protected :
    guTrackEditor * m_TrackEditor;
    guTrack *       m_Track;

  public :
    guMusicBrainzMetadataThread( guTrackEditor * trackeditor, int trackindex );
    ~guMusicBrainzMetadataThread();

    virtual ExitCode Entry();

};

class guTrackEditorGetComboDataThread;

// -------------------------------------------------------------------------------- //
// Class guTrackEditor
// -------------------------------------------------------------------------------- //
class guTrackEditor : public wxDialog
{
  private:
    guTrackArray *                      m_Items;
    guImagePtrArray *                   m_Images;
    wxArrayString *                     m_Lyrics;
    wxArrayInt *                        m_ChangedFlags;
    int                                 m_CurItem;
    int                                 m_NextItem;
    guDbLibrary *                       m_Db;
    guMBTrackArray *                    m_MBrainzAlbums;
    guMBReleaseArray *                  m_MBrainzReleases;
    int                                 m_MBrainzCurTrack;
    int                                 m_MBrainzCurAlbum;
	wxColor                             m_NormalColor;
	wxColor                             m_ErrorColor;
    wxTimer                             m_SelectedTimer;

    void                                SetTagField( wxString &field, const wxString &newval, int &changedflags, const int flagval = guTRACK_CHANGED_DATA_TAGS );
    void                                SetTagField( int &field, const int newval, int &changedflags, const int flagval = guTRACK_CHANGED_DATA_TAGS );

  protected:
    wxSortedArrayString                 m_Artists;
    wxSortedArrayString                 m_AlbumArtists;
    wxSortedArrayString                 m_Albums;
    wxSortedArrayString                 m_Composers;
    wxSortedArrayString                 m_Genres;

    wxNotebook *                        m_MainNotebook;
    wxSplitterWindow *                  m_SongListSplitter;
    wxListBox *                         m_SongListBox;
    wxBitmapButton *                    m_MoveUpButton;
	wxBitmapButton *                    m_MoveDownButton;
    wxBitmapButton *                    m_AACopyButton;
    wxComboBox *                        m_AlbumArtistComboBox;
    bool                                m_AlbumArtistChanged;
    wxBitmapButton *                    m_ArCopyButton;
    wxComboBox *                        m_ArtistComboBox;
    bool                                m_ArtistChanged;
    wxBitmapButton *                    m_AlCopyButton;
    wxComboBox *                        m_AlbumComboBox;
    bool                                m_AlbumChanged;
    wxBitmapButton *                    m_TiCopyButton;
    wxTextCtrl *                        m_TitleTextCtrl;
    wxBitmapButton *                    m_CoCopyButton;
    wxComboBox *                        m_CompComboBox;
    bool                                m_CompChanged;
    wxBitmapButton *                    m_NuCopyButton;
    wxBitmapButton *                    m_NuOrderButton;
    wxTextCtrl *                        m_NumberTextCtrl;
    wxBitmapButton *                    m_DiCopyButton;
    wxTextCtrl *                        m_DiskTextCtrl;
    wxBitmapButton *                    m_GeCopyButton;
    wxComboBox *                        m_GenreComboBox;
    bool                                m_GenreChanged;
    wxBitmapButton *                    m_YeCopyButton;
    wxTextCtrl *                        m_YearTextCtrl;
    wxBitmapButton *                    m_RaCopyButton;
    guRating *                          m_Rating;
    wxStaticText *                      m_DetailLeftInfoStaticText;
    wxStaticText *                      m_DetailRightInfoStaticText;

    wxBitmapButton *                    m_CommentCopyButton;
    wxTextCtrl *                        m_CommentText;

    wxStaticBitmap *                    m_PictureBitmap;
    wxBitmapButton *                    m_AddPicButton;
    wxBitmapButton *                    m_DelPicButton;
    wxBitmapButton *                    m_SavePicButton;
    wxBitmapButton *                    m_SearchPicButton;
    wxBitmapButton *                    m_CopyPicButton;
    int                                 m_CurrentRating;
    int                                 m_RatingStartY;
    int                                 m_RatingStart;
    bool                                m_RatingChanged;
    wxBitmapButton *                    m_LyricReloadButton;
    wxTextCtrl *                        m_LyricArtistTextCtrl;
    wxTextCtrl *                        m_LyricTrackTextCtrl;
    wxTextCtrl *                        m_LyricsTextCtrl;

    guMusicBrainzMetadataThread *       m_MBrainzThread;
    wxMutex                             m_MBrainzThreadMutex;
    wxChoice *                          m_MBrainzAlbumChoice;
    wxBitmapButton *                    m_MBrainzAddButton;
    wxBitmapButton *                    m_MBrainzCopyButton;

	wxTextCtrl *                        m_MBQueryArtistTextCtrl;
    wxTextCtrl *                        m_MBQueryTitleTextCtrl;
    wxBitmapButton *                    m_MBQueryClearButton;
    bool                                m_MBQuerySetArtistEnabled;

	wxStaticText *                      m_MBrainzArtistStaticText;
    wxTextCtrl *                        m_MBrainzArtistTextCtrl;
    wxBitmapButton *                    m_MBrainzArCopyButton;
	wxStaticText *                      m_MBrainzAlbumArtistStaticText;
    wxTextCtrl *                        m_MBrainzAlbumArtistTextCtrl;
    wxBitmapButton *                    m_MBrainzAlArCopyButton;
    wxStaticText *                      m_MBrainzAlbumStaticText;
    wxTextCtrl *                        m_MBrainzAlbumTextCtrl;
    wxBitmapButton *                    m_MBrainzAlCopyButton;
    wxStaticText *                      m_MBrainzDateStaticText;
    wxChoice *                          m_MBrainzDateChoice;
    wxBitmapButton *                    m_MBrainzDaCopyButton;
    wxStaticText *                      m_MBrainzTitleStaticText;
    wxTextCtrl *                        m_MBrainzTitleTextCtrl;
    wxBitmapButton *                    m_MBrainzTiCopyButton;
    wxStaticText *                      m_MBrainzLengthStaticText;
    wxTextCtrl *                        m_MBrainzLengthTextCtrl;
    wxStaticText *                      m_MBrainzNumberStaticText;
    wxTextCtrl *                        m_MBrainzNumberTextCtrl;
    wxStaticText *                      m_MBrainzInfoStaticText;
    wxBitmapButton *                    m_MBrainzNuCopyButton;

    guTrackEditorGetComboDataThread *   m_GetComboDataThread;

    guLyricSearchEngine *               m_LyricSearchEngine;
    guLyricSearchContext *              m_LyricSearchContext;

    wxString                            m_LastArtist;
    wxString                            m_LastAlbumArtist;
    wxString                            m_LastAlbum;
    wxString                            m_LastComposer;
    wxString                            m_LastGenre;

    // Event handlers, overide them in your derived class
	void                                OnSongListBoxSelected( wxCommandEvent &event );
	void                                OnMoveUpBtnClick( wxCommandEvent& event );
	void                                OnMoveDownBtnClick( wxCommandEvent& event );
	void                                OnAACopyButtonClicked( wxCommandEvent &event );
	void                                OnArCopyButtonClicked( wxCommandEvent &event );
	void                                OnAlCopyButtonClicked( wxCommandEvent &event );
	void                                OnTiCopyButtonClicked( wxCommandEvent &event );
	void                                OnCoCopyButtonClicked( wxCommandEvent &event );
	void                                OnNuCopyButtonClicked( wxCommandEvent &event );
	void                                OnNuOrderButtonClicked( wxCommandEvent &event );
	void                                OnDiCopyButtonClicked( wxCommandEvent &event );
	void                                OnGeCopyButtonClicked( wxCommandEvent &event );
	void                                OnYeCopyButtonClicked( wxCommandEvent &event );
	void                                OnRaCopyButtonClicked( wxCommandEvent &event );

	void                                OnArtistTextChanged( wxCommandEvent& event );
	void                                OnAlbumArtistTextChanged( wxCommandEvent& event );
	void                                OnAlbumTextChanged( wxCommandEvent& event );
	void                                OnComposerTextChanged( wxCommandEvent& event );
	void                                OnGenreTextChanged( wxCommandEvent& event );

	void                                OnCommentCopyButtonClicked( wxCommandEvent &event );


	void                                OnMBrainzAddButtonClicked( wxCommandEvent &event );
	void                                OnMBrainzAlbumsFound( wxCommandEvent &event );
	void                                OnMBrainzAlbumChoiceSelected( wxCommandEvent &event );

	void                                OnMBrainzCopyButtonClicked( wxCommandEvent &event );

	void                                OnMBrainzArtistCopyButtonClicked( wxCommandEvent& event );
	void                                OnMBrainzAlbumArtistCopyButtonClicked( wxCommandEvent& event );
	void                                OnMBrainzAlbumCopyButtonClicked( wxCommandEvent& event );
	void                                OnMBrainzDateCopyButtonClicked( wxCommandEvent& event );
	void                                OnMBrainzTitleCopyButtonClicked( wxCommandEvent& event );
	void                                OnMBrainzNumberCopyButtonClicked( wxCommandEvent& event );
	void                                OnMBQueryClearButtonClicked( wxCommandEvent &event );
	void                                OnMBQueryTextCtrlChanged( wxCommandEvent& event );

	void                                OnOKButton( wxCommandEvent& event );
	void                                ReadItemData( void );
	void                                WriteItemData( void );

	void                                SongListSplitterOnIdle( wxIdleEvent& );

	void                                RefreshImage( void );
	void                                OnAddImageClicked( wxCommandEvent &event );
	void                                OnDelImageClicked( wxCommandEvent &event );
	void                                OnSaveImageClicked( wxCommandEvent &event );
	void                                OnSearchImageClicked( wxCommandEvent &event );
	void                                OnCopyImageClicked( wxCommandEvent &event );

	void                                OnRatingChanged( guRatingEvent &event );

	void                                FinishedMusicBrainzSearch( void );
    int                                 FindMBrainzReleaseId( const wxString releaseid );
	void                                UpdateMBrainzTrackInfo( void );
    int                                 CheckTracksLengths( guMBTrackArray * mbtracks, guTrackArray * tracks );

	void                                OnTextUpdated( wxCommandEvent& event );
	void                                OnSearchLyrics( wxCommandEvent &event );
	void                                OnDownloadedLyric( wxCommandEvent &event );

	void                                MBCheckCountAndLengths( void );

	void                                OnPageChanged( wxNotebookEvent &event );

	void                                UpdateArtists( void ) { wxCommandEvent Event( wxEVT_COMMAND_TEXT_UPDATED ); wxPostEvent( m_ArtistComboBox, Event ); }
	void                                UpdateAlbumArtists( void ) { wxCommandEvent Event( wxEVT_COMMAND_TEXT_UPDATED ); wxPostEvent( m_AlbumArtistComboBox, Event ); }
	void                                UpdateAlbums( void ) { wxCommandEvent Event( wxEVT_COMMAND_TEXT_UPDATED ); wxPostEvent( m_AlbumComboBox, Event ); }
	void                                UpdateComposers( void ) { wxCommandEvent Event( wxEVT_COMMAND_TEXT_UPDATED ); wxPostEvent( m_CompComboBox, Event ); }
	void                                UpdateGenres( void ) { wxCommandEvent Event( wxEVT_COMMAND_TEXT_UPDATED ); wxPostEvent( m_GenreComboBox, Event ); }

	void                                OnSelectTimeout( wxTimerEvent &event );

public:
    guTrackEditor( wxWindow * parent, guDbLibrary * db,
            guTrackArray * songs, guImagePtrArray * images, wxArrayString * lyrics, wxArrayInt * changedflags );
    ~guTrackEditor();

    friend class guMusicBrainzMetadataThread;
    friend class guTrackEditorGetComboDataThread;
};

// -------------------------------------------------------------------------------- //
// Class guTrackEditorGetComboDataThread
// -------------------------------------------------------------------------------- //
class guTrackEditorGetComboDataThread : public wxThread
{
  protected :
    guTrackEditor *     m_TrackEditor;
    guDbLibrary *       m_Db;

    void                FillArrayStrings( wxSortedArrayString &array, const guListItems &items );

  public :
    guTrackEditorGetComboDataThread( guTrackEditor * trackedit, guDbLibrary * db );
    ~guTrackEditorGetComboDataThread();

    virtual ExitCode Entry();

};

#endif
// -------------------------------------------------------------------------------- //