Mork WIP on #96
This commit is contained in:
parent
9afba7fdd3
commit
8e494a71ab
@ -385,6 +385,66 @@ void Commands_clearBookmarks(TrackData* trackData)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct LoopmarkData
|
||||
{
|
||||
struct TrackData* trackData;
|
||||
int row;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void toggleLoopmark(void* userData)
|
||||
{
|
||||
struct LoopmarkData* data = (struct LoopmarkData*)userData;
|
||||
TrackData_toggleLoopmark(data->trackData, data->row);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Commands_toggleLoopmark(TrackData* trackData, int row)
|
||||
{
|
||||
struct LoopmarkData* data;
|
||||
Command* command;
|
||||
|
||||
command = malloc(sizeof(Command));
|
||||
memset(command, 0, sizeof(Command));
|
||||
|
||||
command->userData = data = malloc(sizeof(struct LoopmarkData));
|
||||
command->exec = toggleLoopmark;
|
||||
command->undo = toggleLoopmark;
|
||||
data->trackData = trackData;
|
||||
data->row = row;
|
||||
|
||||
execCommand(command);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Commands_clearLoopmarks(TrackData* trackData)
|
||||
{
|
||||
int i, loopmarkCount = trackData->loopmarkCount;
|
||||
int* loopmarks = trackData->loopmarks;
|
||||
|
||||
if (trackData->loopmarkCount == 0)
|
||||
return;
|
||||
|
||||
Commands_beginMulti("clearLoopmarks");
|
||||
|
||||
for (i = 0; i < loopmarkCount; ++i)
|
||||
{
|
||||
const int loopmark = *loopmarks++;
|
||||
|
||||
if (loopmark == 0)
|
||||
continue;
|
||||
|
||||
Commands_toggleLoopmark(trackData, loopmark);
|
||||
}
|
||||
|
||||
Commands_endMulti();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Commands_undo()
|
||||
{
|
||||
Command* command;
|
||||
|
||||
@ -22,6 +22,8 @@ void Commands_deleteKey(int track, int row);
|
||||
void Commands_addOrUpdateKey(int track, struct track_key* key);
|
||||
void Commands_toggleBookmark(struct TrackData* trackData, int row);
|
||||
void Commands_clearBookmarks(struct TrackData* trackData);
|
||||
void Commands_toggleLoopmark(struct TrackData* trackData, int row);
|
||||
void Commands_clearLoopmarks(struct TrackData* trackData);
|
||||
void Commands_updateKey(int track, struct track_key* key);
|
||||
void Commands_beginMulti(const char* name); // Used (for example) when changing many value at the same time
|
||||
void Commands_endMulti();
|
||||
|
||||
@ -1444,6 +1444,22 @@ static void onClearBookmarks()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void onToggleLoopmark()
|
||||
{
|
||||
Commands_toggleLoopmark(getTrackData(), getRowPos());
|
||||
updateNeedsSaving();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void onClearLoopmarks()
|
||||
{
|
||||
Commands_clearLoopmarks(getTrackData());
|
||||
updateNeedsSaving();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void onTab()
|
||||
{
|
||||
Emgui_setFirstControlFocus();
|
||||
@ -1567,6 +1583,8 @@ void Editor_menuEvent(int menuItem)
|
||||
case EDITOR_MENU_UNFOLD_GROUP : onFoldGroup(false); break;
|
||||
case EDITOR_MENU_TOGGLE_BOOKMARK : onToggleBookmark(); break;
|
||||
case EDITOR_MENU_CLEAR_BOOKMARKS : onClearBookmarks(); break;
|
||||
case EDITOR_MENU_TOGGLE_LOOPMARK : onToggleLoopmark(); break;
|
||||
case EDITOR_MENU_CLEAR_LOOPMARKS : onClearLoopmarks(); break;
|
||||
case EDITOR_MENU_TAB : onTab(); break;
|
||||
}
|
||||
|
||||
|
||||
@ -84,6 +84,9 @@ MenuDescriptor g_viewMenu[] =
|
||||
{ _T(""), EDITOR_MENU_SEPARATOR, 0, 0, 0 },
|
||||
{ _T("Toogle bookmark"), EDITOR_MENU_TOGGLE_BOOKMARK, 'b', 0, 0 },
|
||||
{ _T("Clear bookmarks"), EDITOR_MENU_CLEAR_BOOKMARKS, 'b', EMGUI_KEY_COMMAND, EMGUI_KEY_CTRL },
|
||||
{ _T(""), EDITOR_MENU_SEPARATOR, 0, 0, 0 },
|
||||
{ _T("Toogle loopmark"), EDITOR_MENU_TOGGLE_LOOPMARK, 'l', 0, 0 },
|
||||
{ _T("Clear loopmarks"), EDITOR_MENU_CLEAR_LOOPMARKS, 'l', EMGUI_KEY_COMMAND, EMGUI_KEY_CTRL },
|
||||
{ _T("Jump row,start/end & edit"), EDITOR_MENU_TAB, EMGUI_KEY_TAB, 0, 0 },
|
||||
{ 0 },
|
||||
};
|
||||
|
||||
@ -89,6 +89,9 @@ enum
|
||||
EDITOR_MENU_UNFOLD_GROUP,
|
||||
EDITOR_MENU_TOGGLE_BOOKMARK,
|
||||
EDITOR_MENU_CLEAR_BOOKMARKS,
|
||||
EDITOR_MENU_TOGGLE_LOOPMARK,
|
||||
EDITOR_MENU_CLEAR_LOOPMARKS,
|
||||
|
||||
EDITOR_MENU_TAB,
|
||||
};
|
||||
|
||||
|
||||
@ -324,4 +324,33 @@ int TrackData_getPrevBookmark(TrackData* trackData, int row)
|
||||
return getPrevMark(trackData->bookmarks, trackData->bookmarkCount, row, trackData->startRow);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TrackData_hasLoopmark(TrackData* trackData, int row)
|
||||
{
|
||||
return hasMark(trackData->loopmarks, trackData->loopmarkCount, row);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TrackData_toggleLoopmark(TrackData* trackData, int row)
|
||||
{
|
||||
toogleMark(&trackData->loopmarks, &trackData->loopmarkCount, row);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TrackData_getNextLoopmark(TrackData* trackData, int row)
|
||||
{
|
||||
return getNextMark(trackData->loopmarks, trackData->loopmarkCount, row, -1);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int TrackData_getPrevLoopmark(TrackData* trackData, int row)
|
||||
{
|
||||
return getPrevMark(trackData->loopmarks, trackData->loopmarkCount, row, -1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -63,8 +63,10 @@ typedef struct TrackData
|
||||
struct sync_data syncData;
|
||||
Track tracks[EDITOR_MAX_TRACKS];
|
||||
Group groups[EDITOR_MAX_TRACKS];
|
||||
int* loopmarks;
|
||||
int* bookmarks;
|
||||
int bookmarkCount;
|
||||
int loopmarkCount;
|
||||
int groupCount;
|
||||
int activeTrack;
|
||||
int lastColor;
|
||||
@ -84,6 +86,13 @@ int TrackData_getNextBookmark(TrackData* trackData, int row);
|
||||
int TrackData_getPrevBookmark(TrackData* trackData, int row);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TrackData_hasLoopmark(TrackData* trackData, int row);
|
||||
void TrackData_toggleLoopmark(TrackData* trackData, int row);
|
||||
int TrackData_getNextLoopmark(TrackData* trackData, int row);
|
||||
int TrackData_getPrevLoopmark(TrackData* trackData, int row);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Will get the get the track if it exists else create it
|
||||
|
||||
int TrackData_createGetTrack(TrackData* trackData, const char* name);
|
||||
|
||||
@ -36,6 +36,7 @@ const uint32_t inactive_text_color = EMGUI_COLOR32(0x5f, 0x5f, 0x5f, 0xff);
|
||||
const uint32_t border_color = EMGUI_COLOR32(40, 40, 40, 255);
|
||||
const uint32_t selection_color = EMGUI_COLOR32(0x5f, 0x5f, 0x5f, 0x4f);
|
||||
const uint32_t bookmark_color = EMGUI_COLOR32(0x3f, 0x2f, 0xaf, 0x7f);
|
||||
const uint32_t loopmark_color = EMGUI_COLOR32(0x9f, 0x9f, 0x2f, 0x7f);
|
||||
const uint32_t track_selection_color = EMGUI_COLOR32(0xff, 0xff, 0x00, 0xff);
|
||||
|
||||
static bool s_needsUpdate = false;
|
||||
@ -448,6 +449,9 @@ static int renderChannel(struct TrackInfo* info, int startX, Track* trackData, b
|
||||
{
|
||||
if (TrackData_hasBookmark(info->trackData, y))
|
||||
Emgui_fill(bookmark_color, startX, y_offset - font_size_half, size, 8);
|
||||
|
||||
if (TrackData_hasLoopmark(info->trackData, y))
|
||||
Emgui_fill(loopmark_color , startX, y_offset - font_size_half, size, 8);
|
||||
}
|
||||
|
||||
y_offset += font_size;
|
||||
|
||||
@ -21,8 +21,14 @@ static void parseXml(mxml_node_t* rootNode, TrackData* trackData)
|
||||
mxml_node_t* node = rootNode;
|
||||
|
||||
free(trackData->bookmarks);
|
||||
free(trackData->loopmarks);
|
||||
|
||||
trackData->bookmarks = NULL;
|
||||
trackData->bookmarkCount = 0;
|
||||
|
||||
trackData->loopmarks = NULL;
|
||||
trackData->loopmarkCount = 0;
|
||||
|
||||
trackData->highlightRowStep = 8;
|
||||
|
||||
// Traverse the tracks node data
|
||||
@ -48,6 +54,14 @@ static void parseXml(mxml_node_t* rootNode, TrackData* trackData)
|
||||
TrackData_toggleBookmark(trackData, atoi(row));
|
||||
}
|
||||
|
||||
if (!strcmp("loopmark", element_name))
|
||||
{
|
||||
const char* row = mxmlElementGetAttr(node, "row");
|
||||
|
||||
if (row)
|
||||
TrackData_toggleLoopmark(trackData, atoi(row));
|
||||
}
|
||||
|
||||
if (!strcmp("group", element_name))
|
||||
{
|
||||
s_foldedGroupNames[foldedGroupCount++] = strdup(mxmlElementGetAttr(node, "name"));
|
||||
@ -243,6 +257,9 @@ static const char* whitespaceCallback(mxml_node_t* node, int where)
|
||||
|
||||
if (!strcmp("bookmark", name))
|
||||
return "\t";
|
||||
|
||||
if (!strcmp("loopmark", name))
|
||||
return "\t";
|
||||
}
|
||||
|
||||
if (where == MXML_WS_AFTER_OPEN)
|
||||
@ -283,6 +300,7 @@ int LoadSave_saveRocketXML(const text_t* path, TrackData* trackData)
|
||||
size_t p;
|
||||
struct sync_data* sync_data = &trackData->syncData;
|
||||
int* bookmarks = trackData->bookmarks;
|
||||
int* loopmarks = trackData->loopmarks;
|
||||
|
||||
xml = mxmlNewXML("1.0");
|
||||
rootElement = mxmlNewElement(xml, "rootElement");
|
||||
@ -301,6 +319,20 @@ int LoadSave_saveRocketXML(const text_t* path, TrackData* trackData)
|
||||
setElementInt(node, "row", "%d", bookmark);
|
||||
}
|
||||
|
||||
// save all loopmarks
|
||||
|
||||
for (p = 0; p < (size_t)trackData->loopmarkCount; ++p)
|
||||
{
|
||||
mxml_node_t* node;
|
||||
const int loopmark = *loopmarks++;
|
||||
|
||||
if (loopmark == 0)
|
||||
continue;
|
||||
|
||||
node = mxmlNewElement(rootElement, "loopmark");
|
||||
setElementInt(node, "row", "%d", loopmark);
|
||||
}
|
||||
|
||||
// save groups that are folded
|
||||
|
||||
for (p = 0; p < (size_t)trackData->groupCount; ++p)
|
||||
|
||||
@ -561,6 +561,8 @@ LRESULT CALLBACK WndProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam
|
||||
case EDITOR_MENU_UNFOLD_GROUP:
|
||||
case EDITOR_MENU_TOGGLE_BOOKMARK:
|
||||
case EDITOR_MENU_CLEAR_BOOKMARKS:
|
||||
case EDITOR_MENU_TOGGLE_LOOPMARK:
|
||||
case EDITOR_MENU_CLEAR_LOOPMARKS:
|
||||
{
|
||||
Editor_menuEvent(LOWORD(wParam));
|
||||
break;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user