Skip to content

Commit

Permalink
New geGroupChannel widget
Browse files Browse the repository at this point in the history
  • Loading branch information
gvnnz committed May 19, 2024
1 parent d558b15 commit 3f6f108
Show file tree
Hide file tree
Showing 5 changed files with 308 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,11 @@ list(APPEND SOURCES
src/gui/elems/mainWindow/keyboard/column.cpp
src/gui/elems/mainWindow/keyboard/sampleChannel.cpp
src/gui/elems/mainWindow/keyboard/midiChannel.cpp
src/gui/elems/mainWindow/keyboard/groupChannel.cpp
src/gui/elems/mainWindow/keyboard/channel.cpp
src/gui/elems/mainWindow/keyboard/sampleChannelButton.cpp
src/gui/elems/mainWindow/keyboard/midiChannelButton.cpp
src/gui/elems/mainWindow/keyboard/groupChannelButton.cpp
src/gui/elems/config/tabMisc.cpp
src/gui/elems/config/tabMidi.cpp
src/gui/elems/config/tabAudio.cpp
Expand Down
170 changes: 170 additions & 0 deletions src/gui/elems/mainWindow/keyboard/groupChannel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/* -----------------------------------------------------------------------------
*
* Giada - Your Hardcore Loopmachine
*
* -----------------------------------------------------------------------------
*
* Copyright (C) 2010-2023 Giovanni A. Zuliani | Monocasual Laboratories
*
* This file is part of Giada - Your Hardcore Loopmachine.
*
* Giada - Your Hardcore Loopmachine 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 of the License, or (at your option) any later version.
*
* Giada - Your Hardcore Loopmachine 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 Giada - Your Hardcore Loopmachine. If not, see
* <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------- */

#include "gui/elems/mainWindow/keyboard/groupChannel.h"
#include "glue/channel.h"
#include "glue/io.h"
#include "glue/layout.h"
#include "glue/main.h"
#include "glue/storage.h"
#include "gui/dispatcher.h"
#include "gui/elems/basics/boxtypes.h"
#include "gui/elems/basics/dial.h"
#include "gui/elems/basics/imageButton.h"
#include "gui/elems/basics/menu.h"
#include "gui/elems/mainWindow/keyboard/channelProgress.h"
#include "gui/elems/mainWindow/keyboard/column.h"
#include "gui/elems/mainWindow/keyboard/groupChannelButton.h"
#include "gui/elems/mainWindow/keyboard/keyboard.h"
#include "gui/elems/midiActivity.h"
#include "gui/graphics.h"
#include "gui/ui.h"
#include "utils/gui.h"

extern giada::v::Ui* g_ui;

namespace giada::v
{
namespace
{
enum class Menu
{
ADD_SAMPLE_CHANNEL,
ADD_MIDI_CHANNEL,
EDIT_ROUTING,
RENAME_CHANNEL,
CLONE_CHANNEL,
DELETE_CHANNEL
};
} // namespace

/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

geGroupChannel::geGroupChannel(c::channel::Data d)
: geChannel(0, 0, 0, 0, d)
{
playButton = new geImageButton(graphics::channelPlayOff, graphics::channelPlayOn);
arm = new geImageButton(graphics::armOff, graphics::armOn);
mainButton = new geGroupChannelButton(m_channel);
midiActivity = new geMidiActivity();
mute = new geImageButton(graphics::muteOff, graphics::muteOn);
solo = new geImageButton(graphics::soloOff, graphics::soloOn);
fx = new geImageButton(graphics::fxOff, graphics::fxOn);
vol = new geDial(0, 0, 0, 0);

addWidget(playButton, G_GUI_UNIT);
addWidget(mainButton);
addWidget(midiActivity, 10);
addWidget(mute, G_GUI_UNIT);
addWidget(solo, G_GUI_UNIT);
addWidget(fx, G_GUI_UNIT);
addWidget(vol, G_GUI_UNIT);
end();

playButton->copy_tooltip(g_ui->getI18Text(LangMap::MAIN_CHANNEL_LABEL_PLAY));
midiActivity->copy_tooltip(g_ui->getI18Text(LangMap::MAIN_CHANNEL_LABEL_MIDIACTIVITY));
mute->copy_tooltip(g_ui->getI18Text(LangMap::MAIN_CHANNEL_LABEL_MUTE));
solo->copy_tooltip(g_ui->getI18Text(LangMap::MAIN_CHANNEL_LABEL_SOLO));
fx->copy_tooltip(g_ui->getI18Text(LangMap::MAIN_CHANNEL_LABEL_FX));
vol->copy_tooltip(g_ui->getI18Text(LangMap::MAIN_CHANNEL_LABEL_VOLUME));

fx->forceValue(m_channel.plugins.size() > 0);
fx->onClick = [this]() {
c::layout::openChannelPluginListWindow(m_channel.id);
};

playButton->when(FL_WHEN_CHANGED); // On keypress && on keyrelease
playButton->onClick = [this]() {
g_ui->dispatcher.dispatchTouch(*this, playButton->getValue());
};

mute->setToggleable(true);
mute->onClick = [this]() {
c::channel::toggleMuteChannel(m_channel.id, Thread::MAIN);
};

solo->setToggleable(true);
solo->onClick = [this]() {
c::channel::toggleSoloChannel(m_channel.id, Thread::MAIN);
};

mainButton->onClick = [this]() { openMenu(); };

vol->value(m_channel.volume);
vol->callback(cb_changeVol, (void*)this);

size(w(), h()); // Force responsiveness
}

/* -------------------------------------------------------------------------- */

void geGroupChannel::openMenu()
{
geMenu menu;

menu.addItem((ID)Menu::ADD_SAMPLE_CHANNEL, g_ui->getI18Text(LangMap::MAIN_COLUMN_BUTTON_ADDSAMPLECHANNEL));
menu.addItem((ID)Menu::ADD_MIDI_CHANNEL, g_ui->getI18Text(LangMap::MAIN_COLUMN_BUTTON_ADDMIDICHANNEL));
menu.addItem((ID)Menu::EDIT_ROUTING, g_ui->getI18Text(LangMap::MAIN_CHANNEL_MENU_EDITROUTING));
menu.addItem((ID)Menu::RENAME_CHANNEL, g_ui->getI18Text(LangMap::MAIN_CHANNEL_MENU_RENAME));
menu.addItem((ID)Menu::CLONE_CHANNEL, g_ui->getI18Text(LangMap::MAIN_CHANNEL_MENU_CLONE));
menu.addItem((ID)Menu::DELETE_CHANNEL, g_ui->getI18Text(LangMap::MAIN_CHANNEL_MENU_DELETE));

menu.onSelect = [&data = m_channel](ID id) {
switch (static_cast<Menu>(id))
{
case Menu::ADD_SAMPLE_CHANNEL:
c::channel::addChannel(data.columnIndex, ChannelType::SAMPLE);
break;
case Menu::ADD_MIDI_CHANNEL:
c::channel::addChannel(data.columnIndex, ChannelType::MIDI);
break;
case Menu::EDIT_ROUTING:
c::layout::openChannelRoutingWindow(data.id);
break;
case Menu::RENAME_CHANNEL:
c::layout::openRenameChannelWindow(data);
break;
case Menu::CLONE_CHANNEL:
c::channel::cloneChannel(data.id, data.columnIndex);
break;
case Menu::DELETE_CHANNEL:
c::channel::deleteChannel(data.id);
break;
}
};

menu.popup();
}

/* -------------------------------------------------------------------------- */

void geGroupChannel::resize(int X, int Y, int W, int H)
{
geChannel::resize(X, Y, W, H);
}
} // namespace giada::v
47 changes: 47 additions & 0 deletions src/gui/elems/mainWindow/keyboard/groupChannel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* -----------------------------------------------------------------------------
*
* Giada - Your Hardcore Loopmachine
*
* -----------------------------------------------------------------------------
*
* Copyright (C) 2010-2023 Giovanni A. Zuliani | Monocasual Laboratories
*
* This file is part of Giada - Your Hardcore Loopmachine.
*
* Giada - Your Hardcore Loopmachine 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 of the License, or (at your option) any later version.
*
* Giada - Your Hardcore Loopmachine 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 Giada - Your Hardcore Loopmachine. If not, see
* <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------- */

#ifndef GE_GROUP_CHANNEL_H
#define GE_GROUP_CHANNEL_H

#include "channel.h"
#include "glue/channel.h"

namespace giada::v
{
class geGroupChannel : public geChannel
{
public:
geGroupChannel(c::channel::Data d);

void resize(int x, int y, int w, int h) override;

private:
void openMenu();
};
} // namespace giada::v

#endif
46 changes: 46 additions & 0 deletions src/gui/elems/mainWindow/keyboard/groupChannelButton.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* -----------------------------------------------------------------------------
*
* Giada - Your Hardcore Loopmachine
*
* -----------------------------------------------------------------------------
*
* Copyright (C) 2010-2024 Giovanni A. Zuliani | Monocasual Laboratories
*
* This file is part of Giada - Your Hardcore Loopmachine.
*
* Giada - Your Hardcore Loopmachine 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 of the License, or (at your option) any later version.
*
* Giada - Your Hardcore Loopmachine 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 Giada - Your Hardcore Loopmachine. If not, see
* <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------- */

#include "gui/elems/mainWindow/keyboard/groupChannelButton.h"
#include "glue/channel.h"
#include <string>

namespace giada::v
{
geGroupChannelButton::geGroupChannelButton(const c::channel::Data& d)
: geChannelButton(0, 0, 0, 0, d)
{
}

/* -------------------------------------------------------------------------- */

void geGroupChannelButton::refresh()
{
const std::string l = m_channel.name.empty() ? "-- group --" : m_channel.name;
copy_label(l.c_str());
redraw();
}
} // namespace giada::v
43 changes: 43 additions & 0 deletions src/gui/elems/mainWindow/keyboard/groupChannelButton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* -----------------------------------------------------------------------------
*
* Giada - Your Hardcore Loopmachine
*
* -----------------------------------------------------------------------------
*
* Copyright (C) 2010-2024 Giovanni A. Zuliani | Monocasual Laboratories
*
* This file is part of Giada - Your Hardcore Loopmachine.
*
* Giada - Your Hardcore Loopmachine 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 of the License, or (at your option) any later version.
*
* Giada - Your Hardcore Loopmachine 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 Giada - Your Hardcore Loopmachine. If not, see
* <http://www.gnu.org/licenses/>.
*
* -------------------------------------------------------------------------- */

#ifndef GE_GROUP_CHANNEL_BUTTON_H
#define GE_GROUP_CHANNEL_BUTTON_H

#include "gui/elems/mainWindow/keyboard/channelButton.h"

namespace giada::v
{
class geGroupChannelButton : public geChannelButton
{
public:
geGroupChannelButton(const c::channel::Data& d);

void refresh() override;
};
} // namespace giada::v

#endif

0 comments on commit 3f6f108

Please sign in to comment.