Changeset - 721656f9e923
[Not reviewed]
Tess Snider (Malkyne) - 9 years ago 2015-10-14 11:13:20
this@malkyne.org
Added a dialog for prompting resolution and pixel-width, so that the app can be used on retina systems. RC3.
6 files changed with 385 insertions and 11 deletions:
0 comments (0 inline, 0 general)
DesertPaintLab.csproj
Show inline comments
...
 
@@ -68,6 +68,8 @@
 
    <Compile Include="gtk-gui\DesertPaintLab.PaintSwatch.cs" />
 
    <Compile Include="SimulatorWindow.cs" />
 
    <Compile Include="gtk-gui\DesertPaintLab.SimulatorWindow.cs" />
 
    <Compile Include="ScreenCheckDialog.cs" />
 
    <Compile Include="gtk-gui\DesertPaintLab.ScreenCheckDialog.cs" />
 
  </ItemGroup>
 
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
 
  <ProjectExtensions>
MainWindow.cs
Show inline comments
...
 
@@ -28,13 +28,14 @@ using DesertPaintLab;
 

 
public partial class MainWindow : Gtk.Window
 
{
 
	const int swatchHeight = 24;
 
	const int colorBarWidth = 306;
 
	const int redBarSpacing = 32;
 
	const int greenBarSpacing = 42;
 
	const int blueBarSpacing = 52;
 
	const int colorTolerance = 2;
 
	
 
	int swatchHeight = 24;
 
	int colorBarWidth = 306;
 
	int redBarSpacing = 32;
 
	int greenBarSpacing = 42;
 
	int blueBarSpacing = 52;
 

 
	
 
	bool unsavedData = false;
 
	bool shouldShutDown = false;
...
 
@@ -46,6 +47,7 @@ public partial class MainWindow : Gtk.Wi
 
	
 
	int screenWidth = 0;
 
	int screenHeight = 0;
 
	int pixelMultiplier = 1;
 

 
	Gdk.Window rootWindow = null;
 
	Gdk.Pixbuf screenBuffer = null;
...
 
@@ -55,7 +57,6 @@ public partial class MainWindow : Gtk.Wi
 
	Reagent reagent3 = null;
 

 
	
 
	
 
	public bool ShouldShutDown
 
	{
 
		get
...
 
@@ -95,15 +96,29 @@ public partial class MainWindow : Gtk.Wi
 
		unmodifiedSwatch.Clear();
 
		reactionSwatch.Clear();
 
		
 

 
		// get the root window
 
		rootWindow = Gdk.Global.DefaultRootWindow;
 

 
		// get its width and height
 
		rootWindow.GetSize(out screenWidth, out screenHeight);
 
		
 
		screenBuffer = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, 
 
                                       screenWidth, screenHeight);
 
		ScreenCheckDialog screenCheckDialog = new ScreenCheckDialog();
 
		screenCheckDialog.ScreenWidth = screenWidth;
 
		screenCheckDialog.ScreenHeight = screenHeight;
 
		screenCheckDialog.GamePixelWidth = pixelMultiplier;
 
		ResponseType resp = (ResponseType)screenCheckDialog.Run();
 
		screenWidth = screenCheckDialog.ScreenWidth;
 
		screenHeight = screenCheckDialog.ScreenHeight;
 
		pixelMultiplier = screenCheckDialog.GamePixelWidth;
 
		screenCheckDialog.Destroy();
 

 
		screenBuffer = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, screenWidth, screenHeight);
 
	
 
		swatchHeight    *= pixelMultiplier;
 
		colorBarWidth   *= pixelMultiplier;
 
		redBarSpacing   *= pixelMultiplier;
 
		greenBarSpacing *= pixelMultiplier;
 
		blueBarSpacing  *= pixelMultiplier;
 
	
 
		if (!OpenProfile())
 
		{
PaintSwatch.cs
Show inline comments
...
 
@@ -25,7 +25,6 @@ namespace DesertPaintLab
 
						        color.Blue.ToString();
 
				colorNameLabel.Text = Palette.FindNearest(color);
 
			}
 
			
 
		}
 
		
 
		public PaintSwatch ()
...
 
@@ -41,7 +40,6 @@ namespace DesertPaintLab
 
			rgbLabel.Text = "???, ???, ???";
 
			colorNameLabel.Text = "Unknown";
 
		}
 
		
 
	}
 
}
 

ScreenCheckDialog.cs
Show inline comments
 
new file 100644
 
