mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-26 22:43:01 +00:00
fix: macro editor scaling in "single (list)" mode
specifically the bottom line with "length/step-length/delay" and the associated buttons -- previously would just get cut off when there wasn't enough room, now scales the elements to fit (uses a table)
This commit is contained in:
parent
61ddd29b1e
commit
66b22cce32
1 changed files with 58 additions and 38 deletions
|
@ -2392,48 +2392,68 @@ void FurnaceGUI::drawMacros(std::vector<FurnaceGUIMacroDesc>& macros, FurnaceGUI
|
||||||
drawMacroEdit(m,totalFit,availableWidth,index);
|
drawMacroEdit(m,totalFit,availableWidth,index);
|
||||||
|
|
||||||
if (m.macro->open&1) {
|
if (m.macro->open&1) {
|
||||||
if ((m.macro->open&6)==0) {
|
bool showLen=((m.macro->open&6)==0);
|
||||||
ImGui::Text(_("Length"));
|
int colCount=showLen ? 4 : 3;
|
||||||
ImGui::SameLine();
|
float availX=ImGui::GetContentRegionAvail().x;
|
||||||
ImGui::SetNextItemWidth(120.0f*dpiScale);
|
|
||||||
int macroLen=m.macro->len;
|
// fairly arbitrary scaling logic
|
||||||
if (ImGui::InputScalar("##IMacroLen",ImGuiDataType_U8,¯oLen,&_ONE,&_THREE)) { MARK_MODIFIED
|
bool shortLabels=(availX<600.0f*dpiScale);
|
||||||
if (macroLen<0) macroLen=0;
|
float scalarItemWidth=MIN((availX-90.0f*dpiScale)/4, 120.0f*dpiScale);
|
||||||
if (macroLen>255) macroLen=255;
|
if (ImGui::BeginTable("##MacroMetaData",colCount)) {
|
||||||
m.macro->len=macroLen;
|
if (showLen) ImGui::TableSetupColumn("len",ImGuiTableColumnFlags_WidthStretch,0.0);
|
||||||
}
|
ImGui::TableSetupColumn("stepLen",ImGuiTableColumnFlags_WidthStretch,0.0);
|
||||||
ImGui::SameLine();
|
ImGui::TableSetupColumn("delay",ImGuiTableColumnFlags_WidthStretch,0.0);
|
||||||
}
|
ImGui::TableSetupColumn("buttons",ImGuiTableColumnFlags_WidthFixed,0.0);
|
||||||
ImGui::Text(_("StepLen"));
|
|
||||||
ImGui::SameLine();
|
ImGui::TableNextRow();
|
||||||
ImGui::SetNextItemWidth(120.0f*dpiScale);
|
if (showLen) {
|
||||||
if (ImGui::InputScalar("##IMacroSpeed",ImGuiDataType_U8,&m.macro->speed,&_ONE,&_THREE)) {
|
ImGui::TableNextColumn();
|
||||||
if (m.macro->speed<1) m.macro->speed=1;
|
ImGui::Text(shortLabels ? _("Len##macroEditLengthShortLabel") : _("Length"));
|
||||||
MARK_MODIFIED;
|
if (shortLabels && ImGui::IsItemHovered()) ImGui::SetTooltip("%s", _("Length"));
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::Text(_("Delay"));
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::SetNextItemWidth(120.0f*dpiScale);
|
|
||||||
if (ImGui::InputScalar("##IMacroDelay",ImGuiDataType_U8,&m.macro->delay,&_ONE,&_THREE)) {
|
|
||||||
MARK_MODIFIED;
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
{
|
|
||||||
FurnaceGUIMacroDesc& i=m;
|
|
||||||
BUTTON_TO_SET_MODE(ImGui::Button);
|
|
||||||
if ((i.macro->open&6)==0) {
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
BUTTON_TO_SET_RELEASE(ImGui::Button);
|
ImGui::SetNextItemWidth(scalarItemWidth);
|
||||||
|
int macroLen=m.macro->len;
|
||||||
|
if (ImGui::InputScalar("##IMacroLen",ImGuiDataType_U8,¯oLen,&_ONE,&_THREE)) { MARK_MODIFIED
|
||||||
|
if (macroLen<0) macroLen=0;
|
||||||
|
if (macroLen>255) macroLen=255;
|
||||||
|
m.macro->len=macroLen;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
ImGui::TableNextColumn();
|
||||||
if (m.modeName!=NULL) {
|
ImGui::Text(shortLabels ? _("SLen##macroEditStepLenShortLabel") : _("StepLen"));
|
||||||
bool modeVal=m.macro->mode;
|
if (shortLabels && ImGui::IsItemHovered()) ImGui::SetTooltip("%s", _("StepLen"));
|
||||||
String modeName=fmt::sprintf("%s##IMacroMode",m.modeName);
|
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Checkbox(modeName.c_str(),&modeVal)) {
|
ImGui::SetNextItemWidth(scalarItemWidth);
|
||||||
m.macro->mode=modeVal;
|
if (ImGui::InputScalar("##IMacroSpeed",ImGuiDataType_U8,&m.macro->speed,&_ONE,&_THREE)) {
|
||||||
|
if (m.macro->speed<1) m.macro->speed=1;
|
||||||
|
MARK_MODIFIED;
|
||||||
}
|
}
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text(shortLabels ? _("Del##macroEditDelayShortLabel") : _("Delay"));
|
||||||
|
if (shortLabels && ImGui::IsItemHovered()) ImGui::SetTooltip("%s", _("Delay"));
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::SetNextItemWidth(scalarItemWidth);
|
||||||
|
if (ImGui::InputScalar("##IMacroDelay",ImGuiDataType_U8,&m.macro->delay,&_ONE,&_THREE)) {
|
||||||
|
MARK_MODIFIED;
|
||||||
|
}
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
{
|
||||||
|
FurnaceGUIMacroDesc& i=m;
|
||||||
|
BUTTON_TO_SET_MODE(ImGui::Button);
|
||||||
|
if ((i.macro->open&6)==0) {
|
||||||
|
ImGui::SameLine();
|
||||||
|
BUTTON_TO_SET_RELEASE(ImGui::Button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m.modeName!=NULL) {
|
||||||
|
bool modeVal=m.macro->mode;
|
||||||
|
String modeName=fmt::sprintf("%s##IMacroMode",m.modeName);
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Checkbox(modeName.c_str(),&modeVal)) {
|
||||||
|
m.macro->mode=modeVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ImGui::Text(_("The heck? No, this isn't even working correctly..."));
|
ImGui::Text(_("The heck? No, this isn't even working correctly..."));
|
||||||
|
|
Loading…
Reference in a new issue