Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clip Names #2293

Merged
merged 5 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/definitions_cxx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ enum class UIType : uint8_t {
SLICER,
SOUND_EDITOR,
TIMELINE,
RENAME_CLIPNAME,
NONE = 255,
};

Expand Down
130 changes: 130 additions & 0 deletions src/deluge/gui/ui/rename/rename_clipname_ui.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* Copyright © 2019-2023 Synthstrom Audible Limited
*
* This file is part of The Synthstrom Audible Deluge Firmware.
*
* The Synthstrom Audible Deluge Firmware 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.
*
* This program 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 this program.
* If not, see <https://www.gnu.org/licenses/>.
*/

#include "gui/ui/rename/rename_clipname_ui.h"
#include "definitions_cxx.hpp"
#include "extern.h"
#include "gui/l10n/l10n.h"
#include "gui/views/arranger_view.h"
#include "hid/buttons.h"
#include "hid/display/display.h"
#include "hid/led/pad_leds.h"
#include "model/output.h"
#include "model/song/song.h"

RenameClipNameUI renameClipNameUI{};

RenameClipNameUI::RenameClipNameUI() {
}

bool RenameClipNameUI::opened() {
if (display->haveOLED()) {

title = "Clip Name";
}
bool success = QwertyUI::opened();
if (!success) {
return false;
}

enteredText.set(&clip->clipName);

displayText();

drawKeys();

return true;
}

bool RenameClipNameUI::getGreyoutColsAndRows(uint32_t* cols, uint32_t* rows) {
*cols = 0b11;
return true;
}

ActionResult RenameClipNameUI::buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) {
using namespace deluge::hid::button;

// Back button
if (b == BACK) {
if (on && !currentUIMode) {
if (inCardRoutine) {
return ActionResult::REMIND_ME_OUTSIDE_CARD_ROUTINE;
}
exitUI();
}
}

// Select encoder button
else if (b == SELECT_ENC) {
if (on && !currentUIMode) {
if (inCardRoutine) {
return ActionResult::REMIND_ME_OUTSIDE_CARD_ROUTINE;
}
enterKeyPress();
}
}

else {
return ActionResult::NOT_DEALT_WITH;
}

return ActionResult::DEALT_WITH;
}

void RenameClipNameUI::enterKeyPress() {

// If actually changing it...
if (!clip->clipName.equalsCaseIrrespective(&enteredText)) {
if (currentSong->getAudioOutputFromName(&enteredText)) {
display->displayPopup(deluge::l10n::get(deluge::l10n::String::STRING_FOR_DUPLICATE_NAMES));
return;
}
}
clip->clipName.set(&enteredText);
exitUI();
}

bool RenameClipNameUI::exitUI() {
display->setNextTransitionDirection(-1);
close();
return true;
}

ActionResult RenameClipNameUI::padAction(int32_t x, int32_t y, int32_t on) {

// Main pad
if (x < kDisplayWidth) {
return QwertyUI::padAction(x, y, on);
}

// Otherwise, exit
if (on && !currentUIMode) {
if (sdRoutineLock) {
return ActionResult::REMIND_ME_OUTSIDE_CARD_ROUTINE;
}
exitUI();
}

return ActionResult::DEALT_WITH;
}

ActionResult RenameClipNameUI::verticalEncoderAction(int32_t offset, bool inCardRoutine) {
if (Buttons::isShiftButtonPressed() || Buttons::isButtonPressed(deluge::hid::button::X_ENC)) {
return ActionResult::DEALT_WITH;
}
return arrangerView.verticalEncoderAction(offset, inCardRoutine);
}
47 changes: 47 additions & 0 deletions src/deluge/gui/ui/rename/rename_clipname_ui.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright © 2019-2023 Synthstrom Audible Limited
*
* This file is part of The Synthstrom Audible Deluge Firmware.
*
* The Synthstrom Audible Deluge Firmware 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.
*
* This program 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 this program.
* If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include "gui/ui/rename/rename_ui.h"
#include "hid/button.h"

class Output;
class Clip;

class RenameClipNameUI final : public RenameUI {
public:
RenameClipNameUI();
bool opened();
ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine);
ActionResult padAction(int32_t x, int32_t y, int32_t velocity);
ActionResult verticalEncoderAction(int32_t offset, bool inCardRoutine);
bool getGreyoutColsAndRows(uint32_t* cols, uint32_t* rows);

