TimeMicros::fromString()

and improve the cue position editor a bit
This commit is contained in:
tildearrow 2025-10-31 03:42:43 -05:00
parent 3516245d2e
commit e8aeb45a12
6 changed files with 259 additions and 14 deletions

View file

@ -25,6 +25,7 @@
#include <fmt/printf.h>
#include "imgui.h"
#include "imgui_internal.h"
#include "misc/cpp/imgui_stdlib.h"
PendingDrawOsc _debugDo;
static float oscDebugData[2048];
@ -369,6 +370,25 @@ void FurnaceGUI::drawDebug() {
ImGui::Unindent();
ImGui::TreePop();
}
if (ImGui::TreeNode("TimeMicros Test")) {
static TimeMicros testTS;
static String testTSIn;
String testTSFormatted=testTS.toString();
ImGui::Text("Current Value: %s",testTSFormatted.c_str());
if (ImGui::InputText("fromString",&testTSIn)) {
try {
testTS=TimeMicros::fromString(testTSIn);
} catch (std::invalid_argument& e) {
ImGui::Text("COULD NOT! (%s)",e.what());
}
}
ImGui::InputInt("seconds",&testTS.seconds);
ImGui::InputInt("micros",&testTS.micros);
ImGui::TreePop();
}
if (ImGui::TreeNode("New File Picker Test")) {
static bool check0, check1, check2, check3, check4, check5;

View file

@ -9069,6 +9069,9 @@ FurnaceGUI::FurnaceGUI():
xyOscDecayTime(10.0f),
xyOscIntensity(2.0f),
xyOscThickness(2.0f),
fpCueInput(""),
fpCueInputFailed(false),
fpCueInputFailReason(""),
followLog(true),
#ifdef IS_MOBILE
pianoOctaves(7),

View file

@ -2734,6 +2734,11 @@ class FurnaceGUI {
float keyHit1[DIV_MAX_CHANS];
int lastIns[DIV_MAX_CHANS];
// file player temp variables
String fpCueInput;
bool fpCueInputFailed;
String fpCueInputFailReason;
// log window
bool followLog;

View file

@ -21,6 +21,7 @@
#include <fmt/printf.h>
#include "imgui.h"
#include "IconsFontAwesome4.h"
#include "misc/cpp/imgui_stdlib.h"
void FurnaceGUI::drawRefPlayer() {
DivFilePlayer* fp=e->getFilePlayer();
@ -112,19 +113,25 @@ void FurnaceGUI::drawRefPlayer() {
ImGui::TextUnformatted(_("Set cue position at first order:"));
TimeMicros cueTime=e->getFilePlayerCue();
bool altered=false;
// TODO: improve this...
ImGui::SetNextItemWidth(240.0f*dpiScale);
if (ImGui::InputInt(_("Seconds##CuePosS"),&cueTime.seconds)) {
if (cueTime.seconds<-3600) cueTime.seconds=-3600;
if (cueTime.seconds>3600) cueTime.seconds=3600;
altered=true;
fpCueInput=cueTime.toString(-1,TA_TIME_FORMAT_AUTO);
pushWarningColor(false,fpCueInputFailed);
if (ImGui::InputText("##CuePos",&fpCueInput)) {
try {
cueTime=TimeMicros::fromString(fpCueInput);
altered=true;
fpCueInputFailed=false;
} catch (std::invalid_argument& e) {
fpCueInputFailed=true;
fpCueInputFailReason=e.what();
}
}
ImGui::SetNextItemWidth(240.0f*dpiScale);
if (ImGui::InputInt(_("Microseconds##CuePosM"),&cueTime.micros,1000,10000)) {
if (cueTime.micros<0) cueTime.micros=0;
if (cueTime.micros>999999) cueTime.micros=999999;
altered=true;
if (!ImGui::IsItemActive()) {
fpCueInputFailed=false;
}
if (ImGui::IsItemHovered() && fpCueInputFailed) {
ImGui::SetTooltip("%s",fpCueInputFailReason.c_str());
}
popWarningColor();
if (altered) {
e->setFilePlayerCue(cueTime);
}