Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/HEAD'
Browse files Browse the repository at this point in the history
  • Loading branch information
ishani committed Jun 12, 2024
2 parents 0014383 + a9e9c4a commit 0f63946
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 21 deletions.
27 changes: 27 additions & 0 deletions src/r1.render/imgui/imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2567,6 +2567,23 @@ void ImGuiTextFilter::Build()
}
}

// #HDD custom thing for searching by the start of the string only
bool ImSnippetMatch( const char* str1, const char* str2 )
{
int d;
while ( (d = ImToUpper( *str2 ) - ImToUpper( *str1 )) == 0 && *str1 )
{
str1++;
str2++;

if ( *str1 == 0 )
return true;
if ( *str2 == 0 )
break;
}
return false;
}

bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
{
if (Filters.empty())
Expand All @@ -2586,6 +2603,16 @@ bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
if (ImStristr(text, text_end, f.b + 1, f.e) != NULL)
return false;
}
// #HDD custom thing for searching by the start of the string only
else if ( f.b[0] == '^' )
{
if ( f.b[1] == 0 )
return false;

// simple start-of-string snippet match
if ( ImSnippetMatch( f.b + 1, text ) )
return true;
}
else
{
// Grep
Expand Down
2 changes: 1 addition & 1 deletion src/r2.ouro/pch.inl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//
//

#define OURO_FRAMEWORK_VERSION "1.1.1"
#define OURO_FRAMEWORK_VERSION "1.1.2"
#define OURO_FRAMEWORK_CREDIT "ishani.org 2024"
#define OURO_FRAMEWORK_URL "https://ishani.org/shelf/ouroveon/"

Expand Down
3 changes: 3 additions & 0 deletions src/r4.toolbox/app/ouro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,10 @@ base::OperationID OuroApp::enqueueJamStemArchiveImportAsync( const fs::path& pat
{
// ping that we're still working on async tasks
if ( (filesProcessed % 20) == 0 )
{
m_eventBusClient.Send< ::events::AsyncTaskActivity >();
std::this_thread::yield();
}

filesTouched++;
});
Expand Down
2 changes: 2 additions & 0 deletions src/r4.toolbox/ux/jams.importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ void JamImporterState::launchImportTasks( app::OuroApp& ouroApplication )
item->m_importOperationYAML = ouroApplication.getWarehouseInstance()->requestJamDataImport( item->m_fileYAML );
item->m_importOperationTAR = ouroApplication.enqueueJamStemArchiveImportAsync( item->m_fileTAR, taskflow );

std::this_thread::yield();

// mark this done for import
item->m_import = false;
}
Expand Down
68 changes: 48 additions & 20 deletions src/r5.lore/lore.app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3576,35 +3576,63 @@ int LoreApp::EntrypointOuro()
ImGui::TextColored( colour::shades::callout.neutral(), ICON_FA_GEAR " Contents Management" );

ImGui::RightAlignSameLine( toolbarButtonSize.x + cEdgeInsetSize );
if ( ImGui::Button( " " ICON_FA_CLIPBOARD " Copy Report", toolbarButtonSize ) )

// with ALT/Option down, we switch from a CSV of jam/riff/stems/timestamps to a jam/couch pairing
const bool bUseCopyToListing = ( ImGui::GetMergedModFlags() & ImGuiModFlags_Alt );
{
std::string reportResult;
reportResult.reserve( 32 * 1024 );
const char* copyButtonTitle = bUseCopyToListing ?
(" " ICON_FA_CLIPBOARD_LIST " Copy Listing") :
(" " ICON_FA_CLIPBOARD " Copy Report");

std::scoped_lock<std::mutex> reportLock( m_warehouseContentsReportMutex );
for ( size_t jamIdx = 0; jamIdx < m_warehouseContentsReport.m_jamCouchIDs.size(); jamIdx++ )
if ( ImGui::Button( copyButtonTitle, toolbarButtonSize ) )
{
const std::size_t jI = m_warehouseContentsSortedIndices[jamIdx];
std::string reportResult;
reportResult.reserve( 32 * 1024 );

std::string csvFilteredTitle = m_warehouseContentsReportJamTitles[jI];
std::replace( csvFilteredTitle.begin(), csvFilteredTitle.end(), '@', '_' );
// lock the report while we rummage through it
std::scoped_lock<std::mutex> reportLock( m_warehouseContentsReportMutex );
for ( size_t jamIdx = 0; jamIdx < m_warehouseContentsReport.m_jamCouchIDs.size(); jamIdx++ )
{
const std::size_t jI = m_warehouseContentsSortedIndices[jamIdx];

const uint32_t oldestRiffTimestamp = m_warehouse->getOldestRiffUnixTimestampFromJam( m_warehouseContentsReport.m_jamCouchIDs[jI] );
// still filter if one is active, helps cut out useful listings/reports to just the visible stuff
const auto& jamNameToFilterAgainst = m_warehouseContentsReportJamTitlesForSort[jI];
if ( !jamNameFilter.PassFilter( jamNameToFilterAgainst.c_str(), &jamNameToFilterAgainst.back() + 1 ) )
continue;

const auto oldestTimeUnix = spacetime::InSeconds( std::chrono::seconds( static_cast<uint64_t>(oldestRiffTimestamp) ) );
const auto oldestTimeDelta = spacetime::calculateDeltaFromNow( oldestTimeUnix ).asPastTenseString( 3 );
std::string csvFilteredTitle = m_warehouseContentsReportJamTitles[jI];
std::replace( csvFilteredTitle.begin(), csvFilteredTitle.end(), '@', '_' );

reportResult += fmt::format( FMTX( "{}@ {}@ {}@ {}@ {}\n" ),
csvFilteredTitle,
m_warehouseContentsReport.m_populatedRiffs[jI],
m_warehouseContentsReport.m_populatedStems[jI],
oldestTimeDelta,
spacetime::datestampStringFromUnix( oldestRiffTimestamp )
);
if ( bUseCopyToListing )
{
// jam name @ band ID, for BNS via Google Sheets :D
reportResult += fmt::format( FMTX( "{}@{}\n" ),
csvFilteredTitle,
m_warehouseContentsReport.m_jamCouchIDs[jI].value()
);
}
else
{
const uint32_t oldestRiffTimestamp = m_warehouse->getOldestRiffUnixTimestampFromJam( m_warehouseContentsReport.m_jamCouchIDs[jI] );

const auto oldestTimeUnix = spacetime::InSeconds( std::chrono::seconds( static_cast<uint64_t>(oldestRiffTimestamp) ) );
const auto oldestTimeDelta = spacetime::calculateDeltaFromNow( oldestTimeUnix ).asPastTenseString( 3 );

reportResult += fmt::format( FMTX( "{}@ {}@ {}@ {}@ {}\n" ),
csvFilteredTitle,
m_warehouseContentsReport.m_populatedRiffs[jI],
m_warehouseContentsReport.m_populatedStems[jI],
oldestTimeDelta,
spacetime::datestampStringFromUnix( oldestRiffTimestamp )
);
}
}
ImGui::SetClipboardText( reportResult.c_str() );
}
ImGui::SetClipboardText( reportResult.c_str() );
ImGui::CompactTooltip( bUseCopyToListing ?
"Produce and copy a list of jam names and couch IDs to the clipboard" :
"Produce and copy a simple jam contents report to the clipboard" );
}
ImGui::CompactTooltip( "Produce and copy a simple jam contents report to the clipboard" );
}
else
if ( warehouseView == WarehouseView::ImportExport )
Expand Down

0 comments on commit 0f63946

Please sign in to comment.