Output* output;
Clip* clip;

// ui
UIType getUIType() { return UIType::RENAME_CLIPNAME; }
const char* getName() { return "rename_clipname_ui"; }
bool exitUI() override;

protected:
void enterKeyPress();
};

extern RenameClipNameUI renameClipNameUI;
39 changes: 38 additions & 1 deletion src/deluge/gui/ui/sound_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "gui/ui/audio_recorder.h"
#include "gui/ui/browser/sample_browser.h"
#include "gui/ui/keyboard/keyboard_screen.h"
#include "gui/ui/rename/rename_clipname_ui.h"
#include "gui/ui/rename/rename_drum_ui.h"
#include "gui/ui/rename/rename_output_ui.h"
#include "gui/ui/sample_marker_editor.h"
Expand Down Expand Up @@ -916,8 +917,18 @@ ActionResult SoundEditor::potentialShortcutPadAction(int32_t x, int32_t y, bool
goto doSetup;
}

else {
else if (x == 11 && y == 5) {

if (handleClipName()) {
ActionResult::DEALT_WITH;
}
else {
item = paramShortcutsForSounds[x][y];
goto doSetup;
}
}

else {
if (getCurrentUI() == &soundEditor && getCurrentMenuItem() == &dxParam
&& runtimeFeatureSettings.get(RuntimeFeatureSettingType::EnableDxShortcuts)
== RuntimeFeatureStateToggle::On) {
Expand Down Expand Up @@ -1641,6 +1652,32 @@ void SoundEditor::renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas)
currentMenuItem->renderOLED();
}

bool SoundEditor::handleClipName() {

Clip* clip = getCurrentClip();
Output* output = getCurrentOutput();

switch (clip->type) {

case ClipType::INSTRUMENT:

if (output->type == OutputType::SYNTH || output->type == OutputType::MIDI_OUT
|| output->type == OutputType::KIT && getRootUI()->getAffectEntire()) {
if (clip) {
renameClipNameUI.clip = clip;
openUI(&renameClipNameUI);
return true;
}
}
else {

return false;
}

default:
return false;
}
}
/*
char modelStackMemory[MODEL_STACK_MAX_SIZE];
ModelStackWithThreeMainThings* modelStack = soundEditor.getCurrentModelStack(modelStackMemory);
Expand Down
1 change: 1 addition & 0 deletions src/deluge/gui/ui/sound_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class SoundEditor final : public UI {
bool isEditingAutomationViewParam();
void handlePotentialParamMenuChange(deluge::hid::Button b, bool on, bool inCardRoutine, MenuItem* previousItem,
MenuItem* currentItem);
bool handleClipName();
};

extern SoundEditor soundEditor;
50 changes: 50 additions & 0 deletions src/deluge/gui/views/arranger_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,11 @@ void ArrangerView::editPadAction(int32_t x, int32_t y, bool on) {
if (clipInstance) {

Clip* clip = clipInstance->clip;
deluge::hid::display::OLED::clearMainImage();

drawClipName(output, clip);

deluge::hid::display::OLED::markChanged();

// If it's being recorded to, some special instructions
if (clip) {
Expand Down Expand Up @@ -1538,6 +1543,11 @@ void ArrangerView::editPadAction(int32_t x, int32_t y, bool on) {

if (x == xPressed && y == yPressedEffective) {

hid::display::OLED::clearMainImage();
ClipInstance* clipInstance = output->clipInstances.getElement(pressedClipInstanceIndex);
drawClipName(output, clipInstance->clip);
m-m-adams marked this conversation as resolved.
Show resolved Hide resolved
hid::display::OLED::markChanged();

// If no action to perform...
if (!actionOnDepress || (int32_t)(AudioEngine::audioSampleTimer - pressTime) >= kShortPressTime) {
justGetOut:
Expand All @@ -1562,6 +1572,8 @@ void ArrangerView::editPadAction(int32_t x, int32_t y, bool on) {
Action* action =
actionLogger.getNewAction(ActionType::CLIP_INSTANCE_EDIT, ActionAddition::NOT_ALLOWED);
deleteClipInstance(output, pressedClipInstanceIndex, clipInstance, action);

deluge::hid::display::OLED::clearMainImage();
goto justGetOut;
}

Expand Down Expand Up @@ -2360,6 +2372,7 @@ ActionResult ArrangerView::timerCallback() {
void ArrangerView::selectEncoderAction(int8_t offset) {

Output* output = outputsOnScreen[yPressedEffective];
hid::display::OLED::clearMainImage();

if (currentUIMode == UI_MODE_HOLDING_ARRANGEMENT_ROW) {

Expand Down Expand Up @@ -2420,6 +2433,12 @@ void ArrangerView::selectEncoderAction(int8_t offset) {

rememberInteractionWithClipInstance(yPressedEffective, clipInstance);

// Show the clipname in the arrangement if its not a white clip - extra check
if (!newClip->isArrangementOnlyClip() || !clipInstance->clip->section == 255) {
drawClipName(output, newClip);
deluge::hid::display::OLED::markChanged();
}

uiNeedsRendering(this, 1 << yPressedEffective, 0);
}

Expand Down Expand Up @@ -3290,3 +3309,34 @@ void ArrangerView::requestRendering(UI* ui, uint32_t whichMainRows, uint32_t whi
uiNeedsRendering(ui, whichMainRows, whichSideRows);
}
}

void ArrangerView::drawClipName(Output* output, Clip* clip) {

deluge::hid::display::oled_canvas::Canvas& canvas = hid::display::OLED::main;

int32_t yPos = OLED_MAIN_TOPMOST_PIXEL + 3;
int32_t textSpacingX = kTextTitleSpacingX;
int32_t textSpacingY = kTextTitleSizeY;

canvas.drawStringCentred("ARRANGER", yPos, kTextSpacingX, kTextSpacingY);

yPos = OLED_MAIN_TOPMOST_PIXEL + 19;

int32_t textLength = strlen(output->name.get());
int32_t stringLengthPixels = textLength * textSpacingX;

if (stringLengthPixels <= OLED_MAIN_WIDTH_PIXELS) {
canvas.drawStringCentred(output->name.get(), yPos, textSpacingX, textSpacingY);
}
else {
canvas.drawString(output->name.get(), 0, yPos, textSpacingX, textSpacingY);
deluge::hid::display::OLED::setupSideScroller(0, output->name.get(), 0, OLED_MAIN_WIDTH_PIXELS, yPos,
yPos + textSpacingY, textSpacingX, textSpacingY, false);
}

yPos = yPos + 13;

canvas.drawStringCentred(clip->clipName.get(), yPos, kTextSpacingX, kTextSpacingY);
deluge::hid::display::OLED::setupSideScroller(1, clip->clipName.get(), 0, OLED_MAIN_WIDTH_PIXELS, yPos,
yPos + kTextSpacingY, kTextSpacingX, kTextSpacingY, false);
}
1 change: 1 addition & 0 deletions src/deluge/gui/views/arranger_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class ArrangerView final : public TimelineView {
uint32_t doActualRender(int32_t xScroll, uint32_t xZoom, uint32_t whichRows, RGB* image,
uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth], int32_t renderWidth,
int32_t imageWidth);
void drawClipName(Output* output, Clip* clip);
};

extern ArrangerView arrangerView;
2 changes: 1 addition & 1 deletion src/deluge/gui/views/audio_clip_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void AudioClipView::focusRegained() {
}

void AudioClipView::renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas) {
view.displayOutputName(getCurrentOutput(), false);
view.displayOutputName(getCurrentOutput(), false, getCurrentClip());
}

bool AudioClipView::renderMainPads(uint32_t whichRows, RGB image[][kDisplayWidth + kSideBarWidth],
Expand Down
1 change: 1 addition & 0 deletions src/deluge/gui/views/instrument_clip_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "gui/ui/keyboard/keyboard_screen.h"
#include "gui/ui/load/load_instrument_preset_ui.h"
#include "gui/ui/menus.h"
#include "gui/ui/rename/rename_clipname_ui.h"
#include "gui/ui/rename/rename_drum_ui.h"
#include "gui/ui/sample_marker_editor.h"
#include "gui/ui/save/save_kit_row_ui.h"
Expand Down
Loading
Loading