1 /* -*- Mode: c++ -*- */
2 /***************************************************************************
3  *            drumkitframecontent.h
4  *
5  *  Fri Mar 24 21:49:42 CET 2017
6  *  Copyright 2017 André Nusser
7  *  andre.nusser@googlemail.com
8  ****************************************************************************/
9 
10 /*
11  *  This file is part of DrumGizmo.
12  *
13  *  DrumGizmo is free software; you can redistribute it and/or modify
14  *  it under the terms of the GNU Lesser General Public License as published by
15  *  the Free Software Foundation; either version 3 of the License, or
16  *  (at your option) any later version.
17  *
18  *  DrumGizmo is distributed in the hope that it will be useful,
19  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  *  GNU Lesser General Public License for more details.
22  *
23  *  You should have received a copy of the GNU Lesser General Public License
24  *  along with DrumGizmo; if not, write to the Free Software
25  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
26  */
27 #pragma once
28 
29 #include <settings.h>
30 
31 #include "button.h"
32 #include "label.h"
33 #include "lineedit.h"
34 #include "progressbar.h"
35 #include "widget.h"
36 #include "filebrowser.h"
37 
38 namespace GUI
39 {
40 
41 class Config;
42 
43 class BrowseFile
44 	: public Widget
45 {
46 public:
47 	BrowseFile(Widget* parent);
48 
49 	// From Widget
50 	virtual void resize(std::size_t width, std::size_t height) override;
51 
52 	std::size_t getLineEditWidth();
53 	std::size_t getButtonWidth();
54 
55 	Button& getBrowseButton();
56 	LineEdit& getLineEdit();
57 
58 private:
59 	HBoxLayout layout{this};
60 
61 	LineEdit lineedit{this};
62 	Button browse_button{this};
63 
64 	int lineedit_width;
65 	int button_width;
66 	int gap{10};
67 };
68 
69 class DrumkitframeContent
70 	: public Widget
71 {
72 public:
73 	DrumkitframeContent(Widget* parent,
74 	                    Settings& settings,
75 	                    SettingsNotifier& settings_notifier,
76 	                    Config& config);
77 
78 	// From Widget
79 	virtual void resize(std::size_t width, std::size_t height) override;
80 
81 	void kitBrowseClick();
82 	void midimapBrowseClick();
83 
84 private:
85 	void defaultPathChanged(const std::string& path);
86 
87 	void selectKitFile(const std::string& filename);
88 	void selectMapFile(const std::string& filename);
89 
90 	void setDrumKitLoadStatus(LoadStatus load_status);
91 	void setMidiMapLoadStatus(LoadStatus load_status);
92 
93 	VBoxLayout layout{this};
94 
95 	Label drumkit_caption{this};
96 	Label midimap_caption{this};
97 	BrowseFile drumkit_file{this};
98 	BrowseFile midimap_file{this};
99 	ProgressBar drumkit_file_progress{this};
100 	ProgressBar midimap_file_progress{this};
101 
102 	FileBrowser file_browser{this};
103 
104 	Settings& settings;
105 	SettingsNotifier& settings_notifier;
106 	Config& config;
107 };
108 
109 } // GUI::
110