/*
 
 * Copyright (c) 2014, Tess Snider
 

 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 
 of this software and associated documentation files (the "Software"), to deal
 
 in the Software without restriction, including without limitation the rights
 
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
 copies of the Software, and to permit persons to whom the Software is
 
 furnished to do so, subject to the following conditions:
 

 
 The above copyright notice and this permission notice shall be included in
 
 all copies or substantial portions of the Software.
 

 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
 THE SOFTWARE.
 
*/
 

 
using System;
 

 
namespace DesertPaintLab
 
{
 
	public partial class ScreenCheckDialog : Gtk.Dialog
 
	{
 
		public int ScreenWidth
 
		{
 
			get
 
			{
 
				return int.Parse(screenWidthEntry.Text);	
 
			}	
 
			set
 
			{
 
				screenWidthEntry.Text = value.ToString(); 
 
			}
 
		}
 

 
		public int ScreenHeight
 
		{
 
			get
 
			{
 
				return int.Parse(screenHeightEntry.Text);	
 
			}	
 
			set
 
			{
 
				screenHeightEntry.Text = value.ToString();
 
			}
 
		}
 

 
		public int GamePixelWidth
 
		{
 
			get
 
			{
 
				return int.Parse(gamePixelWidthEntry.Text);	
 
			}	
 
			set
 
			{
 
				gamePixelWidthEntry.Text = value.ToString();
 
			}
 
		}
 

 
		public ScreenCheckDialog ()
 
		{
 
			this.Build ();
 
		}
 
	}
 
}
 

gtk-gui/DesertPaintLab.ScreenCheckDialog.cs
Show inline comments
 
new file 100644
 

 
// This file has been generated by the GUI designer. Do not modify.
 
namespace DesertPaintLab
 
{
 
	public partial class ScreenCheckDialog
 
	{
 
		private global::Gtk.VBox vbox2;
 
		
 
		private global::Gtk.HBox hbox1;
 
		
 
		private global::Gtk.Label label1;
 
		
 
		private global::Gtk.Entry screenWidthEntry;
 
		
 
		private global::Gtk.Entry screenHeightEntry;
 
		
 
		private global::Gtk.HBox hbox2;
 
		
 
		private global::Gtk.Label label2;
 
		
 
		private global::Gtk.Entry gamePixelWidthEntry;
 
		
 
		private global::Gtk.Button buttonOk;
 

 
		protected virtual void Build ()
 
