UI: DPI-related fixes/improvements
This commit is contained in:
parent
95500e6dce
commit
aa899d6b35
7 changed files with 60 additions and 13 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Mesen.GUI.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
@ -191,6 +192,12 @@ namespace Mesen.GUI.Controls
|
|||
if(this.Height < 21) {
|
||||
this.Height = 21;
|
||||
}
|
||||
|
||||
double scale = (double)this.Height / 21;
|
||||
if(scale > 1) {
|
||||
btnDown.Image = Properties.Resources.NudDownArrow.GetScaledImage(scale);
|
||||
btnUp.Image = Properties.Resources.NudUpArrow.GetScaledImage(scale);
|
||||
}
|
||||
}
|
||||
|
||||
private void txtValue_KeyDown(object sender, KeyEventArgs e)
|
||||
|
|
|
@ -16,8 +16,7 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
private Timer _tmrScroll;
|
||||
private bool _scrollUp = false;
|
||||
private bool _mouseDown = false;
|
||||
|
||||
private const int _buttonSize = 15;
|
||||
private int _buttonSize = 15;
|
||||
|
||||
private IScrollbarColorProvider _colorProvider = null;
|
||||
public IScrollbarColorProvider ColorProvider
|
||||
|
@ -58,6 +57,9 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
int width = rect.Width;
|
||||
e.Graphics.FillRectangle(Brushes.DimGray, rect);
|
||||
|
||||
double scale = (double)width / 18;
|
||||
_buttonSize = (int)(15 * scale);
|
||||
|
||||
int barTop = rect.Top + _buttonSize;
|
||||
int barHeight = this.Height - _buttonSize * 2;
|
||||
|
||||
|
@ -90,9 +92,9 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
|
||||
float highlightTop = barTop + barHeight * startPos - HighlightOffset;
|
||||
using(SolidBrush brush = new SolidBrush(Color.FromArgb(120, 220, 220, 255))) {
|
||||
e.Graphics.FillRectangle(brush, left + 1, highlightTop, width, HighlightHeight - 2);
|
||||
e.Graphics.DrawRectangle(Pens.DarkSlateGray, left + 1, highlightTop, width - 2, HighlightHeight - 2);
|
||||
e.Graphics.DrawRectangle(Pens.Gray, left + 2, highlightTop + 1, width - 4, HighlightHeight - 4);
|
||||
e.Graphics.FillRectangle(brush, left + 1, highlightTop, width, (int)(HighlightHeight * scale) - 2);
|
||||
e.Graphics.DrawRectangle(Pens.DarkSlateGray, left + 1, highlightTop, width - 2, (int)(HighlightHeight * scale) - 2);
|
||||
e.Graphics.DrawRectangle(Pens.Gray, left + 2, highlightTop + 1, width - 4, (int)(HighlightHeight * scale) - 4);
|
||||
}
|
||||
|
||||
if(this.ColorProvider != null) {
|
||||
|
@ -123,8 +125,8 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
}
|
||||
}
|
||||
|
||||
int arrowWidth = 10;
|
||||
int arrowHeight = 5;
|
||||
int arrowWidth = (int)(10 * scale);
|
||||
int arrowHeight = (int)(5 * scale);
|
||||
int bottom = barTop + barHeight + _buttonSize;
|
||||
e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
e.Graphics.FillRectangle(Brushes.Gainsboro, rect.Left + 1, rect.Top, this.Width - 1, _buttonSize);
|
||||
|
@ -132,8 +134,10 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
e.Graphics.DrawLine(Pens.DimGray, rect.Left + 1, rect.Top + _buttonSize, rect.Left + width, rect.Top + _buttonSize);
|
||||
e.Graphics.DrawLine(Pens.DimGray, rect.Left + 1, bottom - _buttonSize, rect.Left + width, bottom - _buttonSize);
|
||||
e.Graphics.DrawLine(Pens.DimGray, rect.Left + 1, bottom, rect.Left + width, bottom);
|
||||
e.Graphics.TranslateTransform(5, (_buttonSize - arrowHeight) / 2);
|
||||
|
||||
e.Graphics.TranslateTransform((int)(5 * scale), (_buttonSize - arrowHeight) / 2);
|
||||
e.Graphics.FillPolygon(Brushes.DimGray, new Point[] { new Point(left, rect.Top + arrowHeight), new Point(left + arrowWidth, rect.Top + arrowHeight), new Point(left + arrowWidth / 2, rect.Top) }, FillMode.Winding);
|
||||
|
||||
e.Graphics.TranslateTransform(0, -(_buttonSize - arrowHeight));
|
||||
e.Graphics.FillPolygon(Brushes.DimGray, new Point[] { new Point(left, bottom - arrowHeight), new Point(left + arrowWidth, bottom - arrowHeight), new Point(left + arrowWidth / 2, bottom) }, FillMode.Winding);
|
||||
}
|
||||
|
|
10
UI/Debugger/PpuViewer/frmPaletteViewer.Designer.cs
generated
10
UI/Debugger/PpuViewer/frmPaletteViewer.Designer.cs
generated
|
@ -50,7 +50,7 @@
|
|||
// ctrlScanlineCycleSelect
|
||||
//
|
||||
this.ctrlScanlineCycleSelect.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.ctrlScanlineCycleSelect.Location = new System.Drawing.Point(0, 263);
|
||||
this.ctrlScanlineCycleSelect.Location = new System.Drawing.Point(0, 275);
|
||||
this.ctrlScanlineCycleSelect.Name = "ctrlScanlineCycleSelect";
|
||||
this.ctrlScanlineCycleSelect.Size = new System.Drawing.Size(398, 28);
|
||||
this.ctrlScanlineCycleSelect.TabIndex = 5;
|
||||
|
@ -68,7 +68,7 @@
|
|||
this.tableLayoutPanel1.RowCount = 2;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(398, 263);
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(398, 275);
|
||||
this.tableLayoutPanel1.TabIndex = 7;
|
||||
//
|
||||
// ctrlPaletteViewer
|
||||
|
@ -76,9 +76,11 @@
|
|||
this.ctrlPaletteViewer.Location = new System.Drawing.Point(3, 3);
|
||||
this.ctrlPaletteViewer.Name = "ctrlPaletteViewer";
|
||||
this.ctrlPaletteViewer.PaletteScale = 16;
|
||||
this.ctrlPaletteViewer.SelectedPalette = 0;
|
||||
this.ctrlPaletteViewer.SelectionMode = Mesen.GUI.Debugger.PaletteSelectionMode.SingleColor;
|
||||
this.ctrlPaletteViewer.Size = new System.Drawing.Size(256, 256);
|
||||
this.ctrlPaletteViewer.TabIndex = 0;
|
||||
this.ctrlPaletteViewer.TabStop = false;
|
||||
this.ctrlPaletteViewer.SelectionChanged += new Mesen.GUI.Debugger.ctrlPaletteViewer.SelectionChangedHandler(this.ctrlPaletteViewer_SelectionChanged);
|
||||
//
|
||||
// tableLayoutPanel2
|
||||
|
@ -109,7 +111,7 @@
|
|||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel2.Size = new System.Drawing.Size(130, 257);
|
||||
this.tableLayoutPanel2.Size = new System.Drawing.Size(136, 269);
|
||||
this.tableLayoutPanel2.TabIndex = 1;
|
||||
//
|
||||
// txtR
|
||||
|
@ -224,7 +226,7 @@
|
|||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(398, 291);
|
||||
this.ClientSize = new System.Drawing.Size(398, 303);
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.Controls.Add(this.ctrlScanlineCycleSelect);
|
||||
this.Name = "frmPaletteViewer";
|
||||
|
|
|
@ -27,6 +27,9 @@ namespace Mesen.GUI.Debugger
|
|||
_refreshManager.AutoRefresh = true;
|
||||
ctrlScanlineCycleSelect.Initialize(241, 0);
|
||||
|
||||
double scale = (double)ctrlPaletteViewer.Width / 256;
|
||||
ctrlPaletteViewer.PaletteScale = (int)(16 * scale);
|
||||
|
||||
ctrlPaletteViewer.RefreshData();
|
||||
ctrlPaletteViewer.RefreshViewer();
|
||||
UpdateFields();
|
||||
|
|
|
@ -74,6 +74,9 @@ namespace Mesen.GUI.Debugger
|
|||
chkShowTileGrid.Checked = config.ShowTileGrid;
|
||||
ctrlImagePanel.ImageScale = config.ImageScale;
|
||||
ctrlScanlineCycleSelect.Initialize(config.RefreshScanline, config.RefreshCycle);
|
||||
|
||||
double scale = (double)ctrlPaletteViewer.Width / 176;
|
||||
ctrlPaletteViewer.PaletteScale = (int)(11 * scale);
|
||||
ctrlPaletteViewer.SelectedPalette = config.SelectedPalette;
|
||||
|
||||
nudSize.Increment = 0x1000;
|
||||
|
|
|
@ -980,6 +980,7 @@
|
|||
<Compile Include="Utilities\CommandLineHelper.cs" />
|
||||
<Compile Include="Utilities\FolderHelper.cs" />
|
||||
<Compile Include="Utilities\HexConverter.cs" />
|
||||
<Compile Include="Utilities\ImageExtensions.cs" />
|
||||
<Compile Include="Utilities\InBackgroundHelper.cs" />
|
||||
<Compile Include="Utilities\Md5Helper.cs" />
|
||||
<Compile Include="Updates\UpdateHelper.cs" />
|
||||
|
|
27
UI/Utilities/ImageExtensions.cs
Normal file
27
UI/Utilities/ImageExtensions.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Mesen.GUI.Utilities
|
||||
{
|
||||
static class ImageExtensions
|
||||
{
|
||||
public static Image GetScaledImage(this Image img, double scale)
|
||||
{
|
||||
int newWidth = (int)(img.Width * scale);
|
||||
int newHeight = (int)(img.Height * scale);
|
||||
|
||||
Bitmap scaledImg = new Bitmap(newWidth, newHeight);
|
||||
using(Graphics g = Graphics.FromImage(scaledImg)) {
|
||||
g.InterpolationMode = scale >= 2 ? InterpolationMode.NearestNeighbor : InterpolationMode.HighQualityBicubic;
|
||||
g.DrawImage(img, 0, 0, newWidth, newHeight);
|
||||
}
|
||||
|
||||
return scaledImg;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue