mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-24 14:45:53 +00:00
Add escape to cancel range min/max change, commit change on focus loss
This commit is contained in:
@@ -33,8 +33,13 @@ namespace renderdocui.Controls
|
||||
// http://msdn.microsoft.com/en-us/library/ms404304(v=vs.90).aspx
|
||||
public class ToolStripSpringTextBox : ToolStripTextBox
|
||||
{
|
||||
public bool ResizeToFit = true;
|
||||
|
||||
public override Size GetPreferredSize(Size constrainingSize)
|
||||
{
|
||||
if (!ResizeToFit)
|
||||
return base.GetPreferredSize(constrainingSize);
|
||||
|
||||
// Use the default size if the text box is on the overflow menu
|
||||
// or is on a vertical ToolStrip.
|
||||
if (IsOnOverflow || Owner.Orientation == Orientation.Vertical)
|
||||
|
||||
+12
-6
@@ -89,8 +89,8 @@
|
||||
this.sliceFaceLabel = new System.Windows.Forms.ToolStripLabel();
|
||||
this.sliceFace = new System.Windows.Forms.ToolStripComboBox();
|
||||
this.rangeStrip = new System.Windows.Forms.ToolStrip();
|
||||
this.rangeBlack = new System.Windows.Forms.ToolStripTextBox();
|
||||
this.rangeWhite = new System.Windows.Forms.ToolStripTextBox();
|
||||
this.rangeBlack = new renderdocui.Controls.ToolStripSpringTextBox();
|
||||
this.rangeWhite = new renderdocui.Controls.ToolStripSpringTextBox();
|
||||
this.zoomRange = new System.Windows.Forms.ToolStripButton();
|
||||
this.autoFit = new System.Windows.Forms.ToolStripButton();
|
||||
this.reset01 = new System.Windows.Forms.ToolStripButton();
|
||||
@@ -635,14 +635,20 @@
|
||||
this.rangeBlack.Name = "rangeBlack";
|
||||
this.rangeBlack.Size = new System.Drawing.Size(50, 25);
|
||||
this.rangeBlack.Text = "0.0";
|
||||
this.rangeBlack.KeyDown += new System.Windows.Forms.KeyEventHandler(this.rangePoint_KeyDown);
|
||||
this.rangeBlack.ResizeToFit = false;
|
||||
this.rangeBlack.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.rangePoint_KeyPress);
|
||||
this.rangeBlack.Leave += new System.EventHandler(this.rangePoint_Leave);
|
||||
this.rangeBlack.TextChanged += new System.EventHandler(this.rangePoint_Changed);
|
||||
//
|
||||
// rangeWhite
|
||||
//
|
||||
this.rangeWhite.Name = "rangeWhite";
|
||||
this.rangeWhite.Size = new System.Drawing.Size(50, 25);
|
||||
this.rangeWhite.Text = "1.0";
|
||||
this.rangeWhite.KeyDown += new System.Windows.Forms.KeyEventHandler(this.rangePoint_KeyDown);
|
||||
this.rangeWhite.ResizeToFit = false;
|
||||
this.rangeWhite.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.rangePoint_KeyPress);
|
||||
this.rangeWhite.Leave += new System.EventHandler(this.rangePoint_Leave);
|
||||
this.rangeWhite.TextChanged += new System.EventHandler(this.rangePoint_Changed);
|
||||
//
|
||||
// zoomRange
|
||||
//
|
||||
@@ -1412,8 +1418,8 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem closeTab;
|
||||
private System.Windows.Forms.ToolStripMenuItem closeOtherTabs;
|
||||
private System.Windows.Forms.ToolStripMenuItem closeTabsToRight;
|
||||
private System.Windows.Forms.ToolStripTextBox rangeBlack;
|
||||
private System.Windows.Forms.ToolStripTextBox rangeWhite;
|
||||
private renderdocui.Controls.ToolStripSpringTextBox rangeBlack;
|
||||
private renderdocui.Controls.ToolStripSpringTextBox rangeWhite;
|
||||
private System.Windows.Forms.ToolStripButton zoomRange;
|
||||
private System.Windows.Forms.ToolStripButton reset01;
|
||||
private System.Windows.Forms.ToolStripButton autoFit;
|
||||
|
||||
@@ -234,6 +234,9 @@ namespace renderdocui.Windows
|
||||
mipLevel.Enabled = false;
|
||||
sliceFace.Enabled = false;
|
||||
|
||||
rangeBlack.ResizeToFit = false;
|
||||
rangeWhite.ResizeToFit = false;
|
||||
|
||||
PixelPicked = false;
|
||||
|
||||
mainLayout.Dock = DockStyle.Fill;
|
||||
@@ -2938,19 +2941,46 @@ namespace renderdocui.Windows
|
||||
}
|
||||
}
|
||||
|
||||
private void rangePoint_KeyDown(object sender, KeyEventArgs e)
|
||||
bool rangePoint_Dirty = false;
|
||||
|
||||
private void rangePoint_Changed(object sender, EventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
rangePoint_Dirty = true;
|
||||
}
|
||||
|
||||
private void rangePoint_Update()
|
||||
{
|
||||
float black = rangeHistogram.BlackPoint;
|
||||
float white = rangeHistogram.WhitePoint;
|
||||
|
||||
float.TryParse(rangeBlack.Text, out black);
|
||||
float.TryParse(rangeWhite.Text, out white);
|
||||
|
||||
rangeHistogram.SetRange(black, white);
|
||||
|
||||
m_Core.Renderer.BeginInvoke(RT_UpdateVisualRange);
|
||||
}
|
||||
|
||||
private void rangePoint_Leave(object sender, EventArgs e)
|
||||
{
|
||||
if (!rangePoint_Dirty) return;
|
||||
|
||||
rangePoint_Update();
|
||||
|
||||
rangePoint_Dirty = false;
|
||||
}
|
||||
|
||||
private void rangePoint_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
// escape key
|
||||
if (e.KeyChar == '\0')
|
||||
{
|
||||
float black = rangeHistogram.BlackPoint;
|
||||
float white = rangeHistogram.WhitePoint;
|
||||
|
||||
float.TryParse(rangeBlack.Text, out black);
|
||||
float.TryParse(rangeWhite.Text, out white);
|
||||
|
||||
rangeHistogram.SetRange(black, white);
|
||||
|
||||
m_Core.Renderer.BeginInvoke(RT_UpdateVisualRange);
|
||||
rangePoint_Dirty = false;
|
||||
rangeHistogram.SetRange(rangeHistogram.BlackPoint, rangeHistogram.WhitePoint);
|
||||
}
|
||||
if (e.KeyChar == '\n' || e.KeyChar == '\r')
|
||||
{
|
||||
rangePoint_Update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user