		{
 
			global::Stetic.Gui.Initialize (this);
 
			// Widget DesertPaintLab.ScreenCheckDialog
 
			this.Name = "DesertPaintLab.ScreenCheckDialog";
 
			this.Title = "Screen Check";
 
			this.WindowPosition = ((global::Gtk.WindowPosition)(4));
 
			this.Modal = true;
 
			this.BorderWidth = ((uint)(9));
 
			// Internal child DesertPaintLab.ScreenCheckDialog.VBox
 
			global::Gtk.VBox w1 = this.VBox;
 
			w1.Name = "dialog1_VBox";
 
			// Container child dialog1_VBox.Gtk.Box+BoxChild
 
			this.vbox2 = new global::Gtk.VBox ();
 
			this.vbox2.Name = "vbox2";
 
			this.vbox2.Spacing = 20;
 
			this.vbox2.BorderWidth = ((uint)(20));
 
			// Container child vbox2.Gtk.Box+BoxChild
 
			this.hbox1 = new global::Gtk.HBox ();
 
			this.hbox1.Name = "hbox1";
 
			this.hbox1.Spacing = 20;
 
			this.hbox1.BorderWidth = ((uint)(10));
 
			// Container child hbox1.Gtk.Box+BoxChild
 
			this.label1 = new global::Gtk.Label ();
 
			this.label1.Name = "label1";
 
			this.label1.LabelProp = "Screen Resolution";
 
			this.hbox1.Add (this.label1);
 
			global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.label1]));
 
			w2.Position = 0;
 
			w2.Expand = false;
 
			w2.Fill = false;
 
			// Container child hbox1.Gtk.Box+BoxChild
 
			this.screenWidthEntry = new global::Gtk.Entry ();
 
			this.screenWidthEntry.WidthRequest = 50;
 
			this.screenWidthEntry.CanFocus = true;
 
			this.screenWidthEntry.Name = "screenWidthEntry";
 
			this.screenWidthEntry.IsEditable = true;
 
			this.screenWidthEntry.InvisibleChar = '●';
 
			this.hbox1.Add (this.screenWidthEntry);
 
			global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.screenWidthEntry]));
 
			w3.Position = 1;
 
			// Container child hbox1.Gtk.Box+BoxChild
 
			this.screenHeightEntry = new global::Gtk.Entry ();
 
			this.screenHeightEntry.WidthRequest = 50;
 
			this.screenHeightEntry.CanFocus = true;
 
			this.screenHeightEntry.Name = "screenHeightEntry";
 
			this.screenHeightEntry.IsEditable = true;
 
			this.screenHeightEntry.InvisibleChar = '●';
 
			this.hbox1.Add (this.screenHeightEntry);
 
			global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.screenHeightEntry]));
 
			w4.Position = 2;
 
			this.vbox2.Add (this.hbox1);
 
			global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox1]));
 
			w5.Position = 0;
 
			w5.Expand = false;
 
			w5.Fill = false;
 
			// Container child vbox2.Gtk.Box+BoxChild
 
			this.hbox2 = new global::Gtk.HBox ();
 
			this.hbox2.Name = "hbox2";
 
			this.hbox2.Spacing = 20;
 
			this.hbox2.BorderWidth = ((uint)(10));
 
			// Container child hbox2.Gtk.Box+BoxChild
 
			this.label2 = new global::Gtk.Label ();
 
			this.label2.Name = "label2";
 
			this.label2.LabelProp = "Game Pixel Width in Screen Pixels";
 
			this.hbox2.Add (this.label2);
 
			global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.label2]));
 
			w6.Position = 0;
 
			w6.Expand = false;
 
			w6.Fill = false;
 
			// Container child hbox2.Gtk.Box+BoxChild
 
			this.gamePixelWidthEntry = new global::Gtk.Entry ();
 
			this.gamePixelWidthEntry.WidthRequest = 50;
 
			this.gamePixelWidthEntry.CanFocus = true;
 
			this.gamePixelWidthEntry.Name = "gamePixelWidthEntry";
 
			this.gamePixelWidthEntry.IsEditable = true;
 
			this.gamePixelWidthEntry.InvisibleChar = '●';
 
			this.hbox2.Add (this.gamePixelWidthEntry);
 
			global::Gtk.Box.BoxChild w7 = ((global::Gtk.Box.BoxChild)(this.hbox2 [this.gamePixelWidthEntry]));
 
			w7.Position = 1;
 
			w7.Expand = false;
 
			w7.Fill = false;
 
			this.vbox2.Add (this.hbox2);
 
			global::Gtk.Box.BoxChild w8 = ((global::Gtk.Box.BoxChild)(this.vbox2 [this.hbox2]));
 
			w8.Position = 1;
 
			w8.Expand = false;
 
			w8.Fill = false;
 
			w1.Add (this.vbox2);
 
			global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(w1 [this.vbox2]));
 
			w9.Position = 0;
 
			// Internal child DesertPaintLab.ScreenCheckDialog.ActionArea
 
			global::Gtk.HButtonBox w10 = this.ActionArea;
 
			w10.Name = "dialog1_ActionArea";
 
			w10.Spacing = 10;
 
			w10.BorderWidth = ((uint)(5));
 
			w10.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
 
			// Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
 
			this.buttonOk = new global::Gtk.Button ();
 
			this.buttonOk.CanDefault = true;
 
			this.buttonOk.CanFocus = true;
 
			this.buttonOk.Name = "buttonOk";
 
			this.buttonOk.UseStock = true;
 
			this.buttonOk.UseUnderline = true;
 
			this.buttonOk.Label = "gtk-ok";
 
			this.AddActionWidget (this.buttonOk, -5);
 
			global::Gtk.ButtonBox.ButtonBoxChild w11 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w10 [this.buttonOk]));
 
			w11.Expand = false;
 
			w11.Fill = false;
 
			if ((this.Child != null)) {
 
				this.Child.ShowAll ();
 
			}
 
			this.DefaultWidth = 378;
 
			this.DefaultHeight = 245;
 
			this.Show ();
 
		}
 
	}
 
}
gtk-gui/gui.stetic
Show inline comments
...
 
