Put back in small icon rendering
issue: MatterHackers/MatterControl#4825 Library icons no longer distinguishable
This commit is contained in:
parent
23c409dd83
commit
e7f159048f
36 changed files with 58 additions and 15 deletions
|
|
@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
||||
namespace MatterHackers.MatterControl.Library
|
||||
{
|
||||
|
|
@ -40,12 +41,32 @@ namespace MatterHackers.MatterControl.Library
|
|||
private readonly Func<string> nameResolver;
|
||||
|
||||
private readonly ImageBuffer thumbnail;
|
||||
|
||||
private readonly ImageBuffer microIcon;
|
||||
private readonly Func<bool> visibilityResolver;
|
||||
|
||||
public DynamicContainerLink(Func<string> nameResolver, ImageBuffer thumbnail, Func<ILibraryContainer> creator = null, Func<bool> visibilityResolver = null)
|
||||
public DynamicContainerLink(Func<string> nameResolver,
|
||||
ImageBuffer thumbnail,
|
||||
Func<ILibraryContainer> creator = null,
|
||||
Func<bool> visibilityResolver = null)
|
||||
: this(nameResolver, thumbnail, null, creator, visibilityResolver)
|
||||
{
|
||||
}
|
||||
|
||||
public DynamicContainerLink(Func<string> nameResolver,
|
||||
ImageBuffer thumbnail,
|
||||
ImageBuffer microIcon,
|
||||
Func<ILibraryContainer> creator = null,
|
||||
Func<bool> visibilityResolver = null)
|
||||
{
|
||||
this.thumbnail = thumbnail?.SetPreMultiply();
|
||||
this.microIcon = microIcon;
|
||||
if (microIcon != null)
|
||||
{
|
||||
thumbnail.NewGraphics2D().Render(microIcon,
|
||||
(thumbnail.Width - microIcon.Width) / 2,
|
||||
(thumbnail.Height - microIcon.Height) * .43);
|
||||
}
|
||||
|
||||
this.nameResolver = nameResolver;
|
||||
this.containerCreator = creator;
|
||||
this.visibilityResolver = visibilityResolver ?? (() => true);
|
||||
|
|
@ -74,6 +95,13 @@ namespace MatterHackers.MatterControl.Library
|
|||
|
||||
public Task<ImageBuffer> GetThumbnail(int width, int height)
|
||||
{
|
||||
if (microIcon != null
|
||||
&& width < 24 * GuiWidget.DeviceScale
|
||||
&& height < 24 * GuiWidget.DeviceScale)
|
||||
{
|
||||
return Task.FromResult(microIcon?.AlphaToPrimaryAccent());
|
||||
}
|
||||
|
||||
return Task.FromResult(thumbnail?.AlphaToPrimaryAccent());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,14 +55,16 @@ namespace MatterHackers.MatterControl.Library
|
|||
this.ChildContainers.Add(
|
||||
new DynamicContainerLink(
|
||||
() => "Local Library".Localize(),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "local_library_folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "local_library_icon.png")),
|
||||
() => new SqliteLibraryContainer(rootLibraryCollection.Id)));
|
||||
}
|
||||
|
||||
this.ChildContainers.Add(
|
||||
new DynamicContainerLink(
|
||||
() => "Calibration Parts".Localize(),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "calibration_library_folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "calibration_library_icon.png")),
|
||||
() => new CalibrationPartsContainer())
|
||||
{
|
||||
IsReadOnly = true
|
||||
|
|
@ -71,7 +73,8 @@ namespace MatterHackers.MatterControl.Library
|
|||
this.ChildContainers.Add(
|
||||
new DynamicContainerLink(
|
||||
() => "Primitives".Localize(),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "primitives_library_folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "primitives_library_icon.png")),
|
||||
() => new PrimitivesContainer())
|
||||
{
|
||||
IsReadOnly = true
|
||||
|
|
@ -88,7 +91,8 @@ namespace MatterHackers.MatterControl.Library
|
|||
this.ChildContainers.Add(
|
||||
new DynamicContainerLink(
|
||||
() => "Print Queue".Localize(),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "queue_folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "queue_icon.png")),
|
||||
() => new PrintQueueContainer()));
|
||||
}
|
||||
|
||||
|
|
@ -97,6 +101,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
new DynamicContainerLink(
|
||||
() => "Pipe Works".Localize(),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder.png")),
|
||||
null,
|
||||
() => new PipeWorksContainer()));
|
||||
|
||||
int index = 0;
|
||||
|
|
@ -105,6 +110,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
new DynamicContainerLink(
|
||||
() => "Experimental".Localize(),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder.png")),
|
||||
null,
|
||||
() => new DynamicContainer()
|
||||
{
|
||||
Items = new List<ILibraryItem>()
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ namespace MatterHackers.MatterControl.Library
|
|||
this.ChildContainers.Add(
|
||||
new DynamicContainerLink(
|
||||
() => "Plating History".Localize(),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "history_folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "history_icon.png")),
|
||||
() => new PlatingHistoryContainer())
|
||||
{
|
||||
IsReadOnly = true
|
||||
|
|
@ -59,7 +60,8 @@ namespace MatterHackers.MatterControl.Library
|
|||
this.ChildContainers.Add(
|
||||
new DynamicContainerLink(
|
||||
() => "Print History".Localize(),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "history_folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "history_icon.png")),
|
||||
() => new PrintHistoryContainer()
|
||||
{
|
||||
DefaultSort = new SortBehavior()
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ namespace MatterHackers.MatterControl.Library
|
|||
this.ChildContainers.Add(
|
||||
new DynamicContainerLink(
|
||||
() => printer.Settings.GetValue(SettingsKey.printer_name),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "sd_folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "printer_icon.png")),
|
||||
() => new PrinterContainer(printer),
|
||||
() =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@ namespace MatterHackers.MatterControl.Library
|
|||
this.ChildContainers.Add(
|
||||
new DynamicContainerLink(
|
||||
() => "SD Card".Localize(),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "sd_folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "folder.png")),
|
||||
AggContext.StaticData.LoadIcon(Path.Combine("Library", "sd_icon.png")),
|
||||
() => new SDCardContainer(printer),
|
||||
() =>
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue