Texture browser: using the tab key to jump between the currently selected used texture and the position of the texture in the list of all textures works again (this time without toggling the "used textures on top" checkbox). Also added option to vertically center the view on the selected texture (enabled by default)

This commit is contained in:
biwa 2020-11-01 18:21:22 +01:00
parent eab7de4f9e
commit 15772da839
4 changed files with 469 additions and 337 deletions

View file

@ -29,128 +29,144 @@ namespace CodeImp.DoomBuilder.Controls
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.labelMixMode = new System.Windows.Forms.Label();
this.label = new System.Windows.Forms.Label();
this.splitter = new System.Windows.Forms.SplitContainer();
this.list = new CodeImp.DoomBuilder.Controls.ImageSelectorPanel();
this.classicview = new System.Windows.Forms.CheckBox();
this.objectclear = new System.Windows.Forms.Button();
this.sizecombo = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.usedtexturesfirst = new System.Windows.Forms.CheckBox();
this.longtexturenames = new System.Windows.Forms.CheckBox();
this.filterheightlabel = new System.Windows.Forms.Label();
this.filterHeight = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.filterwidthlabel = new System.Windows.Forms.Label();
this.filterWidth = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.texturetypecombo = new System.Windows.Forms.ComboBox();
this.objectname = new System.Windows.Forms.TextBox();
this.refreshtimer = new System.Windows.Forms.Timer(this.components);
this.splitter.Panel1.SuspendLayout();
this.splitter.Panel2.SuspendLayout();
this.splitter.SuspendLayout();
this.SuspendLayout();
//
// labelMixMode
//
this.labelMixMode.AutoSize = true;
this.labelMixMode.Location = new System.Drawing.Point(3, 8);
this.labelMixMode.Name = "labelMixMode";
this.labelMixMode.Size = new System.Drawing.Size(37, 13);
this.labelMixMode.TabIndex = 0;
this.labelMixMode.Text = "Show:";
//
// label
//
this.label.AutoSize = true;
this.label.Location = new System.Drawing.Point(164, 9);
this.label.Name = "label";
this.label.Size = new System.Drawing.Size(32, 13);
this.label.TabIndex = 0;
this.label.Text = "Filter:";
//
// splitter
//
this.splitter.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitter.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.splitter.IsSplitterFixed = true;
this.splitter.Location = new System.Drawing.Point(0, 0);
this.splitter.Name = "splitter";
this.splitter.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitter.Panel1
//
this.splitter.Panel1.Controls.Add(this.list);
//
// splitter.Panel2
//
this.splitter.Panel2.Controls.Add(this.classicview);
this.splitter.Panel2.Controls.Add(this.objectclear);
this.splitter.Panel2.Controls.Add(this.sizecombo);
this.splitter.Panel2.Controls.Add(this.label1);
this.splitter.Panel2.Controls.Add(this.usedtexturesfirst);
this.splitter.Panel2.Controls.Add(this.longtexturenames);
this.splitter.Panel2.Controls.Add(this.filterheightlabel);
this.splitter.Panel2.Controls.Add(this.filterHeight);
this.splitter.Panel2.Controls.Add(this.filterwidthlabel);
this.splitter.Panel2.Controls.Add(this.filterWidth);
this.splitter.Panel2.Controls.Add(this.texturetypecombo);
this.splitter.Panel2.Controls.Add(this.labelMixMode);
this.splitter.Panel2.Controls.Add(this.objectname);
this.splitter.Panel2.Controls.Add(this.label);
this.splitter.Size = new System.Drawing.Size(840, 346);
this.splitter.SplitterDistance = 284;
this.splitter.TabIndex = 0;
this.splitter.TabStop = false;
//
// list
//
this.list.AutoScroll = true;
this.list.BackColor = System.Drawing.Color.White;
this.list.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.list.ClassicView = false;
this.list.ContentType = "Textures";
this.list.Dock = System.Windows.Forms.DockStyle.Fill;
this.list.HideSelection = false;
this.list.ImageSize = 128;
this.list.Location = new System.Drawing.Point(0, 0);
this.list.MultiSelect = false;
this.list.Name = "list";
this.list.Size = new System.Drawing.Size(840, 284);
this.list.TabIndex = 1;
this.list.Title = "Default group";
this.list.ItemDoubleClicked += new CodeImp.DoomBuilder.Controls.ImageSelectorPanel.ItemSelectedEventHandler(this.list_ItemDoubleClicked);
this.list.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.list_KeyPress);
//
// classicview
//
this.classicview.AutoSize = true;
this.classicview.Location = new System.Drawing.Point(510, 8);
this.classicview.Name = "classicview";
this.classicview.Size = new System.Drawing.Size(84, 17);
this.classicview.TabIndex = 4;
this.classicview.TabStop = false;
this.classicview.Text = "Classic view";
this.classicview.UseVisualStyleBackColor = true;
this.classicview.CheckedChanged += new System.EventHandler(this.classicview_CheckedChanged);
//
// objectclear
//
this.objectclear.Image = global::CodeImp.DoomBuilder.Properties.Resources.Close;
this.objectclear.Location = new System.Drawing.Point(330, 4);
this.objectclear.Name = "objectclear";
this.objectclear.Size = new System.Drawing.Size(26, 23);
this.objectclear.TabIndex = 3;
this.objectclear.TabStop = false;
this.objectclear.UseVisualStyleBackColor = true;
this.objectclear.Click += new System.EventHandler(this.objectclear_Click);
//
// sizecombo
//
this.sizecombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.sizecombo.FormattingEnabled = true;
this.sizecombo.Items.AddRange(new object[] {
this.components = new System.ComponentModel.Container();
this.labelMixMode = new System.Windows.Forms.Label();
this.label = new System.Windows.Forms.Label();
this.splitter = new System.Windows.Forms.SplitContainer();
this.list = new CodeImp.DoomBuilder.Controls.ImageSelectorPanel();
this.centeritem = new System.Windows.Forms.CheckBox();
this.classicview = new System.Windows.Forms.CheckBox();
this.objectclear = new System.Windows.Forms.Button();
this.sizecombo = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.usedtexturesfirst = new System.Windows.Forms.CheckBox();
this.longtexturenames = new System.Windows.Forms.CheckBox();
this.filterheightlabel = new System.Windows.Forms.Label();
this.filterHeight = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.filterwidthlabel = new System.Windows.Forms.Label();
this.filterWidth = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.texturetypecombo = new System.Windows.Forms.ComboBox();
this.objectname = new System.Windows.Forms.TextBox();
this.refreshtimer = new System.Windows.Forms.Timer(this.components);
((System.ComponentModel.ISupportInitialize)(this.splitter)).BeginInit();
this.splitter.Panel1.SuspendLayout();
this.splitter.Panel2.SuspendLayout();
this.splitter.SuspendLayout();
this.SuspendLayout();
//
// labelMixMode
//
this.labelMixMode.AutoSize = true;
this.labelMixMode.Location = new System.Drawing.Point(3, 8);
this.labelMixMode.Name = "labelMixMode";
this.labelMixMode.Size = new System.Drawing.Size(37, 13);
this.labelMixMode.TabIndex = 0;
this.labelMixMode.Text = "Show:";
//
// label
//
this.label.AutoSize = true;
this.label.Location = new System.Drawing.Point(164, 9);
this.label.Name = "label";
this.label.Size = new System.Drawing.Size(32, 13);
this.label.TabIndex = 0;
this.label.Text = "Filter:";
//
// splitter
//
this.splitter.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitter.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.splitter.IsSplitterFixed = true;
this.splitter.Location = new System.Drawing.Point(0, 0);
this.splitter.Name = "splitter";
this.splitter.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitter.Panel1
//
this.splitter.Panel1.Controls.Add(this.list);
//
// splitter.Panel2
//
this.splitter.Panel2.Controls.Add(this.centeritem);
this.splitter.Panel2.Controls.Add(this.classicview);
this.splitter.Panel2.Controls.Add(this.objectclear);
this.splitter.Panel2.Controls.Add(this.sizecombo);
this.splitter.Panel2.Controls.Add(this.label1);
this.splitter.Panel2.Controls.Add(this.usedtexturesfirst);
this.splitter.Panel2.Controls.Add(this.longtexturenames);
this.splitter.Panel2.Controls.Add(this.filterheightlabel);
this.splitter.Panel2.Controls.Add(this.filterHeight);
this.splitter.Panel2.Controls.Add(this.filterwidthlabel);
this.splitter.Panel2.Controls.Add(this.filterWidth);
this.splitter.Panel2.Controls.Add(this.texturetypecombo);
this.splitter.Panel2.Controls.Add(this.labelMixMode);
this.splitter.Panel2.Controls.Add(this.objectname);
this.splitter.Panel2.Controls.Add(this.label);
this.splitter.Size = new System.Drawing.Size(840, 346);
this.splitter.SplitterDistance = 284;
this.splitter.TabIndex = 0;
this.splitter.TabStop = false;
//
// list
//
this.list.AutoScroll = true;
this.list.BackColor = System.Drawing.Color.White;
this.list.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.list.ClassicView = false;
this.list.ContentType = "Textures";
this.list.Dock = System.Windows.Forms.DockStyle.Fill;
this.list.HideSelection = false;
this.list.ImageSize = 128;
this.list.Location = new System.Drawing.Point(0, 0);
this.list.MultiSelect = false;
this.list.Name = "list";
this.list.Size = new System.Drawing.Size(840, 284);
this.list.TabIndex = 1;
this.list.Title = "Default group";
this.list.UsedTexturesFirst = false;
this.list.ItemDoubleClicked += new CodeImp.DoomBuilder.Controls.ImageSelectorPanel.ItemSelectedEventHandler(this.list_ItemDoubleClicked);
this.list.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.list_KeyPress);
//
// centeritem
//
this.centeritem.AutoSize = true;
this.centeritem.Location = new System.Drawing.Point(510, 34);
this.centeritem.Name = "centeritem";
this.centeritem.Size = new System.Drawing.Size(146, 17);
this.centeritem.TabIndex = 5;
this.centeritem.TabStop = false;
this.centeritem.Text = "Vertically center selection";
this.centeritem.UseVisualStyleBackColor = true;
this.centeritem.CheckedChanged += new System.EventHandler(this.centeritem_CheckedChanged);
//
// classicview
//
this.classicview.AutoSize = true;
this.classicview.Location = new System.Drawing.Point(510, 8);
this.classicview.Name = "classicview";
this.classicview.Size = new System.Drawing.Size(84, 17);
this.classicview.TabIndex = 4;
this.classicview.TabStop = false;
this.classicview.Text = "Classic view";
this.classicview.UseVisualStyleBackColor = true;
this.classicview.CheckedChanged += new System.EventHandler(this.classicview_CheckedChanged);
//
// objectclear
//
this.objectclear.Image = global::CodeImp.DoomBuilder.Properties.Resources.Close;
this.objectclear.Location = new System.Drawing.Point(330, 4);
this.objectclear.Name = "objectclear";
this.objectclear.Size = new System.Drawing.Size(26, 23);
this.objectclear.TabIndex = 3;
this.objectclear.TabStop = false;
this.objectclear.UseVisualStyleBackColor = true;
this.objectclear.Click += new System.EventHandler(this.objectclear_Click);
//
// sizecombo
//
this.sizecombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.sizecombo.FormattingEnabled = true;
this.sizecombo.Items.AddRange(new object[] {
"1:1",
"64",
"80",
@ -158,152 +174,153 @@ namespace CodeImp.DoomBuilder.Controls
"128",
"192",
"256"});
this.sizecombo.Location = new System.Drawing.Point(43, 32);
this.sizecombo.Margin = new System.Windows.Forms.Padding(3, 3, 6, 3);
this.sizecombo.Name = "sizecombo";
this.sizecombo.Size = new System.Drawing.Size(107, 21);
this.sizecombo.TabIndex = 2;
this.sizecombo.TabStop = false;
this.sizecombo.SelectedIndexChanged += new System.EventHandler(this.sizecombo_SelectedIndexChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(10, 35);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(30, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Size:";
//
// usedtexturesfirst
//
this.usedtexturesfirst.AutoSize = true;
this.usedtexturesfirst.Location = new System.Drawing.Point(365, 8);
this.usedtexturesfirst.Name = "usedtexturesfirst";
this.usedtexturesfirst.Size = new System.Drawing.Size(139, 17);
this.usedtexturesfirst.TabIndex = 0;
this.usedtexturesfirst.TabStop = false;
this.usedtexturesfirst.Text = "Used textures at the top";
this.usedtexturesfirst.UseVisualStyleBackColor = true;
this.usedtexturesfirst.CheckedChanged += new System.EventHandler(this.usedtexturesfirst_CheckedChanged);
//
// longtexturenames
//
this.longtexturenames.AutoSize = true;
this.longtexturenames.Location = new System.Drawing.Point(365, 34);
this.longtexturenames.Name = "longtexturenames";
this.longtexturenames.Size = new System.Drawing.Size(119, 17);
this.longtexturenames.TabIndex = 0;
this.longtexturenames.TabStop = false;
this.longtexturenames.Text = "Long texture names";
this.longtexturenames.UseVisualStyleBackColor = true;
this.longtexturenames.CheckedChanged += new System.EventHandler(this.longtexturenames_CheckedChanged);
//
// filterheightlabel
//
this.filterheightlabel.AutoSize = true;
this.filterheightlabel.Location = new System.Drawing.Point(258, 35);
this.filterheightlabel.Name = "filterheightlabel";
this.filterheightlabel.Size = new System.Drawing.Size(41, 13);
this.filterheightlabel.TabIndex = 0;
this.filterheightlabel.Text = "Height:";
//
// filterHeight
//
this.filterHeight.AllowDecimal = false;
this.filterHeight.AllowExpressions = false;
this.filterHeight.AllowNegative = false;
this.filterHeight.AllowRelative = false;
this.filterHeight.ButtonStep = 1;
this.filterHeight.ButtonStepBig = 10F;
this.filterHeight.ButtonStepFloat = 1F;
this.filterHeight.ButtonStepSmall = 0.1F;
this.filterHeight.ButtonStepsUseModifierKeys = false;
this.filterHeight.ButtonStepsWrapAround = false;
this.filterHeight.Location = new System.Drawing.Point(301, 30);
this.filterHeight.Name = "filterHeight";
this.filterHeight.Size = new System.Drawing.Size(54, 24);
this.filterHeight.StepValues = null;
this.filterHeight.TabIndex = 0;
this.filterHeight.TabStop = false;
this.filterHeight.WhenTextChanged += new System.EventHandler(this.filterSize_WhenTextChanged);
//
// filterwidthlabel
//
this.filterwidthlabel.AutoSize = true;
this.filterwidthlabel.Location = new System.Drawing.Point(159, 35);
this.filterwidthlabel.Name = "filterwidthlabel";
this.filterwidthlabel.Size = new System.Drawing.Size(38, 13);
this.filterwidthlabel.TabIndex = 0;
this.filterwidthlabel.Text = "Width:";
//
// filterWidth
//
this.filterWidth.AllowDecimal = false;
this.filterWidth.AllowExpressions = false;
this.filterWidth.AllowNegative = false;
this.filterWidth.AllowRelative = false;
this.filterWidth.ButtonStep = 1;
this.filterWidth.ButtonStepBig = 10F;
this.filterWidth.ButtonStepFloat = 1F;
this.filterWidth.ButtonStepSmall = 0.1F;
this.filterWidth.ButtonStepsUseModifierKeys = false;
this.filterWidth.ButtonStepsWrapAround = false;
this.filterWidth.Location = new System.Drawing.Point(199, 30);
this.filterWidth.Name = "filterWidth";
this.filterWidth.Size = new System.Drawing.Size(54, 24);
this.filterWidth.StepValues = null;
this.filterWidth.TabIndex = 0;
this.filterWidth.TabStop = false;
this.filterWidth.WhenTextChanged += new System.EventHandler(this.filterSize_WhenTextChanged);
//
// texturetypecombo
//
this.texturetypecombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.texturetypecombo.FormattingEnabled = true;
this.texturetypecombo.Items.AddRange(new object[] {
this.sizecombo.Location = new System.Drawing.Point(43, 32);
this.sizecombo.Margin = new System.Windows.Forms.Padding(3, 3, 6, 3);
this.sizecombo.Name = "sizecombo";
this.sizecombo.Size = new System.Drawing.Size(107, 21);
this.sizecombo.TabIndex = 2;
this.sizecombo.TabStop = false;
this.sizecombo.SelectedIndexChanged += new System.EventHandler(this.sizecombo_SelectedIndexChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(10, 35);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(30, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Size:";
//
// usedtexturesfirst
//
this.usedtexturesfirst.AutoSize = true;
this.usedtexturesfirst.Location = new System.Drawing.Point(365, 8);
this.usedtexturesfirst.Name = "usedtexturesfirst";
this.usedtexturesfirst.Size = new System.Drawing.Size(139, 17);
this.usedtexturesfirst.TabIndex = 0;
this.usedtexturesfirst.TabStop = false;
this.usedtexturesfirst.Text = "Used textures at the top";
this.usedtexturesfirst.UseVisualStyleBackColor = true;
this.usedtexturesfirst.CheckedChanged += new System.EventHandler(this.usedtexturesfirst_CheckedChanged);
//
// longtexturenames
//
this.longtexturenames.AutoSize = true;
this.longtexturenames.Location = new System.Drawing.Point(365, 34);
this.longtexturenames.Name = "longtexturenames";
this.longtexturenames.Size = new System.Drawing.Size(119, 17);
this.longtexturenames.TabIndex = 0;
this.longtexturenames.TabStop = false;
this.longtexturenames.Text = "Long texture names";
this.longtexturenames.UseVisualStyleBackColor = true;
this.longtexturenames.CheckedChanged += new System.EventHandler(this.longtexturenames_CheckedChanged);
//
// filterheightlabel
//
this.filterheightlabel.AutoSize = true;
this.filterheightlabel.Location = new System.Drawing.Point(258, 35);
this.filterheightlabel.Name = "filterheightlabel";
this.filterheightlabel.Size = new System.Drawing.Size(41, 13);
this.filterheightlabel.TabIndex = 0;
this.filterheightlabel.Text = "Height:";
//
// filterHeight
//
this.filterHeight.AllowDecimal = false;
this.filterHeight.AllowExpressions = false;
this.filterHeight.AllowNegative = false;
this.filterHeight.AllowRelative = false;
this.filterHeight.ButtonStep = 1;
this.filterHeight.ButtonStepBig = 10F;
this.filterHeight.ButtonStepFloat = 1F;
this.filterHeight.ButtonStepSmall = 0.1F;
this.filterHeight.ButtonStepsUseModifierKeys = false;
this.filterHeight.ButtonStepsWrapAround = false;
this.filterHeight.Location = new System.Drawing.Point(301, 30);
this.filterHeight.Name = "filterHeight";
this.filterHeight.Size = new System.Drawing.Size(54, 24);
this.filterHeight.StepValues = null;
this.filterHeight.TabIndex = 0;
this.filterHeight.TabStop = false;
this.filterHeight.WhenTextChanged += new System.EventHandler(this.filterSize_WhenTextChanged);
//
// filterwidthlabel
//
this.filterwidthlabel.AutoSize = true;
this.filterwidthlabel.Location = new System.Drawing.Point(159, 35);
this.filterwidthlabel.Name = "filterwidthlabel";
this.filterwidthlabel.Size = new System.Drawing.Size(38, 13);
this.filterwidthlabel.TabIndex = 0;
this.filterwidthlabel.Text = "Width:";
//
// filterWidth
//
this.filterWidth.AllowDecimal = false;
this.filterWidth.AllowExpressions = false;
this.filterWidth.AllowNegative = false;
this.filterWidth.AllowRelative = false;
this.filterWidth.ButtonStep = 1;
this.filterWidth.ButtonStepBig = 10F;
this.filterWidth.ButtonStepFloat = 1F;
this.filterWidth.ButtonStepSmall = 0.1F;
this.filterWidth.ButtonStepsUseModifierKeys = false;
this.filterWidth.ButtonStepsWrapAround = false;
this.filterWidth.Location = new System.Drawing.Point(199, 30);
this.filterWidth.Name = "filterWidth";
this.filterWidth.Size = new System.Drawing.Size(54, 24);
this.filterWidth.StepValues = null;
this.filterWidth.TabIndex = 0;
this.filterWidth.TabStop = false;
this.filterWidth.WhenTextChanged += new System.EventHandler(this.filterSize_WhenTextChanged);
//
// texturetypecombo
//
this.texturetypecombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.texturetypecombo.FormattingEnabled = true;
this.texturetypecombo.Items.AddRange(new object[] {
"All",
"Textures",
"Flats",
"By selection type"});
this.texturetypecombo.Location = new System.Drawing.Point(43, 5);
this.texturetypecombo.Margin = new System.Windows.Forms.Padding(3, 3, 6, 3);
this.texturetypecombo.Name = "texturetypecombo";
this.texturetypecombo.Size = new System.Drawing.Size(107, 21);
this.texturetypecombo.TabIndex = 0;
this.texturetypecombo.TabStop = false;
this.texturetypecombo.SelectedIndexChanged += new System.EventHandler(this.texturetypecombo_SelectedIndexChanged);
//
// objectname
//
this.objectname.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
this.objectname.HideSelection = false;
this.objectname.Location = new System.Drawing.Point(199, 6);
this.objectname.Margin = new System.Windows.Forms.Padding(3, 3, 6, 3);
this.objectname.Name = "objectname";
this.objectname.Size = new System.Drawing.Size(128, 20);
this.objectname.TabIndex = 0;
this.objectname.TabStop = false;
this.objectname.TextChanged += new System.EventHandler(this.objectname_TextChanged);
this.objectname.KeyDown += new System.Windows.Forms.KeyEventHandler(this.objectname_KeyDown);
//
// refreshtimer
//
this.refreshtimer.Interval = 500;
this.refreshtimer.Tick += new System.EventHandler(this.refreshtimer_Tick);
//
// ImageBrowserControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.Controls.Add(this.splitter);
this.Name = "ImageBrowserControl";
this.Size = new System.Drawing.Size(840, 346);
this.splitter.Panel1.ResumeLayout(false);
this.splitter.Panel2.ResumeLayout(false);
this.splitter.Panel2.PerformLayout();
this.splitter.ResumeLayout(false);
this.ResumeLayout(false);
this.texturetypecombo.Location = new System.Drawing.Point(43, 5);
this.texturetypecombo.Margin = new System.Windows.Forms.Padding(3, 3, 6, 3);
this.texturetypecombo.Name = "texturetypecombo";
this.texturetypecombo.Size = new System.Drawing.Size(107, 21);
this.texturetypecombo.TabIndex = 0;
this.texturetypecombo.TabStop = false;
this.texturetypecombo.SelectedIndexChanged += new System.EventHandler(this.texturetypecombo_SelectedIndexChanged);
//
// objectname
//
this.objectname.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
this.objectname.HideSelection = false;
this.objectname.Location = new System.Drawing.Point(199, 6);
this.objectname.Margin = new System.Windows.Forms.Padding(3, 3, 6, 3);
this.objectname.Name = "objectname";
this.objectname.Size = new System.Drawing.Size(128, 20);
this.objectname.TabIndex = 0;
this.objectname.TabStop = false;
this.objectname.TextChanged += new System.EventHandler(this.objectname_TextChanged);
this.objectname.KeyDown += new System.Windows.Forms.KeyEventHandler(this.objectname_KeyDown);
//
// refreshtimer
//
this.refreshtimer.Interval = 500;
this.refreshtimer.Tick += new System.EventHandler(this.refreshtimer_Tick);
//
// ImageBrowserControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.Controls.Add(this.splitter);
this.Name = "ImageBrowserControl";
this.Size = new System.Drawing.Size(840, 346);
this.splitter.Panel1.ResumeLayout(false);
this.splitter.Panel2.ResumeLayout(false);
this.splitter.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitter)).EndInit();
this.splitter.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -326,5 +343,6 @@ namespace CodeImp.DoomBuilder.Controls
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button objectclear;
private System.Windows.Forms.CheckBox classicview;
}
private System.Windows.Forms.CheckBox centeritem;
}
}

View file

@ -28,6 +28,21 @@ using CodeImp.DoomBuilder.Windows;
namespace CodeImp.DoomBuilder.Controls
{
/// <summary>
/// Holds a title of an item group and its items
/// </summary>
internal struct ImageBrowserItemGroup
{
public string Title;
public List<ImageBrowserItem> Items;
public ImageBrowserItemGroup(string title)
{
Title = title;
Items = new List<ImageBrowserItem>();
}
}
internal partial class ImageBrowserControl : UserControl
{
#region ================== Constants
@ -63,9 +78,6 @@ namespace CodeImp.DoomBuilder.Controls
private string usedfirstgroup;
private string availgroup;
// Filtered items
private List<ImageBrowserItem> visibleitems;
//mxd
private int texturetype;
@ -130,6 +142,7 @@ namespace CodeImp.DoomBuilder.Controls
ElementName = (texturetype == 2 || (texturetype == 3 && browseflats)) ? "flats" : "textures";
list.UsedTexturesFirst = usedtexturesfirst.Checked = General.Settings.ReadSetting(settingpath + ".showusedtexturesfirst", false);
list.ClassicView = classicview.Checked = General.Settings.ReadSetting(settingpath + ".classicview", false);
list.CenterItem = centeritem.Checked = General.Settings.ReadSetting(settingpath + ".verticallycenteritem", true);
int _imagesize = General.Settings.ReadSetting(settingpath + ".imagesize", 128);
sizecombo.Text = (_imagesize == 0 ? sizecombo.Items[0].ToString() : _imagesize.ToString());
@ -187,8 +200,10 @@ namespace CodeImp.DoomBuilder.Controls
{
General.Settings.WriteSetting(settingpath + ".showusedtexturesfirst", usedtexturesfirst.Checked);
General.Settings.WriteSetting(settingpath + ".classicview", classicview.Checked);
General.Settings.WriteSetting(settingpath + ".verticallycenteritem", list.CenterItem);
General.Settings.WriteSetting(settingpath + ".imagesize", list.ImageSize);
if(General.Map.Config.UseLongTextureNames) General.Map.Options.UseLongTextureNames = uselongtexturenames;
if (General.Map.Config.UseLongTextureNames) General.Map.Options.UseLongTextureNames = uselongtexturenames;
CleanUp();
}
@ -278,7 +293,11 @@ namespace CodeImp.DoomBuilder.Controls
//mxd
protected override bool ProcessTabKey(bool forward)
{
usedtexturesfirst.Checked = !usedtexturesfirst.Checked;
if (list.SelectedItems.Count == 0)
return false;
list.JumpBetweenItems(list.SelectedItems[0]);
return false;
}
@ -380,6 +399,7 @@ namespace CodeImp.DoomBuilder.Controls
{
list.UsedTexturesFirst = usedtexturesfirst.Checked;
RefillList(false);
list.UpdateRectangles();
list.Focus();
}
}
@ -499,7 +519,9 @@ namespace CodeImp.DoomBuilder.Controls
// This fills the list based on the objectname filter
private void RefillList(bool selectfirst)
{
visibleitems = new List<ImageBrowserItem>();
ImageBrowserItemGroup directoryitems = new ImageBrowserItemGroup("Directories");
ImageBrowserItemGroup useditems = new ImageBrowserItemGroup("Used textures");
ImageBrowserItemGroup visibleitems = new ImageBrowserItemGroup("All textures");
// Clear list first
list.Clear();
@ -523,30 +545,50 @@ namespace CodeImp.DoomBuilder.Controls
case ImageBrowserItemType.IMAGE:
if(ValidateItem(items[i], previtem) && ValidateItemSize(items[i], w, h))
{
visibleitems.Add(items[i]);
visibleitems.Items.Add(items[i]);
if (items[i].Icon.UsedInMap)
useditems.Items.Add(items[i]);
previtem = items[i];
}
break;
case ImageBrowserItemType.FOLDER_UP: //mxd. "Browse Up" items are always valid
visibleitems.Add(items[i]);
directoryitems.Items.Add(items[i]);
break;
case ImageBrowserItemType.FOLDER: //mxd. Only apply name filtering to "Folder" items
if(items[i].TextureName.ToUpperInvariant().Contains(objectname.Text.ToUpperInvariant()))
visibleitems.Add(items[i]);
directoryitems.Items.Add(items[i]);
break;
default: throw new NotImplementedException("Unknown ImageBrowserItemType");
}
}
// Fill list
visibleitems.Sort(SortItems);
list.SetItems(visibleitems);
directoryitems.Items.Sort();
useditems.Items.Sort();
visibleitems.Items.Sort();
List<ImageBrowserItemGroup> itemgroups = new List<ImageBrowserItemGroup>();
// Always add the directories
itemgroups.Add(directoryitems);
// Add used textures if the user wants to and there are any
if (usedtexturesfirst.Checked && useditems.Items.Count > 0)
itemgroups.Add(useditems);
// Finally add all items
if (visibleitems.Items.Count > 0)
itemgroups.Add(visibleitems);
list.SetItems(itemgroups);
// Make selection?
if(!preventselection && list.Items.Count > 0)
if (!preventselection && list.Items.Count > 0)
{
// Select specific item?
if(keepselected > -1)
@ -658,6 +700,11 @@ namespace CodeImp.DoomBuilder.Controls
list.Focus();
}
#endregion
}
private void centeritem_CheckedChanged(object sender, EventArgs e)
{
list.CenterItem = centeritem.Checked;
}
#endregion
}
}

