File: SoundTypeAndPath.cpp

package info (click to toggle)
exadrums 0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 5,728 kB
  • sloc: cpp: 2,880; xml: 165; makefile: 76
file content (80 lines) | stat: -rw-r--r-- 2,190 bytes parent folder | download
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
/*
 * SoundTypeAndPath.cpp
 *
 *  Created on: 6 Dec 2016
 *      Author: jeremy
 */

#include "SoundTypeAndPath.h"

namespace Widgets
{

	SoundTypeAndPath::SoundTypeAndPath(const std::vector<std::string>& types, const std::string& dataFolder, Gtk::FileChooserDialog* soundChooser)
	{

		this->set_hexpand(true);

		// Configure and add sound type label
		soundTypeLabel.set_halign(Gtk::Align::ALIGN_CENTER);
		this->attach(soundTypeLabel, 0, 0, 1, 1);
		soundTypeLabel.show();

		this->set_halign(Gtk::Align::ALIGN_FILL);
		this->set_column_spacing(4);

		// Populate types combobox
		for(const auto& type : types)
		{
			typesList.append(type);
		}
		typesList.set_active(0);

		// Configure and add types to widget
		typesList.set_halign(Gtk::Align::ALIGN_CENTER);
		typesList.get_entry()->set_width_chars(12);
		this->attach_next_to(typesList, soundTypeLabel, Gtk::PositionType::POS_RIGHT, 1, 1);
		typesList.show();


		// Configure and add sound label
		soundLabel.set_halign(Gtk::Align::ALIGN_CENTER);
		this->attach_next_to(soundLabel, typesList, Gtk::PositionType::POS_RIGHT, 1, 1);
		soundLabel.show();

		// Populate sounds combobox

		this->attach_next_to(soundName, soundLabel, Gtk::PositionType::POS_RIGHT, 1, 1);
		soundName.show();

		this->attach_next_to(soundChange, soundName, Gtk::PositionType::POS_RIGHT, 1, 1);
		soundChange.set_halign(Gtk::Align::ALIGN_END);
		soundChange.set_hexpand(true);
		soundChange.show();

		soundChange.signal_clicked().connect([=, this] { ShowSoundChooser(soundChooser, dataFolder); });

		this->attach_next_to(midiLabel, soundChange, Gtk::PositionType::POS_RIGHT, 1, 1);
		midiLabel.set_halign(Gtk::Align::ALIGN_END);
		midiLabel.set_hexpand(true);
		midiLabel.show();

		this->attach_next_to(midiNote, midiLabel, Gtk::PositionType::POS_RIGHT, 1, 1);
		midiNote.set_halign(Gtk::Align::ALIGN_END);
		midiNote.set_hexpand(false);
		midiNote.show();

		this->show();

		return;
	}


	void SoundTypeAndPath::ShowSoundChooser(Gtk::FileChooserDialog* soundChooser, const std::string& dataFolder)
	{
		this->changingSound = true;
		soundChooser->set_current_folder(dataFolder + "SoundBank/");
		soundChooser->show();
	}

} /* namespace Widgets */