Skip to content

Commit 7ddc397

Browse files
committed
Made better history input
issue: MatterHackers/MCCentral#6148 Create canceled / failed options hierarchy
1 parent fc26a92 commit 7ddc397

File tree

3 files changed

+96
-89
lines changed

3 files changed

+96
-89
lines changed

MatterControlLib/History/PrintHistoryEditor.cs

Lines changed: 94 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void AddNotesMenu(PopupMenu popupMenu, IEnumerable<PrintTask> printTasks,
8989
AllowEmpty = true,
9090
};
9191

92-
inputBoxPage.ContentRow.AddChild(CreateDefaultOptions(inputBoxPage.TextEditWidget, theme), 0);
92+
inputBoxPage.ContentRow.AddChild(CreateDefaultOptions(inputBoxPage.TextEditWidget, theme, null), 0);
9393

9494
DialogWindow.Show(inputBoxPage);
9595

@@ -281,101 +281,110 @@ private static void SetStarState(ThemeConfig theme, List<GuiWidget> siblings, Pr
281281
}
282282
}
283283

284-
public static MHDropDownList CreateDefaultOptions(GuiWidget textField, ThemeConfig theme)
284+
public static GuiWidget CreateDefaultOptions(GuiWidget textField, ThemeConfig theme, Action selectionChanged)
285285
{
286-
var options = new List<(string group, string item)>()
287-
{
288-
("First Layer", "First Layer Bad Quality"),
289-
("First Layer", "Initial Z Height Incorrect"),
290-
("Quality", "Dislodged From Bed"),
291-
("Quality", "Layer Shift"),
292-
("Quality", "General Quality"),
293-
("Quality", "Rough Overhangs"),
294-
("Quality", "Skipped Layers"),
295-
("Quality", "Some Parts Lifted"),
296-
("Quality", "Stringing / Poor retractions"),
297-
("Quality", "Warping"),
298-
("Mechanical", "Bed Dislodged"),
299-
("Mechanical", "Bowden Tube Popped Out"),
300-
("Mechanical", "Extruder Slipping"),
301-
("Mechanical", "Flooded Hot End"),
302-
("Mechanical", "Power Outage"),
303-
("Computer / MatterControl", "Computer Crashed"),
304-
("Computer / MatterControl", "Computer Slow / Lagging"),
305-
("Computer / MatterControl", "Couldn't Resume"),
306-
("Computer / MatterControl", "Wouldn’t Slice Correctly"),
307-
("Filament", "Filament Jam"),
308-
("Filament", "Filament Runout"),
309-
("Filament", "Filament Snapped"),
310-
("Heating", "Thermal Runaway - Bed"),
311-
("Heating", "Thermal Runaway - Hot End"),
312-
("Heating", "Thermal Runaway"),
313-
("Heating", "Took Too Long To Heat"),
314-
("Heating", "Bad Thermistor"),
315-
("X", "Test Print"),
316-
("X", "User Error"),
317-
("X", "Other"),
318-
};
319-
320-
var issues = new string[]
321-
{
322-
"Bad Thermistor".Localize(),
323-
"Bed Dislodged".Localize(),
324-
"Bowden Tube Popped Out".Localize(),
325-
"Computer Crashed".Localize(),
326-
"Computer Slow/Lagging".Localize(),
327-
"Couldn't Resume".Localize(),
328-
"Dislodged From Bed".Localize(),
329-
"Extruder Slipping".Localize(),
330-
"Filament Jam".Localize(),
331-
"Filament Runout".Localize(),
332-
"Filament Snapped".Localize(),
333-
"First Layer Bad Quality".Localize(),
334-
"Flooded Hot End".Localize(),
335-
"Initial Z Height Incorrect".Localize(),
336-
"Layer Shift".Localize(),
337-
"Power Outage".Localize(),
338-
"Print Quality".Localize(),
339-
"Rough Overhangs".Localize(),
340-
"Skipped Layers".Localize(),
341-
"Some Parts Lifted".Localize(),
342-
"Stringing / Poor retractions".Localize(),
343-
"Test Print".Localize(),
344-
"Thermal Runaway - Bed".Localize(),
345-
"Thermal Runaway - Hot End".Localize(),
346-
"Thermal Runaway".Localize(),
347-
"Took Too Long To Heat".Localize(),
348-
"User Error".Localize(),
349-
"Warping".Localize(),
350-
"Wouldn’t Slice Correctly".Localize(),
351-
"Other...".Localize()
352-
};
286+
var selectString = "- " + "What went wrong?".Localize() + " -";
287+
var menuButton = new PopupMenuButton(selectString, theme);
288+
var menuButtonText = menuButton.Descendants<TextWidget>().First();
289+
menuButtonText.AutoExpandBoundsToText = true;
353290

354-
textField.Visible = false;
355-
356-
var dropdownList = new MHDropDownList("What went wrong?".Localize(), theme, maxHeight: 300 * GuiWidget.DeviceScale);
357-
358-
foreach (var issue in issues)
291+
void AddSelection(PopupMenu menu, string text, bool other = false)
359292
{
360-
MenuItem newItem = dropdownList.AddItem(issue);
293+
var menuItem = menu.CreateMenuItem(text);
361294

362-
newItem.Selected += (sender, e) =>
295+
menuItem.Click += (s, e) =>
363296
{
364-
if (dropdownList.SelectedIndex == issues.Length - 1)
297+
if (other)
365298
{
366299
textField.Text = "";
367300
textField.Visible = true;
368301
UiThread.RunOnIdle(textField.Focus);
302+
menuButtonText.Text = "Other".Localize() + "...";
369303
}
370304
else
371305
{
372-
textField.Text = issue;
306+
textField.Text = text;
373307
textField.Visible = false;
308+
menuButtonText.Text = textField.Text;
374309
}
310+
311+
selectionChanged?.Invoke();
375312
};
376313
}
377314

378-
return dropdownList;
315+
menuButton.DynamicPopupContent = () =>
316+
{
317+
var popupMenu = new PopupMenu(ApplicationController.Instance.MenuTheme);
318+
319+
popupMenu.CreateSubMenu("First Layer".Localize(),
320+
theme,
321+
(menu) =>
322+
{
323+
AddSelection(menu, "First Layer Bad Quality".Localize());
324+
AddSelection(menu, "Initial Z Height Incorrect".Localize());
325+
});
326+
popupMenu.CreateSubMenu("Quality".Localize(),
327+
theme,
328+
(menu) =>
329+
{
330+
AddSelection(menu, "General Quality".Localize());
331+
AddSelection(menu, "Rough Overhangs".Localize());
332+
AddSelection(menu, "Skipped Layers".Localize());
333+
AddSelection(menu, "Some Parts Lifted".Localize());
334+
AddSelection(menu, "Stringing / Poor retractions".Localize());
335+
AddSelection(menu, "Warping".Localize());
336+
AddSelection(menu, "Dislodged From Bed".Localize());
337+
AddSelection(menu, "Layer Shift".Localize());
338+
});
339+
popupMenu.CreateSubMenu("Mechanical".Localize(),
340+
theme,
341+
(menu) =>
342+
{
343+
AddSelection(menu, "Bed Dislodged".Localize());
344+
AddSelection(menu, "Bowden Tube Popped Out".Localize());
345+
AddSelection(menu, "Extruder Slipping".Localize());
346+
AddSelection(menu, "Flooded Hot End".Localize());
347+
AddSelection(menu, "Power Outage".Localize());
348+
});
349+
popupMenu.CreateSubMenu("Computer / MatterControl ".Localize(),
350+
theme,
351+
(menu) =>
352+
{
353+
AddSelection(menu, "Computer Crashed".Localize());
354+
AddSelection(menu, "Computer Slow / Lagging".Localize());
355+
AddSelection(menu, "Couldn't Resume".Localize());
356+
AddSelection(menu, "Wouldn’t Slice Correctly".Localize());
357+
});
358+
popupMenu.CreateSubMenu("Filament".Localize(),
359+
theme,
360+
(menu) =>
361+
{
362+
AddSelection(menu, "Filament Jam".Localize());
363+
AddSelection(menu, "Filament Runout".Localize());
364+
AddSelection(menu, "Filament Snapped".Localize());
365+
});
366+
popupMenu.CreateSubMenu("Heating".Localize(),
367+
theme,
368+
(menu) =>
369+
{
370+
AddSelection(menu, "Thermal Runaway - Bed".Localize());
371+
AddSelection(menu, "Thermal Runaway - Hot End".Localize());
372+
AddSelection(menu, "Heating".Localize());
373+
AddSelection(menu, "Took Too Long To Heat".Localize());
374+
AddSelection(menu, "Bad Thermistor".Localize());
375+
AddSelection(menu, "Bad Thermistor".Localize());
376+
});
377+
AddSelection(popupMenu, "Test Print".Localize());
378+
AddSelection(popupMenu, "User Error".Localize());
379+
AddSelection(popupMenu, "Other".Localize(), true);
380+
381+
return popupMenu;
382+
};
383+
384+
textField.Visible = false;
385+
menuButton.VAnchor = VAnchor.Fit;
386+
387+
return menuButton;
379388
}
380389