View file

@ -112,15 +112,15 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="splitter.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="splitter.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="refreshtimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<metadata name="refreshtimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>103, 17</value>
</metadata>
</root>

View file

@ -51,6 +51,9 @@ namespace CodeImp.DoomBuilder.Controls
// Selection
private bool allowselection;
private bool allowmultipleselection;
private bool centeritem;
private List<ImageBrowserItemGroup> itemgroups = new List<ImageBrowserItemGroup>();
#endregion
@ -144,6 +147,8 @@ namespace CodeImp.DoomBuilder.Controls
}
}
public bool CenterItem { get { return centeritem; } set { centeritem = value; } }
public List<ImageBrowserItem> Items { get { return items; } }
public List<ImageBrowserItem> SelectedItems { get { return selection; } }
public string Title { get { return title; } set { title = value; } }
@ -200,6 +205,24 @@ namespace CodeImp.DoomBuilder.Controls
Refresh();
}
public void SetItems(IEnumerable<ImageBrowserItemGroup> itemgroups)
{
this.items.Clear();
lastselecteditem = null;
selection.Clear();
this.itemgroups.Clear();
foreach (ImageBrowserItemGroup ibig in itemgroups)
{
this.items.AddRange(ibig.Items);
this.itemgroups.Add(ibig);
}
OnSelectionChanged(selection);
UpdateRectangles();
}
public void SetItems(IEnumerable<ImageBrowserItem> items)
{
this.items.Clear();
@ -213,7 +236,7 @@ namespace CodeImp.DoomBuilder.Controls
public void SetSelectedItem(ImageBrowserItem item)
{
SetSelectedItems(new List<ImageBrowserItem> { item } );
SetSelectedItems(new List<ImageBrowserItem> { item });
}
public void SetSelectedItems(List<ImageBrowserItem> items)
@ -229,6 +252,11 @@ namespace CodeImp.DoomBuilder.Controls
}
public void ScrollToItem(ImageBrowserItem item)
{
ScrollToItem(item, centeritem);
}
public void ScrollToItem(ImageBrowserItem item, bool centeritem)
{
int index = items.IndexOf(item);
if(index < 0) return;
@ -240,8 +268,49 @@ namespace CodeImp.DoomBuilder.Controls
int ymax = ymin + this.ClientRectangle.Height + titleheight;
if(rec.Top - 3 >= ymin && rec.Bottom + 3 <= ymax) return;
int yscroll = Math.Max(0, Math.Min(rec.Top - titleheight - 3, scrollbar.Maximum - ClientRectangle.Height));
scrollbar.Value = yscroll;
int yscroll;
if (centeritem)
yscroll = rec.Top + rec.Height / 2 - ClientRectangle.Height / 2;
else
yscroll = rec.Top - titleheight - 3;
scrollbar.Value = Math.Max(0, Math.Min(yscroll, scrollbar.Maximum - ClientRectangle.Height)); ;
Refresh();
}
/// <summary>
/// Jumps back and forth between the currently selected texture at the top and in the pile of all textures
/// </summary>
/// <param name="item">The item to jump back and forth between</param>
public void JumpBetweenItems(ImageBrowserItem item)
{
// The item has to exist twice, once in the used textures at the top and in the pile, so get the indexes
int index1 = items.IndexOf(item);
int index2 = items.LastIndexOf(item);
// Item only exists once, so stop here
if (index1 == index2)
return;
Rectangle rect1 = rectangles[index1];
Rectangle rect2 = rectangles[index2];
// Get the distance to the two images. Count from the center of the currently scrolled to position and take the bottom
// of the first image and the top of the second image
int distance1 = Math.Abs(rect1.Bottom - (scrollbar.Value + ClientRectangle.Height / 2));
int distance2 = Math.Abs(rect2.Top - (scrollbar.Value + ClientRectangle.Height / 2));
int yscroll;
// Get the y position we want to scroll to
if(centeritem)
yscroll = (distance1 > distance2 ? (rect1.Top + rect1.Height / 2) : (rect2.Top + rect2.Height / 2)) - ClientRectangle.Height / 2;
else
yscroll = distance1 > distance2 ? rect1.Top : rect2.Top;
// The desired y position might be outside of the range we can scroll to, so clamp the value
scrollbar.Value = Math.Max(0, Math.Min(yscroll, scrollbar.Maximum - ClientRectangle.Height));
Refresh();
}
@ -503,43 +572,42 @@ namespace CodeImp.DoomBuilder.Controls
int my = 0;
rectangles.Clear();
//
ImageBrowserItemType currentType = ImageBrowserItemType.IMAGE; // initialized to random value
bool currentUsedInMap = false;
var firstItem = (items.Count > 0) ? items[0] : null;
foreach (var ti in items)
foreach (ImageBrowserItemGroup ibig in itemgroups)
{
Image preview = GetPreview(ti, imagesize);
if (classicview && (ti == firstItem || ((currentType == ImageBrowserItemType.IMAGE) != (ti.ItemType == ImageBrowserItemType.IMAGE)) || (usedtexturesfirst && currentUsedInMap != ti.Icon.UsedInMap)))
{
// new row, also provide space for category name.
cx = 0;
cy += SystemFonts.MessageBoxFont.Height + 6 + my + ((ti != firstItem) ? 16 : 0);
my = 0;
currentType = ti.ItemType;
currentUsedInMap = ti.Icon.UsedInMap;
}
int rw = w - cx;
int wid = Math.Max((imagesize > 0 ? imagesize : preview.Width), ti.TextureNameWidth) + padhorz + padhorz;
int hei = (imagesize > 0 ? imagesize : preview.Height) + padvert + padvert + font;
// if we draw height below, add another font
if (General.Settings.ShowTextureSizes && General.Settings.TextureSizesBelow && ti.ItemType == ImageBrowserItemType.IMAGE)
hei += font;
if(rw < wid)
if (classicview)
{
// New row
// new row, also provide space for category name.
cx = 0;
cy += my;
cy += SystemFonts.MessageBoxFont.Height + 6 + my + 16 /* ((ti != firstItem) ? 16 : 0) */;
my = 0;
}
my = Math.Max(my, hei);
var rect = new Rectangle(cx + padhorz, cy + padvert, wid - padhorz - padhorz, hei - padvert - padvert - font);
rectangles.Add(rect);
cx += wid;
foreach (var ti in ibig.Items)
{
Image preview = GetPreview(ti, imagesize);
int rw = w - cx;
int wid = Math.Max((imagesize > 0 ? imagesize : preview.Width), ti.TextureNameWidth) + padhorz + padhorz;
int hei = (imagesize > 0 ? imagesize : preview.Height) + padvert + padvert + font;
// if we draw height below, add another font
if (General.Settings.ShowTextureSizes && General.Settings.TextureSizesBelow && ti.ItemType == ImageBrowserItemType.IMAGE)
hei += font;
if (rw < wid)
{
// New row
cx = 0;
cy += my;
my = 0;
}
my = Math.Max(my, hei);
var rect = new Rectangle(cx + padhorz, cy + padvert, wid - padhorz - padhorz, hei - padvert - padvert - font);
rectangles.Add(rect);
cx += wid;
}
}
if(rectangles.Count > 0)
@ -607,34 +675,33 @@ namespace CodeImp.DoomBuilder.Controls
{
int y = scrollbar.Value;
int height = ClientRectangle.Height;
int i = 0;
ImageBrowserItemType currentType = ImageBrowserItemType.IMAGE; // initialized to random value
bool currentUsedInMap = false;
ImageBrowserItem.SetBrushes(classicview, rectangles[0].X, rectangles[0].Y - y, rectangles[0].Width, rectangles[0].Height);
for (var i = 0; i < items.Count; i++)
foreach (ImageBrowserItemGroup ibig in itemgroups)
{
if (classicview && (i == 0 || ((currentType == ImageBrowserItemType.IMAGE) != (items[i].ItemType == ImageBrowserItemType.IMAGE)) || (usedtexturesfirst && currentUsedInMap != items[i].Icon.UsedInMap)))
{
// draw corresponding title right above this item.
string hdrname;
if (items[i].ItemType == ImageBrowserItemType.IMAGE)
{
if (usedtexturesfirst && items[i].Icon.UsedInMap) hdrname = "Used " + contenttype + ":";
else hdrname = "All " + contenttype + ":";
}
else hdrname = "Directories:";
DrawTextureHeader(g, hdrname, new Rectangle(2, rectangles[i].Y - (SystemFonts.MessageBoxFont.Height + 6) - y, ClientRectangle.Width - scrollwidth - 4, SystemFonts.MessageBoxFont.Height), false);
currentType = items[i].ItemType;
currentUsedInMap = items[i].Icon.UsedInMap;
}
if (classicview)
{
// draw corresponding title right above this item.
string hdrname = ibig.Title + ":";
DrawTextureHeader(g, hdrname, new Rectangle(2, rectangles[i].Y - (SystemFonts.MessageBoxFont.Height + 6) - y, ClientRectangle.Width - scrollwidth - 4, SystemFonts.MessageBoxFont.Height), false);
currentType = items[i].ItemType;
currentUsedInMap = items[i].Icon.UsedInMap;
}
Rectangle rec = rectangles[i];
if(rec.Bottom < y) continue;
if(rec.Top > y + height) break;
for(int j=0; j < ibig.Items.Count; j++, i++)
{
Rectangle rec = rectangles[i];
if (rec.Bottom < y) continue;
if (rec.Top > y + height) break;
Image bmp = GetPreview(items[i], imagesize);
items[i].Draw(g, bmp, rec.X, rec.Y - y, rec.Width, rec.Height, selection.Contains(items[i]), items[i].Icon.UsedInMap, classicview);
Image bmp = GetPreview(items[i], imagesize);
items[i].Draw(g, bmp, rec.X, rec.Y - y, rec.Width, rec.Height, selection.Contains(items[i]), items[i].Icon.UsedInMap, classicview);
}
}
}