furnace/src/gui/gui.h

179 lines
4 KiB
C
Raw Normal View History

2021-12-11 02:10:09 -05:00
#include "../engine/engine.h"
2021-12-11 03:11:40 -05:00
#include "imgui.h"
#include "imgui_impl_sdl.h"
#include "imgui_impl_sdlrenderer.h"
#include <SDL.h>
2021-12-14 17:45:37 -05:00
#include <map>
2021-12-11 02:10:09 -05:00
2021-12-13 17:09:46 -05:00
enum FurnaceGUIColors {
GUI_COLOR_BACKGROUND=0,
GUI_COLOR_FRAME_BACKGROUND,
GUI_COLOR_HEADER,
GUI_COLOR_ITEM_BACKGROUND,
GUI_COLOR_ITEM_FOREGROUND,
GUI_COLOR_PATTERN_HI_1,
GUI_COLOR_PATTERN_HI_2,
GUI_COLOR_PATTERN_ROW_INDEX,
GUI_COLOR_PATTERN_ACTIVE,
GUI_COLOR_PATTERN_INACTIVE,
GUI_COLOR_PATTERN_INS,
GUI_COLOR_PATTERN_VOLUME_MAX,
GUI_COLOR_PATTERN_VOLUME_HALF,
GUI_COLOR_PATTERN_VOLUME_MIN,
GUI_COLOR_PATTERN_EFFECT_INVALID,
GUI_COLOR_PATTERN_EFFECT_PITCH,
GUI_COLOR_PATTERN_EFFECT_VOLUME,
GUI_COLOR_PATTERN_EFFECT_PANNING,
GUI_COLOR_PATTERN_EFFECT_SONG,
GUI_COLOR_PATTERN_EFFECT_TIME,
GUI_COLOR_PATTERN_EFFECT_SPEED,
GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY,
GUI_COLOR_PATTERN_EFFECT_SYS_SECONDARY,
GUI_COLOR_PATTERN_EFFECT_MISC,
GUI_COLOR_EE_VALUE,
2021-12-21 02:30:09 -05:00
GUI_COLOR_PLAYBACK_STAT,
2021-12-13 17:09:46 -05:00
GUI_COLOR_MAX
};
2021-12-14 17:45:37 -05:00
enum FurnaceGUIWindows {
GUI_WINDOW_NOTHING=0,
2021-12-15 17:32:08 -05:00
GUI_WINDOW_EDIT_CONTROLS,
2021-12-14 17:45:37 -05:00
GUI_WINDOW_SONG_INFO,
GUI_WINDOW_ORDERS,
GUI_WINDOW_INS_LIST,
GUI_WINDOW_PATTERN,
GUI_WINDOW_INS_EDIT,
GUI_WINDOW_WAVE_LIST,
GUI_WINDOW_WAVE_EDIT,
GUI_WINDOW_SAMPLE_LIST,
GUI_WINDOW_SAMPLE_EDIT
2021-12-14 17:45:37 -05:00
};
enum FurnaceGUIFileDialogs {
GUI_FILE_OPEN,
GUI_FILE_SAVE,
GUI_FILE_SAMPLE_OPEN,
GUI_FILE_SAMPLE_SAVE
};
2021-12-14 04:45:44 -05:00
struct SelectionPoint {
int xCoarse, xFine;
int y;
2021-12-14 17:45:37 -05:00
SelectionPoint():
xCoarse(0), xFine(0), y(0) {}
2021-12-14 04:45:44 -05:00
};
2021-12-11 02:10:09 -05:00
class FurnaceGUI {
DivEngine* e;
2021-12-11 03:11:40 -05:00
SDL_Window* sdlWin;
SDL_Renderer* sdlRend;
String workingDir, fileName, clipboard, errorString, lastError;
2021-12-19 22:51:02 -05:00
bool quit, willCommit;
FurnaceGUIFileDialogs curFileDialog;
2021-12-11 03:11:40 -05:00
int scrW, scrH;
double dpiScale;
2021-12-18 23:03:50 -05:00
int aboutScroll, aboutSin;
float aboutHue;
2021-12-11 03:11:40 -05:00
ImFont* mainFont;
2021-12-21 00:30:55 -05:00
ImFont* iconFont;
2021-12-11 03:11:40 -05:00
ImFont* patFont;
2021-12-18 23:03:50 -05:00
ImFont* bigFont;
2021-12-13 17:09:46 -05:00
ImVec4 uiColors[GUI_COLOR_MAX];
ImVec4 volColors[128];
2021-12-11 03:11:40 -05:00
2021-12-19 22:51:02 -05:00
int mainFontSize, patFontSize;
2021-12-19 16:01:24 -05:00
char finalLayoutPath[4096];
2021-12-19 03:16:24 -05:00
int curIns, curWave, curSample, curOctave, oldRow, oldOrder, oldOrder1, editStep;
2021-12-15 17:32:08 -05:00
bool editControlsOpen, ordersOpen, insListOpen, songInfoOpen, patternOpen, insEditOpen;
2021-12-19 22:51:02 -05:00
bool waveListOpen, waveEditOpen, sampleListOpen, sampleEditOpen, aboutOpen, settingsOpen;
2021-12-14 04:45:44 -05:00
SelectionPoint selStart, selEnd;
bool selecting, curNibble, extraChannelButtons, followOrders, followPattern;
2021-12-14 17:45:37 -05:00
FurnaceGUIWindows curWindow;
std::map<SDL_Keycode,int> noteKeys;
std::map<SDL_Keycode,int> valueKeys;
2021-12-11 16:44:02 -05:00
2021-12-12 18:19:43 -05:00
int arpMacroScroll;
ImVec2 macroDragStart;
ImVec2 macroDragAreaSize;
int* macroDragTarget;
int macroDragLen;
int macroDragMin, macroDragMax;
bool macroDragActive;
ImVec2 macroLoopDragStart;
ImVec2 macroLoopDragAreaSize;
signed char* macroLoopDragTarget;
int macroLoopDragLen;
bool macroLoopDragActive;
2021-12-18 17:54:26 -05:00
ImVec2 waveDragStart;
ImVec2 waveDragAreaSize;
int* waveDragTarget;
int waveDragLen;
int waveDragMin, waveDragMax;
bool waveDragActive;
2021-12-13 17:09:46 -05:00
float nextScroll;
2021-12-15 17:32:08 -05:00
void updateWindowTitle();
2021-12-19 16:01:24 -05:00
void prepareLayout();
2021-12-15 17:32:08 -05:00
void drawEditControls();
2021-12-14 04:45:44 -05:00
void drawSongInfo();
void drawOrders();
void drawPattern();
void drawInsList();
2021-12-14 04:45:44 -05:00
void drawInsEdit();
void drawWaveList();
void drawWaveEdit();
void drawSampleList();
void drawSampleEdit();
2021-12-18 23:03:50 -05:00
void drawAbout();
2021-12-19 22:51:02 -05:00
void drawSettings();
void commitSettings();
2021-12-14 04:45:44 -05:00
2021-12-14 17:45:37 -05:00
void startSelection(int xCoarse, int xFine, int y);
void updateSelection(int xCoarse, int xFine, int y);
void finishSelection();
void moveCursor(int x, int y);
2021-12-14 17:45:37 -05:00
void editAdvance();
void doDelete();
2021-12-19 02:12:19 -05:00
void doPullDelete();
void doInsert();
void doCopy(bool cut);
void doPaste();
2021-12-14 17:45:37 -05:00
void keyDown(SDL_Event& ev);
void keyUp(SDL_Event& ev);
void openFileDialog(FurnaceGUIFileDialogs type);
int save(String path);
int load(String path);
void showError(String what);
2021-12-11 02:10:09 -05:00
public:
2021-12-13 02:03:36 -05:00
const char* noteName(short note, short octave);
2021-12-19 02:12:19 -05:00
bool decodeNote(const char* what, short& note, short& octave);
2021-12-11 02:10:09 -05:00
void bindEngine(DivEngine* eng);
2021-12-19 22:51:02 -05:00
void updateScroll(int amount);
2021-12-11 03:11:40 -05:00
bool loop();
2021-12-19 16:01:24 -05:00
bool finish();
2021-12-11 03:11:40 -05:00
bool init();
2021-12-11 02:10:09 -05:00
FurnaceGUI();
2021-12-11 16:44:02 -05:00
};