Apparently UserControls that are created dynamically need AutoScaleMode.Font. UserControls placed via the designer should use AutoScaleMode.Inherit. Actually it seems possible to get around the problems of dynamically created UserControls (including the need to manually scale the positions/sizes) by moving their creation into the constructor after InitializeComponent, adding SuspendLayout before InitializeComponent, and adding ResumeLayout after UserControl creation. But I don't want to risk moving the code around too much.
This commit is contained in:
parent
008b35a93d
commit
eacadc8e09
|
@ -6,8 +6,9 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
public static class UIHelper
|
||||
{
|
||||
private static SizeF _autoScaleBaseSize = new SizeF(6F, 13F);
|
||||
private static SizeF _autoScaleCurrentSize = GetCurrentAutoScaleSize(AutoScaleMode.Font);
|
||||
private static readonly AutoScaleMode _autoScaleMode = AutoScaleMode.Font;
|
||||
private static readonly SizeF _autoScaleBaseSize = new SizeF(6F, 13F);
|
||||
private static readonly SizeF _autoScaleCurrentSize = GetCurrentAutoScaleSize(_autoScaleMode);
|
||||
|
||||
private static SizeF GetCurrentAutoScaleSize(AutoScaleMode autoScaleMode)
|
||||
{
|
||||
|
@ -18,6 +19,16 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
}
|
||||
|
||||
public static AutoScaleMode AutoScaleMode
|
||||
{
|
||||
get { return _autoScaleMode; }
|
||||
}
|
||||
|
||||
public static SizeF AutoScaleBaseSize
|
||||
{
|
||||
get { return _autoScaleBaseSize; }
|
||||
}
|
||||
|
||||
public static float AutoScaleFactorX
|
||||
{
|
||||
get { return _autoScaleCurrentSize.Width / _autoScaleBaseSize.Width; }
|
||||
|
|
|
@ -84,7 +84,8 @@
|
|||
//
|
||||
// BizBoxInfoControl
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.CoreUrlLink);
|
||||
this.Controls.Add(this.CorePortedLabel);
|
||||
this.Controls.Add(this.CoreAuthorLabel);
|
||||
|
|
|
@ -136,7 +136,8 @@
|
|||
//
|
||||
// AnalogBindControl
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.buttonUnbind);
|
||||
this.Controls.Add(this.buttonFlip);
|
||||
this.Controls.Add(this.labelDeadzone);
|
||||
|
|
|
@ -50,7 +50,8 @@
|
|||
//
|
||||
// ControllerConfigPanel
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ContextMenuStrip = this.contextMenuStrip1;
|
||||
this.Name = "ControllerConfigPanel";
|
||||
this.Size = new System.Drawing.Size(203, 292);
|
||||
|
|
|
@ -52,7 +52,8 @@
|
|||
//
|
||||
// FileExtensionPreferencesPicker
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.PlatformDropdown);
|
||||
this.Controls.Add(this.FileExtensionLabel);
|
||||
this.Name = "FileExtensionPreferencesPicker";
|
||||
|
|
|
@ -79,7 +79,8 @@
|
|||
//
|
||||
// InputCompositeWidget
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.Name = "InputCompositeWidget";
|
||||
this.Size = new System.Drawing.Size(492, 20);
|
||||
|
|
|
@ -44,7 +44,8 @@
|
|||
//
|
||||
// VirtualPad
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.PadBox);
|
||||
this.Name = "VirtualPad";
|
||||
this.Load += new System.EventHandler(this.VirtualPadControl_Load);
|
||||
|
|
|
@ -62,7 +62,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
PadBox.Text = _schema.DisplayName;
|
||||
foreach (var button in _schema.Buttons)
|
||||
{
|
||||
// TODO: Size of all controls should ideally be scaled, only implemented on button for now
|
||||
switch (button.Type)
|
||||
{
|
||||
case PadSchema.PadInputType.Boolean:
|
||||
|
@ -86,7 +85,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
Name = button.Name,
|
||||
Location = UIHelper.Scale(button.Location),
|
||||
Size = new Size(button.MaxValue + 79, button.MaxValue + 9), // TODO: don't use hardcoded values here, at least make them defaults in the AnalogStick object itself
|
||||
Size = UIHelper.Scale(new Size(button.MaxValue + 79, button.MaxValue + 9)), // TODO: don't use hardcoded values here, at least make them defaults in the AnalogStick object itself
|
||||
RangeX = button.MaxValue,
|
||||
RangeY = button.MaxValue // TODO ability to pass in a different Y max
|
||||
});
|
||||
|
@ -96,7 +95,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
Name = button.Name,
|
||||
Location = UIHelper.Scale(button.Location),
|
||||
Size = button.TargetSize,
|
||||
Size = button.TargetSize, // TODO: Scale size without messing up X/Y range
|
||||
XName = button.Name,
|
||||
YName = button.SecondaryNames[0],
|
||||
RangeX = button.MaxValue,
|
||||
|
@ -109,7 +108,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Name = button.Name,
|
||||
DisplayName = button.DisplayName,
|
||||
Location = UIHelper.Scale(button.Location),
|
||||
Size = button.TargetSize,
|
||||
Size = UIHelper.Scale(button.TargetSize),
|
||||
MinValue = button.MinValue,
|
||||
MaxValue = button.MaxValue
|
||||
});
|
||||
|
@ -120,7 +119,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Name = button.Name,
|
||||
//DisplayName = button.DisplayName,
|
||||
Location = UIHelper.Scale(button.Location),
|
||||
Size = button.TargetSize,
|
||||
Size = UIHelper.Scale(button.TargetSize),
|
||||
OwnerEmulator = button.OwnerEmulator
|
||||
});
|
||||
break;
|
||||
|
|
|
@ -65,7 +65,8 @@
|
|||
//
|
||||
// VirtualPadAnalogButton
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.ValueLabel);
|
||||
this.Controls.Add(this.DisplayNameLabel);
|
||||
this.Controls.Add(this.AnalogTrackBar);
|
||||
|
|
|
@ -175,7 +175,8 @@
|
|||
//
|
||||
// VirtualPadAnalogStick
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.MaxYNumeric);
|
||||
this.Controls.Add(this.MaxXNumeric);
|
||||
this.Controls.Add(this.MaxLabel);
|
||||
|
|
|
@ -110,7 +110,8 @@
|
|||
//
|
||||
// VirtualPadDiscManager
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
|
||||
this.Controls.Add(this.btnInsert);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
|
|
Loading…
Reference in New Issue