Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Src/LexText/LexTextControls/LexOptionsDlg.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Src/LexText/LexTextControls/LexOptionsDlg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,15 +494,15 @@ private void InitializeUIModeControls()
m_uiModeBetaWarning.Location = new System.Drawing.Point(pad, m_uiModeChooser.Bottom + pad);
m_uiModeGroup.Height = m_uiModeBetaWarning.Bottom + pad;

var delta = m_uiModeGroup.Bottom + pad - label4.Top;
var delta = m_uiModeGroup.Bottom + pad - m_labelAdvanced.Top;
if (delta > 0)
{
// label4 and m_autoOpenCheckBox sit on the Interface tab page and are top-anchored, so
// push them down manually to clear the injected UI-mode group. tabControl1 (Top+Bottom-
// m_labelAdvanced and m_autoOpenCheckBox sit on the Interface tab page and are top-anchored,
// so push them down manually to clear the injected UI-mode group. tabControl1 (Top+Bottom-
// anchored) and the OK/Cancel/Help buttons (Bottom-anchored) live on the form and are
// resized/repositioned automatically when the form grows, so they must NOT be moved by
// hand -- doing both shifts them by 2*delta and drops the buttons off the bottom edge.
label4.Top += delta;
m_labelAdvanced.Top += delta;
m_autoOpenCheckBox.Top += delta;
Height += delta;
}
Expand Down
32 changes: 16 additions & 16 deletions Src/LexText/LexTextControls/LexOptionsDlg.resx
Original file line number Diff line number Diff line change
Expand Up @@ -535,16 +535,16 @@ These anonymous statistics will help with future development.</value>
<data name="&gt;&gt;m_autoOpenCheckBox.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="&gt;&gt;label4.Name" xml:space="preserve">
<value>label4</value>
<data name="&gt;&gt;m_labelAdvanced.Name" xml:space="preserve">
<value>m_labelAdvanced</value>
</data>
<data name="&gt;&gt;label4.Type" xml:space="preserve">
<data name="&gt;&gt;m_labelAdvanced.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label4.Parent" xml:space="preserve">
<data name="&gt;&gt;m_labelAdvanced.Parent" xml:space="preserve">
<value>m_tabInterface</value>
</data>
<data name="&gt;&gt;label4.ZOrder" xml:space="preserve">
<data name="&gt;&gt;m_labelAdvanced.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="&gt;&gt;groupBox1.Name" xml:space="preserve">
Expand Down Expand Up @@ -617,34 +617,34 @@ always open the last edited project automatically</value>
<data name="&gt;&gt;m_autoOpenCheckBox.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="label4.AutoSize" type="System.Boolean, mscorlib">
<data name="m_labelAdvanced.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label4.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<data name="m_labelAdvanced.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="label4.Location" type="System.Drawing.Point, System.Drawing">
<data name="m_labelAdvanced.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 116</value>
</data>
<data name="label4.Size" type="System.Drawing.Size, System.Drawing">
<data name="m_labelAdvanced.Size" type="System.Drawing.Size, System.Drawing">
<value>59, 13</value>
</data>
<data name="label4.TabIndex" type="System.Int32, mscorlib">
<data name="m_labelAdvanced.TabIndex" type="System.Int32, mscorlib">
<value>13</value>
</data>
<data name="label4.Text" xml:space="preserve">
<data name="m_labelAdvanced.Text" xml:space="preserve">
<value>Advanced:</value>
</data>
<data name="&gt;&gt;label4.Name" xml:space="preserve">
<value>label4</value>
<data name="&gt;&gt;m_labelAdvanced.Name" xml:space="preserve">
<value>m_labelAdvanced</value>
</data>
<data name="&gt;&gt;label4.Type" xml:space="preserve">
<data name="&gt;&gt;m_labelAdvanced.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label4.Parent" xml:space="preserve">
<data name="&gt;&gt;m_labelAdvanced.Parent" xml:space="preserve">
<value>m_tabInterface</value>
</data>
<data name="&gt;&gt;label4.ZOrder" xml:space="preserve">
<data name="&gt;&gt;m_labelAdvanced.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="&gt;&gt;m_userInterfaceChooser.Name" xml:space="preserve">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void OkClick_LeavesLegacyWhenUserDoesNotChangeSelection()
/// <summary>
/// Regression test for a "double-shift" layout bug: InitializeUIModeControls() injects a new
/// GroupBox into an already-laid-out Interface tab and must grow the Form to make room. Controls
/// below the injection point that are top-anchored (label4, m_autoOpenCheckBox) don't move on
/// below the injection point that are top-anchored (m_labelAdvanced, m_autoOpenCheckBox) don't move on
/// their own, so the code moves them by hand. Controls that are bottom-anchored (tabControl1,
/// the OK/Cancel/Help buttons) already move/resize automatically as a side effect of Form.Height
/// growing — a prior version of this code ALSO manually re-added the same delta to those, which
Expand All @@ -81,37 +81,38 @@ public void InitializeUIModeControls_ShiftsTopAnchoredControlsOnce_NotDoubleShif
using (var dlg = new TestableLexOptionsDlg())
{
var uiModeGroup = FindControlRecursive(dlg, "m_uiModeGroup");
var label4 = FindControlRecursive(dlg, "label4");
var labelAdvanced = FindControlRecursive(dlg, "m_labelAdvanced");
var autoOpenCheckBox = FindControlRecursive(dlg, "m_autoOpenCheckBox");
var tabControl1 = FindControlRecursive(dlg, "tabControl1");
var btnOK = FindControlRecursive(dlg, "m_btnOK");
var btnCancel = FindControlRecursive(dlg, "m_btnCancel");
var btnHelp = FindControlRecursive(dlg, "m_btnHelp");

Assert.That(uiModeGroup, Is.Not.Null);
Assert.That(label4, Is.Not.Null);
Assert.That(labelAdvanced, Is.Not.Null);
Assert.That(autoOpenCheckBox, Is.Not.Null);
Assert.That(tabControl1, Is.Not.Null);
Assert.That(btnOK, Is.Not.Null);
Assert.That(btnCancel, Is.Not.Null);
Assert.That(btnHelp, Is.Not.Null);

var originalLabel4Top = ReadLexOptionsDlgResxPoint("label4.Location").Y;
var originalLabelAdvancedTop = ReadLexOptionsDlgResxPoint("m_labelAdvanced.Location").Y;
var originalAutoOpenTop = ReadLexOptionsDlgResxPoint("m_autoOpenCheckBox.Location").Y;
var originalTabControlHeight = ReadLexOptionsDlgResxSize("tabControl1.Size").Height;
var originalBtnOkTop = ReadLexOptionsDlgResxPoint("m_btnOK.Location").Y;
var originalBtnCancelTop = ReadLexOptionsDlgResxPoint("m_btnCancel.Location").Y;
var originalBtnHelpTop = ReadLexOptionsDlgResxPoint("m_btnHelp.Location").Y;

// The delta InitializeUIModeControls() computed to make room for the injected group box,
// derived from the group box's own (live) bottom edge rather than hardcoded, so this test
// doesn't need updating if m_uiModeGroup's own size/position ever changes.
var delta = uiModeGroup.Bottom + 8 - originalLabel4Top;
// One shift, measured from a control InitializeUIModeControls moves by hand. Deriving it
// from observed layout rather than recomputing the padding formula keeps this test about
// the relationship -- every affected control moves exactly once -- not the arithmetic.
var delta = labelAdvanced.Top - originalLabelAdvancedTop;
Assert.That(delta, Is.GreaterThan(0),
"precondition: the injected group box must actually require extra room for this test to exercise the shift logic");
Assert.That(uiModeGroup.Bottom, Is.LessThanOrEqualTo(labelAdvanced.Top),
"the injected group must clear the control it pushed down");

// Top-anchored controls: moved by hand, must shift by exactly delta.
Assert.That(label4.Top, Is.EqualTo(originalLabel4Top + delta));
// The other hand-moved, top-anchored control must shift by the same single delta.
Assert.That(autoOpenCheckBox.Top, Is.EqualTo(originalAutoOpenTop + delta));

// Bottom-anchored controls: WinForms repositions/resizes these automatically as a side
Expand Down
Loading