From c97f4d8f8fed3b735d7d57712d764140ee8f270d Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Sat, 30 Aug 2014 16:03:28 -0700 Subject: [PATCH] Making MC be able to adapt to a global change in the point size of all text. --- ApplicationView/WidescreenPanel.cs | 4 ++-- CustomWidgets/PartThumbnailWidget.cs | 27 +++++++++++---------------- MatterControlApplication.cs | 2 ++ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/ApplicationView/WidescreenPanel.cs b/ApplicationView/WidescreenPanel.cs index 577bd8eb1..c271f88d5 100644 --- a/ApplicationView/WidescreenPanel.cs +++ b/ApplicationView/WidescreenPanel.cs @@ -65,8 +65,8 @@ namespace MatterHackers.MatterControl FlowLayoutWidget ColumnOne; FlowLayoutWidget ColumnTwo; FlowLayoutWidget ColumnThree; - int Max1ColumnWidth = 990; - int Max2ColumnWidth = 1590; + double Max1ColumnWidth = 990 * TextWidget.GlobalPointSizeScaleRatio; + double Max2ColumnWidth = 1590 * TextWidget.GlobalPointSizeScaleRatio; View3DTransformPart part3DView; ViewGcodeBasic partGcodeView; diff --git a/CustomWidgets/PartThumbnailWidget.cs b/CustomWidgets/PartThumbnailWidget.cs index eef3d497e..00d608bcd 100644 --- a/CustomWidgets/PartThumbnailWidget.cs +++ b/CustomWidgets/PartThumbnailWidget.cs @@ -101,20 +101,19 @@ namespace MatterHackers.MatterControl switch(size) { case ImageSizes.Size50x50: - this.Width = 50; - this.Height = 50; - this.MinimumSize = new Vector2(50, 50); + this.Width = 50 * TextWidget.GlobalPointSizeScaleRatio; + this.Height = 50 * TextWidget.GlobalPointSizeScaleRatio; break; case ImageSizes.Size115x115: - this.Width = 115; - this.Height = 115; - this.MinimumSize = new Vector2(115, 115); + this.Width = 115 * TextWidget.GlobalPointSizeScaleRatio; + this.Height = 115 * TextWidget.GlobalPointSizeScaleRatio; break; default: throw new NotImplementedException(); } + this.MinimumSize = new Vector2(this.Width, this.Height); this.BackgroundColor = normalBackgroundColor; this.Cursor = Cursors.Hand; @@ -172,26 +171,22 @@ namespace MatterHackers.MatterControl case ImageSizes.Size115x115: { ImageIO.LoadImageData(this.GetImageLocation("icon_sd_card_115x115.png"), thumbnailWidget.thumbnailImage); - thumbnailWidget.thumbnailImage.SetRecieveBlender(new BlenderPreMultBGRA()); - Graphics2D graphics = thumbnailWidget.thumbnailImage.NewGraphics2D(); - Ellipse outline = new Ellipse(new Vector2(115 / 2.0, 115 / 2.0), 50); - graphics.Render(new Stroke(outline, 4), RGBA_Bytes.White); } break; case ImageSizes.Size50x50: { ImageIO.LoadImageData(this.GetImageLocation("icon_sd_card_50x50.png"), thumbnailWidget.thumbnailImage); - thumbnailWidget.thumbnailImage.SetRecieveBlender(new BlenderPreMultBGRA()); - Graphics2D graphics = thumbnailWidget.thumbnailImage.NewGraphics2D(); - Ellipse outline = new Ellipse(new Vector2(50 / 2.0, 50 / 2.0), 22); - graphics.Render(new Stroke(outline, 1.5), RGBA_Bytes.White); } break; default: throw new NotImplementedException(); } + thumbnailWidget.thumbnailImage.SetRecieveBlender(new BlenderPreMultBGRA()); + Graphics2D graphics = thumbnailWidget.thumbnailImage.NewGraphics2D(); + Ellipse outline = new Ellipse(new Vector2(Width / 2.0, Height / 2.0), Width/2 + Width/12); + graphics.Render(new Stroke(outline, 4), RGBA_Bytes.White); UiThread.RunOnIdle(thumbnailWidget.EnsureImageUpdated); return; @@ -226,7 +221,7 @@ namespace MatterHackers.MatterControl halfWay2.NewGraphics2D().Clear(new RGBA_Bytes(255, 255, 255, 0)); halfWay2.NewGraphics2D().Render(halfWay1, 0, 0, 0, (double)halfWay2.Width / halfWay1.Width, (double)halfWay2.Height / halfWay1.Height); - thumbnailWidget.thumbnailImage = new ImageBuffer(50, 50, 32, new BlenderBGRA()); + thumbnailWidget.thumbnailImage = new ImageBuffer((int)Width, (int)Height, 32, new BlenderBGRA()); thumbnailWidget.thumbnailImage.NewGraphics2D().Clear(new RGBA_Bytes(255, 255, 255, 0)); thumbnailWidget.thumbnailImage.NewGraphics2D().Render(halfWay2, 0, 0, 0, (double)thumbnailWidget.thumbnailImage.Width / halfWay2.Width, (double)thumbnailWidget.thumbnailImage.Height / halfWay2.Height); } @@ -238,7 +233,7 @@ namespace MatterHackers.MatterControl halfWay1.NewGraphics2D().Clear(new RGBA_Bytes(255, 255, 255, 0)); halfWay1.NewGraphics2D().Render(bigRender, 0, 0, 0, (double)halfWay1.Width / bigRender.Width, (double)halfWay1.Height / bigRender.Height); - thumbnailWidget.thumbnailImage = new ImageBuffer(115, 115, 32, new BlenderBGRA()); + thumbnailWidget.thumbnailImage = new ImageBuffer((int)Width, (int)Height, 32, new BlenderBGRA()); thumbnailWidget.thumbnailImage.NewGraphics2D().Clear(new RGBA_Bytes(255, 255, 255, 0)); thumbnailWidget.thumbnailImage.NewGraphics2D().Render(halfWay1, 0, 0, 0, (double)thumbnailWidget.thumbnailImage.Width / halfWay1.Width, (double)thumbnailWidget.thumbnailImage.Height / halfWay1.Height); } diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index e244bcd5e..65771085b 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -110,6 +110,8 @@ namespace MatterHackers.MatterControl GuiWidget.DefaultEnforceIntegerBounds = true; + //TextWidget.GlobalPointSizeScaleRatio = 1.63; + this.AddChild(ApplicationWidget.Instance); this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off