hydrogen 1.2.6
InstrumentRack.cpp
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2025 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program 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 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program 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 this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#include "InstrumentRack.h"
24#include "HydrogenApp.h"
25#include "CommonStrings.h"
26#include "Widgets/Button.h"
29#include "HydrogenApp.h"
30
31#include <QGridLayout>
32
34 : QWidget( pParent )
35 , Object()
36{
37
38
40
41 resize( 290, m_nMinimumHeight );
42 setMinimumSize( width(), height() );
43 setFixedWidth( width() );
44
45 QFont fontButtons( H2Core::Preferences::get_instance()->getApplicationFontFamily(), getPointSize( pPref->getFontSize() ) );
46
47// TAB buttons
48 QWidget *pTabButtonsPanel = new QWidget( nullptr );
49 pTabButtonsPanel->setFixedHeight( 24 );
50 pTabButtonsPanel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
51
52 // instrument editor button
53 m_pShowInstrumentEditorBtn = new Button( pTabButtonsPanel, QSize( 145, 24 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getInstrumentButton(), false, QSize(), tr( "Show Instrument editor" ) );
54 connect( m_pShowInstrumentEditorBtn, &QPushButton::clicked,
55 [=]() { showSoundLibrary( false ); });
56
57 // show sound library button
58 m_pShowSoundLibraryBtn = new Button( pTabButtonsPanel,QSize( 145, 24 ), Button::Type::Toggle, "", HydrogenApp::get_instance()->getCommonStrings()->getSoundLibraryButton(), false, QSize(), tr( "Show sound library" ) );
59 connect( m_pShowSoundLibraryBtn, &QPushButton::clicked,
60 [=]() { showSoundLibrary( true ); });
61
62 QHBoxLayout *pTabHBox = new QHBoxLayout();
63 pTabHBox->setSpacing( 0 );
64 pTabHBox->setContentsMargins( 0, 0, 0, 0 );
65 pTabHBox->addWidget( m_pShowInstrumentEditorBtn );
66 pTabHBox->addWidget( m_pShowSoundLibraryBtn );
67
68 pTabButtonsPanel->setLayout( pTabHBox );
69
70// ~ TAB buttons
71
72
73 InstrumentEditorPanel::get_instance()->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
74
75 m_pSoundLibraryPanel = new SoundLibraryPanel( nullptr, false );
76
77 // LAYOUT
78 QGridLayout *pGrid = new QGridLayout();
79 pGrid->setSpacing( 0 );
80 pGrid->setContentsMargins( 0, 0, 0, 0 );
81
82 pGrid->addWidget( pTabButtonsPanel, 0, 0, 1, 3 );
83 pGrid->addWidget( InstrumentEditorPanel::get_instance(), 2, 1 );
84 pGrid->addWidget( m_pSoundLibraryPanel, 2, 1 );
85
86 this->setLayout( pGrid );
87
89
90 showSoundLibrary( false );
91}
92
93
94
96{
97 INFOLOG( "DESTROY" );
98}
99
102
103 if ( changes & H2Core::Preferences::Changes::Font ) {
104 QFont fontButtons( pPref->getApplicationFontFamily(), getPointSize( pPref->getFontSize() ) );
105 m_pShowInstrumentEditorBtn->setFont( fontButtons );
106 m_pShowSoundLibraryBtn->setFont( fontButtons );
107 }
108}
109
111 if ( bShow ) {
112 m_pSoundLibraryPanel->show();
113 m_pShowSoundLibraryBtn->setChecked( true );
115 m_pShowInstrumentEditorBtn->setChecked( false );
116 }
117 else {
118 m_pSoundLibraryPanel->hide();
119 m_pShowSoundLibraryBtn->setChecked( false );
121 m_pShowInstrumentEditorBtn->setChecked( true );
122 }
123}
#define INFOLOG(x)
Definition Object.h:240
Generic Button with SVG icons or text.
Definition Button.h:60
@ Toggle
Button is set checkable.
Definition Button.h:70
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
Changes
Bitwise or-able options showing which part of the Preferences were altered using the PreferencesDialo...
@ Font
Either the font size or font family have changed.
static HydrogenApp * get_instance()
Returns the instance of HydrogenApp class.
void preferencesChanged(H2Core::Preferences::Changes changes)
Propagates a change in the Preferences through the GUI.
static InstrumentEditorPanel * get_instance()
Button * m_pShowSoundLibraryBtn
button for showing the Sound Library
InstrumentRack(QWidget *pParent)
Button * m_pShowInstrumentEditorBtn
button for showing the Instrument Editor
void showSoundLibrary(bool bShow)
Used by the #Shotlist.
void onPreferencesChanged(H2Core::Preferences::Changes changes)
SoundLibraryPanel * m_pSoundLibraryPanel
static constexpr int m_nMinimumHeight
450 - InstrumentEditor layer view + 24 - tab button
constexpr int getPointSize(H2Core::FontTheme::FontSize fontSize) const