381390
private static string articles = @"
@@ -496,21 +505,19 @@ public CollectPrintDetailsPage(string windowTitle,
496505
printTask.CommitAndPushToServer();
497506
};
498507

499-
var dropDownList = CreateDefaultOptions(textEditWidget, theme);
500-
dropDownList.Margin = new BorderDouble(5, 0);
501-
dropDownList.HAnchor = HAnchor.Left;
502-
reasonSection.AddChild(dropDownList);
503-
reasonSection.AddChild(textEditWidget);
504-
505-
dropDownList.SelectionChanged += (s, e) =>
508+
var dropDownList = CreateDefaultOptions(textEditWidget, theme, () =>
506509
{
507510
// Delay this so we wait for the text to be updated
508511
UiThread.RunOnIdle(() =>
509512
{
510513
printTask.Note = textEditWidget.Text;
511514
printTask.CommitAndPushToServer();
512515
});
513-
};
516+
});
517+
dropDownList.Margin = new BorderDouble(5, 0);
518+
dropDownList.HAnchor |= HAnchor.Left;
519+
reasonSection.AddChild(dropDownList);
520+
reasonSection.AddChild(textEditWidget);
514521

515522
topToBottom.AddChild(new HorizontalLine(theme.BorderColor40)
516523
{

Submodules/MatterSlice

Submodules/agg-sharp

0 commit comments

Comments
 (0)