@@ -906,4 +906,151 @@ You can either import an existing Practi
 
      </widget>
 
    </child>
 
  </widget>
 
  <widget class="Gtk.Dialog" id="DesertPaintLab.ScreenCheckDialog" design-size="378 245">
 
    <property name="MemberName" />
 
    <property name="Title" translatable="yes">Screen Check</property>
 
    <property name="WindowPosition">CenterOnParent</property>
 
    <property name="Modal">True</property>
 
    <property name="BorderWidth">9</property>
 
    <property name="Buttons">1</property>
 
    <property name="HelpButton">False</property>
 
    <child internal-child="VBox">
 
      <widget class="Gtk.VBox" id="dialog1_VBox">
 
        <property name="MemberName" />
 
        <child>
 
          <widget class="Gtk.VBox" id="vbox2">
 
            <property name="MemberName" />
 
            <property name="Spacing">20</property>
 
            <property name="BorderWidth">20</property>
 
            <child>
 
              <widget class="Gtk.HBox" id="hbox1">
 
                <property name="MemberName" />
 
                <property name="Spacing">20</property>
 
                <property name="BorderWidth">10</property>
 
                <child>
 
                  <widget class="Gtk.Label" id="label1">
 
                    <property name="MemberName" />
 
                    <property name="LabelProp" translatable="yes">Screen Resolution</property>
 
                  </widget>
 
                  <packing>
 
                    <property name="Position">0</property>
 
                    <property name="AutoSize">True</property>
 
                    <property name="Expand">False</property>
 
                    <property name="Fill">False</property>
 
                  </packing>
 
                </child>
 
                <child>
 
                  <widget class="Gtk.Entry" id="screenWidthEntry">
 
                    <property name="MemberName" />
 
                    <property name="WidthRequest">50</property>
 
                    <property name="CanFocus">True</property>
 
                    <property name="IsEditable">True</property>
 
                    <property name="InvisibleChar">●</property>
 
                  </widget>
 
                  <packing>
 
                    <property name="Position">1</property>
 
                    <property name="AutoSize">True</property>
 
                  </packing>
 
                </child>
 
                <child>
 
                  <widget class="Gtk.Entry" id="screenHeightEntry">
 
                    <property name="MemberName" />
 
                    <property name="WidthRequest">50</property>
 
                    <property name="CanFocus">True</property>
 
                    <property name="IsEditable">True</property>
 
                    <property name="InvisibleChar">●</property>
 
                  </widget>
 
                  <packing>
 
                    <property name="Position">2</property>
 
                    <property name="AutoSize">True</property>
 
                  </packing>
 
                </child>
 
              </widget>
 
              <packing>
 
                <property name="Position">0</property>
 
                <property name="AutoSize">True</property>
 
                <property name="Expand">False</property>
 
                <property name="Fill">False</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <widget class="Gtk.HBox" id="hbox2">
 
                <property name="MemberName" />
 
                <property name="Spacing">20</property>
 
                <property name="BorderWidth">10</property>
 
                <child>
 
                  <widget class="Gtk.Label" id="label2">
 
                    <property name="MemberName" />
 
                    <property name="LabelProp" translatable="yes">Game Pixel Width in Screen Pixels</property>
 
                  </widget>
 
                  <packing>
 
                    <property name="Position">0</property>
 
                    <property name="AutoSize">True</property>
 
                    <property name="Expand">False</property>
 
                    <property name="Fill">False</property>
 
                  </packing>
 
                </child>
 
                <child>
 
                  <widget class="Gtk.Entry" id="gamePixelWidthEntry">
 
                    <property name="MemberName" />
 
                    <property name="WidthRequest">50</property>
 
                    <property name="CanFocus">True</property>
 
                    <property name="IsEditable">True</property>
 
                    <property name="InvisibleChar">●</property>
 
                  </widget>
 
                  <packing>
 
                    <property name="Position">1</property>
 
                    <property name="AutoSize">False</property>
 
                    <property name="Expand">False</property>
 
                    <property name="Fill">False</property>
 
                  </packing>
 
                </child>
 
                <child>
 
                  <placeholder />
 
                </child>
 
              </widget>
 
              <packing>
 
                <property name="Position">1</property>
 
                <property name="AutoSize">True</property>
 
                <property name="Expand">False</property>
 
                <property name="Fill">False</property>
 
              </packing>
 
            </child>
 
            <child>
 
              <placeholder />
 
            </child>
 
          </widget>
 
          <packing>
 
            <property name="Position">0</property>
 
            <property name="AutoSize">True</property>
 
          </packing>
 
        </child>
 
      </widget>
 
    </child>
 
    <child internal-child="ActionArea">
 
      <widget class="Gtk.HButtonBox" id="dialog1_ActionArea">
 
        <property name="MemberName" />
 
        <property name="Spacing">10</property>
 
        <property name="BorderWidth">5</property>
 
        <property name="Size">1</property>
 
        <property name="LayoutStyle">End</property>
 
        <child>
 
          <widget class="Gtk.Button" id="buttonOk">
 
            <property name="MemberName" />
 
            <property name="CanDefault">True</property>
 
            <property name="CanFocus">True</property>
 
            <property name="UseStock">True</property>
 
            <property name="Type">StockItem</property>
 
            <property name="StockId">gtk-ok</property>
 
            <property name="ResponseId">-5</property>
 
            <property name="label">gtk-ok</property>
 
          </widget>
 
          <packing>
 
            <property name="Expand">False</property>
 
            <property name="Fill">False</property>
 
          </packing>
 
        </child>
 
      </widget>
 
    </child>
 
  </widget>
 
</stetic-interface>
...
 
\ No newline at end of file
0 comments (0 inline, 0 general)