From 7fc61ab713473968e3f6c8ad2ba34458a04ca4a7 Mon Sep 17 00:00:00 2001 From: Nick Vella Date: Sat, 29 Jun 2019 18:09:14 +1000 Subject: [PATCH 1/6] split post: ExtendedEntrySplitterElementBehavior: only synchronize the splitter width, not height. --- .../Behaviors/ExtendedEntrySplitterElementBehavior.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs index 9e4a9b23..94afcf31 100644 --- a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs +++ b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs @@ -91,8 +91,7 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing.Behaviors private void ExtendedEntrySplitterElementBehavior_ElementSizeChanged(object sender, EventArgs e) { //synchronized the splitter width with the new element width - Rectangle elementRect = ElementRectangle; - _splitter.VirtualSize = new Size(elementRect.Width, elementRect.Height); + _splitter.VirtualWidth = ElementRectangle.Width; } protected override void OnKeyDown(HtmlEventArgs e) From e77d0435859133b6138104e01b979e86474bb362 Mon Sep 17 00:00:00 2001 From: Nick Vella Date: Sat, 29 Jun 2019 18:09:56 +1000 Subject: [PATCH 2/6] split post: SplitterControl: set a static VirtualHeight of 16. A smarter way to acheive this would be by measuring the font height --- .../Behaviors/ExtendedEntrySplitterElementBehavior.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs index 94afcf31..77caa1e6 100644 --- a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs +++ b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs @@ -176,6 +176,7 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing.Behaviors private Font font = Res.GetFont(FontSize.PostSplitCaption, FontStyle.Regular); public SplitterControl() { + VirtualHeight = 16; } protected override void OnPaint(PaintEventArgs e) From 3eb2ad95139b377d2315c011ecde2091fa995471 Mon Sep 17 00:00:00 2001 From: Nick Vella Date: Sat, 29 Jun 2019 22:00:28 +1000 Subject: [PATCH 3/6] split post: ExtendedEntrySplitterElementBehavior, SplitterControl: set static splitter height of 16, refactor SplitterControl height code, pass SplitterControl height to constructor from ExtendedEntrySplitterElementBehavior, and compute splitter div height based on static splitter height. SplitterControl will no longer dynamically resize based on font size, but should not be an issue. --- .../ExtendedEntrySplitterElementBehavior.cs | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs index 77caa1e6..dc694b31 100644 --- a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs +++ b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs @@ -27,11 +27,15 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing.Behaviors internal class ExtendedEntrySplitterElementBehavior : ElementControlBehavior { private SplitterControl _splitter; - private const int _verticalPadding = 3; + + // _splitterHeight and _verticalPadding measured in 96dpi pixels + private const int _splitterHeight = 16; + private const int _verticalPadding = 2; + public ExtendedEntrySplitterElementBehavior(IHtmlEditorComponentContext editorContext) : base(editorContext) { - _splitter = new SplitterControl(); + _splitter = new SplitterControl(_splitterHeight); _splitter.VirtualLocation = new Point(0, _verticalPadding); Controls.Add(_splitter); @@ -41,10 +45,14 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing.Behaviors protected override void OnElementAttached() { + // Padding is applied to both top and bottom, so halve the splitter height + int cssVerticalPadding = (_splitterHeight / 2) + _verticalPadding; + IHTMLElement2 e2 = (IHTMLElement2)HTMLElement; - e2.runtimeStyle.padding = "0px 0px 0px 0px;"; - e2.runtimeStyle.margin = String.Format(CultureInfo.InvariantCulture, "{0}px 0px {0}px 0px;", _verticalPadding); + e2.runtimeStyle.padding = $"{cssVerticalPadding}px 0px {cssVerticalPadding}px 0px"; + e2.runtimeStyle.margin = "0px 0px 0px 0px"; e2.runtimeStyle.lineHeight = "16px"; + (e2 as IHTMLElement3).contentEditable = "false"; base.OnElementAttached(); @@ -174,9 +182,15 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing.Behaviors private Rectangle _lineRect; private string _moreText = Res.Get(StringId.SplitterMore); private Font font = Res.GetFont(FontSize.PostSplitCaption, FontStyle.Regular); - public SplitterControl() + + /// + /// Instansiates a new SplitterControl + /// + /// The 'virtual height' of the splitter. + /// Subtracting _lineRect.Height from this value yields the height of the 'More' rectangle on the end of the splitter line. + public SplitterControl(int virtualHeight) { - VirtualHeight = 16; + VirtualHeight = virtualHeight; } protected override void OnPaint(PaintEventArgs e) @@ -194,7 +208,8 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing.Behaviors int morePadding = 0; int moreRightOffset = 1; - Size moreRectSize = new Size(Convert.ToInt32(moreTextSize.Width) + morePadding * 2, Convert.ToInt32(moreTextSize.Height) + morePadding * 2); + Size moreRectSize = new Size(Convert.ToInt32(moreTextSize.Width) + morePadding * 2, + VirtualHeight - _lineRect.Height); Point moreRectLocation = new Point(_controlRect.Right - moreRectSize.Width - moreRightOffset, _lineRect.Bottom); Rectangle moreRect = new Rectangle(moreRectLocation, moreRectSize); From 6b8d3d1fe84c24451d5871ceb4fda039f39c6292 Mon Sep 17 00:00:00 2001 From: Nick Vella Date: Sat, 29 Jun 2019 22:51:09 +1000 Subject: [PATCH 4/6] DisplayHelper: scaling functions which automatically run Math.Ceiling --- .../DisplayHelper.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/managed/OpenLiveWriter.CoreServices/DisplayHelper.cs b/src/managed/OpenLiveWriter.CoreServices/DisplayHelper.cs index 8221c020..dbb58fd6 100644 --- a/src/managed/OpenLiveWriter.CoreServices/DisplayHelper.cs +++ b/src/managed/OpenLiveWriter.CoreServices/DisplayHelper.cs @@ -105,15 +105,11 @@ namespace OpenLiveWriter.CoreServices } } - public static float ScaleX(float x) - { - return x * ScalingFactorX; - } + public static float ScaleX(float x) => x * ScalingFactorX; + public static float ScaleY(float y) => y * ScalingFactorY; - public static float ScaleY(float y) - { - return y * ScalingFactorY; - } + public static int ScaleXCeil(float x) => (int)Math.Ceiling(x * ScalingFactorX); + public static int ScaleYCeil(float y) => (int)Math.Ceiling(y * ScalingFactorY); /// /// Scales a control from 96dpi to the actual screen dpi. @@ -136,10 +132,7 @@ namespace OpenLiveWriter.CoreServices /// public static Size ScaleSize(Size original) { - return new Size( - (int)Math.Ceiling(ScaleX(original.Width)), - (int)Math.Ceiling(ScaleY(original.Height)) - ); + return new Size(ScaleXCeil(original.Width), ScaleYCeil(original.Height)); } /// From 4fe0582645793d3e994a6033785b39f5f9613d35 Mon Sep 17 00:00:00 2001 From: Nick Vella Date: Sat, 29 Jun 2019 22:52:23 +1000 Subject: [PATCH 5/6] split post: ExtendedEntrySplitterElementBehavior, SplitterControl: make DPI aware --- .../ExtendedEntrySplitterElementBehavior.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs index dc694b31..9d596a78 100644 --- a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs +++ b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/ExtendedEntrySplitterElementBehavior.cs @@ -46,7 +46,7 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing.Behaviors protected override void OnElementAttached() { // Padding is applied to both top and bottom, so halve the splitter height - int cssVerticalPadding = (_splitterHeight / 2) + _verticalPadding; + int cssVerticalPadding = DisplayHelper.ScaleYCeil(_splitterHeight / 2 + _verticalPadding); IHTMLElement2 e2 = (IHTMLElement2)HTMLElement; e2.runtimeStyle.padding = $"{cssVerticalPadding}px 0px {cssVerticalPadding}px 0px"; @@ -186,11 +186,11 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing.Behaviors /// /// Instansiates a new SplitterControl /// - /// The 'virtual height' of the splitter. + /// The 'virtual height' of the splitter in 96 DPI pixels. /// Subtracting _lineRect.Height from this value yields the height of the 'More' rectangle on the end of the splitter line. - public SplitterControl(int virtualHeight) + public SplitterControl(int virtualHeight96) { - VirtualHeight = virtualHeight; + VirtualHeight = DisplayHelper.ScaleYCeil(virtualHeight96); } protected override void OnPaint(PaintEventArgs e) @@ -208,8 +208,8 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing.Behaviors int morePadding = 0; int moreRightOffset = 1; - Size moreRectSize = new Size(Convert.ToInt32(moreTextSize.Width) + morePadding * 2, - VirtualHeight - _lineRect.Height); + Size moreRectSize = new Size(Convert.ToInt32(moreTextSize.Width) + DisplayHelper.ScaleXCeil(morePadding * 2), + VirtualHeight - DisplayHelper.ScaleYCeil(_lineRect.Height)); Point moreRectLocation = new Point(_controlRect.Right - moreRectSize.Width - moreRightOffset, _lineRect.Bottom); Rectangle moreRect = new Rectangle(moreRectLocation, moreRectSize); @@ -231,7 +231,7 @@ namespace OpenLiveWriter.PostEditor.PostHtmlEditing.Behaviors protected override void OnLayout(EventArgs e) { _controlRect = new Rectangle(VirtualLocation, new Size(VirtualWidth, VirtualHeight)); - _lineRect = new Rectangle(new Point(0, 0), new Size(_controlRect.Width, 2)); + _lineRect = new Rectangle(new Point(0, 0), new Size(_controlRect.Width, DisplayHelper.ScaleYCeil(2))); } } } From e1a622f46e575642577dda393716af5f5185defb Mon Sep 17 00:00:00 2001 From: Nick Vella Date: Sat, 29 Jun 2019 22:57:09 +1000 Subject: [PATCH 6/6] split post: SplitterControl: tile splitter separator image to 255 pixels wide --- .../Images/ExtendedEntrySeparatorTile.png | Bin 138 -> 280 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/Images/ExtendedEntrySeparatorTile.png b/src/managed/OpenLiveWriter.PostEditor/PostHtmlEditing/Behaviors/Images/ExtendedEntrySeparatorTile.png index 455681e676b692d83e4aa14766dba65e02c77f2d..8ca5faecda95b7056ea22cb4d3f46193ee1a0408 100644 GIT binary patch literal 280 zcmeAS@N?(olHy`uVBq!ia0vp^|ACl^g9S+1@*ZjfQY`6?zK#qG8~eHcB(ehe3dtTp zz6=aiY77hwEes65fIWb6^2~~HslP3;**x%ULxG`~xOs5LN z#c6+?+%sWA{~8yZ*{7|3tF g{2E0=ZhlH;S|x4`dGE5rff^V*UHx3vIVCg!0R4kX!2kdN literal 138 zcmeAS@N?(olHy`uVBq!ia0vp^%s|Y}1B_t%QV14-i|9@kH iCJu!R20;c!Hioo&>}8)NxpxB9F?hQAxvX