1 /*
2  * Hydrogen
3  * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4  *
5  * http://www.hydrogen-music.org
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY, without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  *
21  */
22 
23 #include "InstrumentRack.h"
24 #include "Skin.h"
25 #include "Widgets/Button.h"
26 #include "InstrumentEditor/InstrumentEditorPanel.h"
27 #include "SoundLibrary/SoundLibraryPanel.h"
28 
29 #include <QGridLayout>
30 
31 const char* InstrumentRack::__class_name = "InstrumentRack";
32 
InstrumentRack(QWidget * pParent)33 InstrumentRack::InstrumentRack( QWidget *pParent )
34  : QWidget( pParent )
35  , Object( __class_name )
36 {
37 	INFOLOG( "INIT" );
38 
39 	resize( 290, 405 );
40 	setMinimumSize( width(), height() );
41 	setFixedWidth( width() );
42 
43 
44 // TAB buttons
45 	QWidget *pTabButtonsPanel = new QWidget( nullptr );
46 	pTabButtonsPanel->setFixedHeight( 24 );
47 	pTabButtonsPanel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
48 
49 	// instrument editor button
50 	m_pShowInstrumentEditorBtn = new ToggleButton(
51 			pTabButtonsPanel,
52 			"/instrumentEditor/instrument_show_on.png",
53 			"/instrumentEditor/instrument_show_off.png",
54 			"/instrumentEditor/instrument_show_off.png",
55 			QSize( 130, 24 )
56 	);
57 	m_pShowInstrumentEditorBtn->setToolTip( tr( "Show Instrument editor" ) );
58 	m_pShowInstrumentEditorBtn->setText( tr( "Instrument" ) );
59 	connect( m_pShowInstrumentEditorBtn, SIGNAL( clicked( Button* ) ), this, SLOT( on_showInstrumentEditorBtnClicked() ) );
60 
61 	// show sound library button
62 	m_pShowSoundLibraryBtn = new ToggleButton(
63 			pTabButtonsPanel,
64 			"/instrumentEditor/library_show_on.png",
65 			"/instrumentEditor/library_show_off.png",
66 			"/instrumentEditor/library_show_off.png",
67 			QSize( 150, 24 )
68 	);
69 	m_pShowSoundLibraryBtn->setToolTip( tr( "Show sound library" ) );
70 	m_pShowSoundLibraryBtn->setText( tr( "Sound library" ) );
71 	connect( m_pShowSoundLibraryBtn, SIGNAL( clicked( Button* ) ), this, SLOT( on_showSoundLibraryBtnClicked() ) );
72 
73 	QHBoxLayout *pTabHBox = new QHBoxLayout();
74 	pTabHBox->setSpacing( 0 );
75 	pTabHBox->setMargin( 0 );
76 	pTabHBox->addWidget( m_pShowInstrumentEditorBtn );
77 	pTabHBox->addWidget( m_pShowSoundLibraryBtn );
78 
79 	pTabButtonsPanel->setLayout( pTabHBox );
80 
81 //~ TAB buttons
82 
83 
84 	InstrumentEditorPanel::get_instance()->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
85 
86 	m_pSoundLibraryPanel = new SoundLibraryPanel( nullptr, false );
87 
88 	// LAYOUT
89 	QGridLayout *pGrid = new QGridLayout();
90 	pGrid->setSpacing( 0 );
91 	pGrid->setMargin( 0 );
92 
93 	pGrid->addWidget( pTabButtonsPanel, 0, 0, 1, 3 );
94 	pGrid->addWidget( InstrumentEditorPanel::get_instance(), 2, 1 );
95 	pGrid->addWidget( m_pSoundLibraryPanel, 2, 1 );
96 
97 	this->setLayout( pGrid );
98 
99 	on_showInstrumentEditorBtnClicked();	// show the instrument editor as default
100 }
101 
102 
103 
~InstrumentRack()104 InstrumentRack::~InstrumentRack()
105 {
106 	INFOLOG( "DESTROY" );
107 }
108 
109 
110 
on_showSoundLibraryBtnClicked()111 void InstrumentRack::on_showSoundLibraryBtnClicked()
112 {
113 	m_pShowSoundLibraryBtn->setPressed( true );
114 	m_pShowInstrumentEditorBtn->setPressed( false );
115 
116 	m_pSoundLibraryPanel->show();
117 	InstrumentEditorPanel::get_instance()->hide();
118 }
119 
120 
121 
on_showInstrumentEditorBtnClicked()122 void InstrumentRack::on_showInstrumentEditorBtnClicked()
123 {
124 	m_pShowInstrumentEditorBtn->setPressed( true );
125 	m_pShowSoundLibraryBtn->setPressed( false );
126 
127 	InstrumentEditorPanel::get_instance()->show();
128 	m_pSoundLibraryPanel->hide();
129 }
130 
131