Skip to content

Commit

Permalink
Merge pull request #8719 from RussKie/disable_toolbar_movement
Browse files Browse the repository at this point in the history
  • Loading branch information
RussKie committed Jan 18, 2021
2 parents 37e7501 + 43cf6b5 commit 9685011
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 28 deletions.
36 changes: 30 additions & 6 deletions GitUI/CommandsDialogs/FormBrowse.Designer.cs

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

43 changes: 21 additions & 22 deletions GitUI/CommandsDialogs/FormBrowse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ public FormBrowse([NotNull] GitUICommands commands, string filter, ObjectId sele

ManageWorktreeSupport();

WorkaroundToolbarLocationBug();

var toolBackColor = SystemColors.Window;
var toolForeColor = SystemColors.WindowText;
BackColor = toolBackColor;
Expand Down Expand Up @@ -318,6 +320,17 @@ public FormBrowse([NotNull] GitUICommands commands, string filter, ObjectId sele

return;

void WorkaroundToolbarLocationBug()
{
// Layout engine bug (?) which may change the order of toolbars
// if the 1st one becomes longer than the 2nd toolbar's Location.X
// the layout engine will be place the 2nd toolbar first
toolPanel.TopToolStripPanel.Controls.Clear();
toolPanel.TopToolStripPanel.Controls.Add(ToolStripScripts);
toolPanel.TopToolStripPanel.Controls.Add(ToolStripFilters);
toolPanel.TopToolStripPanel.Controls.Add(ToolStripMain);
}

void FocusRevisionDiffFileStatusList()
{
if (!revisionDiff.Visible)
Expand Down Expand Up @@ -446,6 +459,9 @@ void InitToolStripStyles(Color toolForeColor, Color toolBackColor)
ToolStripMain.ForeColor = toolForeColor;
ToolStripFilters.BackColor = toolBackColor;
ToolStripFilters.ForeColor = toolForeColor;
ToolStripScripts.BackColor = toolBackColor;
ToolStripScripts.ForeColor = toolForeColor;

toolStripRevisionFilterDropDownButton.BackColor = toolBackColor;
toolStripRevisionFilterDropDownButton.ForeColor = toolForeColor;

Expand Down Expand Up @@ -621,18 +637,7 @@ protected override void OnApplicationActivated()

protected override void OnLoad(EventArgs e)
{
// Removing the main menu before restoring the toolstrip layouts
// as it *does* randomly change the order of the defined items in the menu
Controls.Remove(mainMenuStrip);

toolPanel.TopToolStripPanel.SuspendLayout();
ToolStripManager.LoadSettings(this, "toolsettings");
toolPanel.TopToolStripPanel.ResumeLayout();

// Add the menu back
Controls.Add(mainMenuStrip);

_formBrowseMenus.CreateToolbarsMenus(ToolStripMain, ToolStripFilters);
_formBrowseMenus.CreateToolbarsMenus(ToolStripMain, ToolStripFilters, ToolStripScripts);

HideVariableMainMenuItems();
RefreshSplitViewLayout();
Expand Down Expand Up @@ -695,10 +700,6 @@ protected override void OnActivated(EventArgs e)

protected override void OnFormClosing(FormClosingEventArgs e)
{
// Remove the main menu to prevent its state being persisted
Controls.Remove(mainMenuStrip);

ToolStripManager.SaveSettings(this, "toolsettings");
SaveApplicationSettings();

foreach (var control in this.FindDescendants())
Expand Down Expand Up @@ -1119,11 +1120,11 @@ void LoadUserMenu()
.Where(script => script.Enabled && script.OnEvent == ScriptEvent.ShowInUserMenuBar)
.ToList();

for (int i = ToolStripMain.Items.Count - 1; i >= 0; i--)
for (int i = ToolStripScripts.Items.Count - 1; i >= 0; i--)
{
if (ToolStripMain.Items[i].Tag as string == "userscript")
if (ToolStripScripts.Items[i].Tag as string == "userscript")
{
ToolStripMain.Items.RemoveAt(i);
ToolStripScripts.Items.RemoveAt(i);
}
}

Expand All @@ -1132,8 +1133,6 @@ void LoadUserMenu()
return;
}

ToolStripMain.Items.Add(new ToolStripSeparator { Tag = "userscript" });

foreach (var script in scripts)
{
var button = new ToolStripButton
Expand All @@ -1156,7 +1155,7 @@ void LoadUserMenu()
};

// add to toolstrip
ToolStripMain.Items.Add(button);
ToolStripScripts.Items.Add(button);
}
}

Expand Down
3 changes: 3 additions & 0 deletions GitUI/CommandsDialogs/FormBrowse.resx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
<metadata name="ToolStripFilters.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>711, 17</value>
</metadata>
<metadata name="toolStripScripts.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>844, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>82</value>
</metadata>
Expand Down
4 changes: 4 additions & 0 deletions GitUI/Translation/English.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2132,6 +2132,10 @@ compare with first:</source>
<source>Standard</source>
<target />
</trans-unit>
<trans-unit id="ToolStripScripts.Text">
<source>Scripts</source>
<target />
</trans-unit>
<trans-unit id="TreeTabPage.Text">
<source>File tree</source>
<target />
Expand Down

0 comments on commit 9685011

Please sign in to comment.