Discard our simultaneous hacky GTK engine in favor of a cross-platform UWT solution

This commit is contained in:
Michael Becker 2016-06-19 01:20:44 -04:00
parent db68700d40
commit 6e67d71243
24 changed files with 278 additions and 863 deletions

View File

@ -1,30 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK
{
public static class GtkApplication
{
private static IntPtr mvarHandle = IntPtr.Zero;
public static bool Initialize(ref int argc, ref string[] argv)
{
bool check = Internal.GTK.Methods.gtk_init_check (ref argc, ref argv);
if (!check)
return check;
mvarHandle = Internal.GTK.Methods.gtk_application_new ("net.alcetech.UniversalEditor", Internal.GTK.Constants.GApplicationFlags.None);
return check;
}
public static void Run()
{
Internal.GTK.Methods.gtk_main ();
}
public static void Quit()
{
Internal.GTK.Methods.gtk_main_quit ();
}
}
}

View File

@ -1,60 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK
{
public enum GtkBoxOrientation
{
Horizontal,
Vertical
}
public class GtkBox : GtkContainer
{
private int mvarItemCount = 0;
private GtkBoxOrientation mvarOrientation = GtkBoxOrientation.Vertical;
public GtkBox(GtkBoxOrientation orientation, int itemCount)
{
mvarOrientation = orientation;
mvarItemCount = itemCount;
}
protected override IntPtr CreateInternal ()
{
Internal.GTK.Constants.GtkBoxOrientation orientation = Internal.GTK.Constants.GtkBoxOrientation.Vertical;
switch (mvarOrientation)
{
case GtkBoxOrientation.Horizontal:
{
orientation = Internal.GTK.Constants.GtkBoxOrientation.Horizontal;
break;
}
case GtkBoxOrientation.Vertical:
{
orientation = Internal.GTK.Constants.GtkBoxOrientation.Vertical;
break;
}
}
IntPtr handle = Internal.GTK.Methods.gtk_box_new (orientation, mvarItemCount);
return handle;
}
public void Pack(PackDirection direction, GtkWidget child, bool expand, bool fill, int padding)
{
switch (direction)
{
case PackDirection.Start:
{
Internal.GTK.Methods.gtk_box_pack_start (this.Handle, child.Handle, expand, fill, padding);
break;
}
case PackDirection.End:
{
Internal.GTK.Methods.gtk_box_pack_end (this.Handle, child.Handle, expand, fill, padding);
break;
}
}
}
}
}

View File

@ -1,17 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK
{
public abstract class GtkContainer : GtkWidget
{
private GtkWidget.GtkWidgetCollection mvarControls = null;
public GtkWidget.GtkWidgetCollection Controls { get { return mvarControls; } }
protected override void BeforeCreateInternal ()
{
mvarControls = new GtkWidget.GtkWidgetCollection (this);
base.BeforeCreateInternal ();
}
}
}

View File

@ -1,20 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK
{
public class GtkMenu : GtkMenuShell
{
protected override IntPtr CreateInternal ()
{
IntPtr handle = Internal.GTK.Methods.gtk_menu_new ();
return handle;
}
public string Text
{
get { return Internal.GTK.Methods.gtk_menu_get_title(this.Handle); }
set { Internal.GTK.Methods.gtk_menu_set_title (this.Handle, value); }
}
}
}

View File

@ -1,15 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK
{
public class GtkMenuBar : GtkMenuShell
{
protected override IntPtr CreateInternal ()
{
IntPtr handle = Internal.GTK.Methods.gtk_menu_bar_new ();
return handle;
}
}
}

View File

@ -1,68 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK
{
public class GtkMenuItem : GtkWidget
{
public class GtkMenuItemCollection
: System.Collections.ObjectModel.Collection<GtkWidget>
{
private GtkMenuShell _parent = null;
internal GtkMenuItemCollection(GtkMenuShell parent)
{
_parent = parent;
}
protected override void InsertItem (int index, GtkWidget item)
{
base.InsertItem (index, item);
Internal.GTK.Methods.gtk_menu_shell_insert (_parent.Handle, item.Handle, index);
}
}
private Internal.GLib.Delegates.GCallback _this_activate = null;
private void _this_activate_impl(IntPtr sender)
{
Console.WriteLine ("Hello world for item " + sender.ToString ());
}
protected override IntPtr CreateInternal ()
{
IntPtr handle = Internal.GTK.Methods.gtk_menu_item_new ();
_this_activate = new Internal.GLib.Delegates.GCallback (_this_activate_impl);
Internal.GLib.Methods.g_signal_connect (handle, "activate", _this_activate, IntPtr.Zero);
return handle;
}
protected override void AfterCreateInternal ()
{
this.UseMnemonic = true;
base.AfterCreateInternal ();
}
private GtkMenu mvarMenu = null;
public GtkMenu Menu
{
get { return mvarMenu; }
set
{
Internal.GTK.Methods.gtk_menu_item_set_submenu (this.Handle, value.Handle);
IntPtr checkHandle = Internal.GTK.Methods.gtk_menu_item_get_submenu (this.Handle);
if (checkHandle == value.Handle) mvarMenu = value;
}
}
public string Text
{
get { return Internal.GTK.Methods.gtk_menu_item_get_label (this.Handle); }
set { Internal.GTK.Methods.gtk_menu_item_set_label (this.Handle, value); }
}
public bool UseMnemonic
{
get { return Internal.GTK.Methods.gtk_menu_item_get_use_underline (this.Handle); }
set { Internal.GTK.Methods.gtk_menu_item_set_use_underline (this.Handle, value); }
}
}
}

View File

@ -1,16 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK
{
public abstract class GtkMenuShell : GtkWidget
{
private GtkMenuItem.GtkMenuItemCollection mvarItems = null;
public GtkMenuItem.GtkMenuItemCollection Items { get { return mvarItems; } }
public GtkMenuShell()
{
mvarItems = new GtkMenuItem.GtkMenuItemCollection (this);
}
}
}

View File

@ -1,22 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK
{
public class GtkSeparator : GtkWidget
{
private GtkBoxOrientation mvarOrientation = GtkBoxOrientation.Horizontal;
public GtkBoxOrientation Orientation { get { return mvarOrientation; } }
public GtkSeparator (GtkBoxOrientation orientation)
{
mvarOrientation = orientation;
}
protected override IntPtr CreateInternal ()
{
IntPtr handle = Internal.GTK.Methods.gtk_separator_new (mvarOrientation);
return handle;
}
}
}

View File

@ -1,95 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK
{
public abstract class GtkWidget
{
public class GtkWidgetCollection
: System.Collections.ObjectModel.Collection<GtkWidget>
{
private GtkContainer _parent = null;
public GtkWidgetCollection(GtkContainer parent)
{
_parent = parent;
}
protected override void InsertItem (int index, GtkWidget item)
{
base.InsertItem (index, item);
Internal.GTK.Methods.gtk_container_add (_parent.Handle, item.Handle);
}
}
private IntPtr mvarHandle = IntPtr.Zero;
public IntPtr Handle { get { return mvarHandle; } }
public bool IsCreated {
get { return mvarHandle != IntPtr.Zero; }
}
protected abstract IntPtr CreateInternal ();
protected virtual void BeforeCreateInternal()
{
}
protected virtual void AfterCreateInternal()
{
}
public GtkWidget()
{
Create();
}
public bool Create()
{
if (IsCreated)
return false;
BeforeCreateInternal ();
IntPtr handle = CreateInternal ();
if (handle == IntPtr.Zero)
return false;
mvarHandle = handle;
AfterCreateInternal ();
return true;
}
private GtkWidget mvarParent = null;
public GtkWidget Parent {
get {
if (mvarParent != null)
return mvarParent;
IntPtr handle = Internal.GTK.Methods.gtk_widget_get_parent (mvarHandle);
if (handle != IntPtr.Zero)
return null;
return null;
}
set {
Internal.GTK.Methods.gtk_widget_set_parent (mvarHandle, value.Handle);
IntPtr handleCheck = Internal.GTK.Methods.gtk_widget_get_parent (mvarHandle);
if (handleCheck == value.Handle)
mvarParent = value;
}
}
public bool Visible
{
get
{
return Internal.GTK.Methods.gtk_widget_get_visible (mvarHandle);
}
set
{
Internal.GTK.Methods.gtk_widget_set_visible (mvarHandle, value);
if (value)
Internal.GTK.Methods.gtk_widget_show_all (mvarHandle);
}
}
}
}

View File

@ -1,50 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK
{
public class GtkWindow : GtkContainer
{
protected override IntPtr CreateInternal ()
{
IntPtr handle = Internal.GTK.Methods.gtk_window_new (Internal.GTK.Constants.GtkWindowType.TopLevel);
return handle;
}
private Internal.GLib.Delegates.GCallback _this_quit = null;
private void _this_quit_impl(IntPtr sender)
{
OnClosed (EventArgs.Empty);
}
public event EventHandler Closed;
protected virtual void OnClosed (EventArgs e)
{
if (Closed != null)
Closed (this, e);
}
protected override void AfterCreateInternal ()
{
base.AfterCreateInternal ();
this.Visible = true;
Internal.GTK.Methods.gtk_widget_set_size_request (this.Handle, 600, 400);
_this_quit = new Internal.GLib.Delegates.GCallback (_this_quit_impl);
Internal.GLib.Methods.g_signal_connect (this.Handle, "destroy", _this_quit, IntPtr.Zero);
}
public string Text
{
get { return Internal.GTK.Methods.gtk_window_get_title (this.Handle); }
set { Internal.GTK.Methods.gtk_window_set_title (this.Handle, value); }
}
public void Show()
{
this.Visible = true;
}
}
}

View File

@ -1,18 +0,0 @@
using System;
using System.Runtime.InteropServices;
namespace UniversalEditor.Engines.GTK.Internal.GDK
{
internal static class Methods
{
public const string LIBRARY_FILENAME = "gdk-3";
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gdk_screen_get_default();
[DllImport(LIBRARY_FILENAME)]
public static extern double gdk_screen_get_resolution(IntPtr screen);
}
}

View File

@ -1,13 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK.Internal.GLib
{
internal static class Constants
{
public enum GConnectFlags
{
None = 0
}
}
}

View File

@ -1,11 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK.Internal.GLib
{
internal static class Delegates
{
public delegate void GCallback(IntPtr sender);
public delegate void GClosureNotify(IntPtr data, IntPtr closure);
}
}

View File

@ -1,19 +0,0 @@
using System;
using System.Runtime.InteropServices;
namespace UniversalEditor.Engines.GTK.Internal.GLib
{
internal static class Methods
{
public const string LIBRARY_FILENAME = "gobject-2.0";
public static void g_signal_connect(IntPtr instance, string detailed_signal, Delegates.GCallback c_handler, IntPtr data)
{
g_signal_connect_data (instance, detailed_signal, c_handler, data, null, Constants.GConnectFlags.None);
}
[DllImport(LIBRARY_FILENAME)]
public static extern uint g_signal_connect_data(IntPtr instance, string detailed_signal, Delegates.GCallback c_handler, IntPtr data, Delegates.GClosureNotify destroy_data, Constants.GConnectFlags connect_flags);
}
}

View File

@ -1,32 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK.Internal.GTK
{
internal static class Constants
{
public enum GApplicationFlags
{
None = 0,
IsService = (1 << 0),
IsLauncher = (1 << 1),
HandlesOpen = (1 << 2),
HandlesCommandLine = (1 << 3),
SendEnvironment = (1 << 4),
NonUnique = (1 << 5)
}
public enum GtkWindowType
{
TopLevel = 0,
Popup = 1
}
public enum GtkBoxOrientation
{
Horizontal = 0,
Vertical = 1
}
}
}

View File

@ -1,150 +0,0 @@
using System;
using System.Runtime.InteropServices;
namespace UniversalEditor.Engines.GTK.Internal.GTK
{
internal static class Methods
{
public const string LIBRARY_FILENAME_V2 = "gtk-x11-2.0";
public const string LIBRARY_FILENAME_V3 = "gtk-3";
public const string LIBRARY_FILENAME = LIBRARY_FILENAME_V3;
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_main();
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_main_quit();
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_init (ref int argc, ref string[] argv);
[DllImport(LIBRARY_FILENAME)]
public static extern bool gtk_init_check (ref int argc, ref string[] argv);
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gtk_window_new(Constants.GtkWindowType windowType);
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gtk_window_set_screen (IntPtr window, IntPtr screen);
[DllImport(LIBRARY_FILENAME)]
public static extern string gtk_window_get_title(IntPtr window);
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_window_set_title(IntPtr window, string title);
#region Application
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gtk_application_new(string application_id, Constants.GApplicationFlags flags);
#endregion
#region Widget
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_widget_set_size_request(IntPtr widget, uint width, uint height);
[DllImport(LIBRARY_FILENAME)]
public static extern bool gtk_widget_get_visible(IntPtr widget);
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_widget_set_visible(IntPtr widget, bool visible);
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gtk_widget_get_parent(IntPtr widget);
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_widget_set_parent(IntPtr widget, IntPtr parent);
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_widget_show(IntPtr widget);
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_widget_show_all(IntPtr widget);
#endregion
#region Container
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_container_add(IntPtr container, IntPtr widget);
#endregion
#region Box
[DllImport(LIBRARY_FILENAME_V2)]
private static extern IntPtr gtk_hbox_new (bool homogenous, int spacing);
[DllImport(LIBRARY_FILENAME_V2)]
private static extern IntPtr gtk_vbox_new (bool homogenous, int spacing);
[DllImport(LIBRARY_FILENAME_V3, EntryPoint="gtk_box_new")]
private static extern IntPtr gtk_box_new_v3 (Constants.GtkBoxOrientation orientation, int spacing);
public static IntPtr gtk_box_new(Constants.GtkBoxOrientation orientation, int spacing = 0)
{
return gtk_box_new (orientation, true, spacing);
}
public static IntPtr gtk_box_new(Constants.GtkBoxOrientation orientation, bool homogenous = true, int spacing = 0)
{
if (LIBRARY_FILENAME == LIBRARY_FILENAME_V2) {
switch (orientation)
{
case Constants.GtkBoxOrientation.Horizontal:
{
return gtk_hbox_new (homogenous, spacing);
}
case Constants.GtkBoxOrientation.Vertical:
{
return gtk_vbox_new (homogenous, spacing);
}
}
} else if (LIBRARY_FILENAME == LIBRARY_FILENAME_V3) {
return gtk_box_new_v3 (orientation, spacing);
}
return IntPtr.Zero;
}
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gtk_box_pack_start (IntPtr box, IntPtr child, bool expand, bool fill, int padding);
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gtk_box_pack_end (IntPtr box, IntPtr child, bool expand, bool fill, int padding);
#endregion
#region Menu Shell
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gtk_menu_shell_append(IntPtr shell, IntPtr child);
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gtk_menu_shell_insert(IntPtr shell, IntPtr child, int position);
#endregion
#region Menu Bar
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gtk_menu_bar_new();
#endregion
#region Menu
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gtk_menu_new();
[DllImport(LIBRARY_FILENAME)]
public static extern string gtk_menu_get_title(IntPtr handle);
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_menu_set_title(IntPtr handle, string title);
#endregion
#region Menu Item
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gtk_menu_item_new();
[DllImport(LIBRARY_FILENAME)]
public static extern bool gtk_menu_item_get_use_underline(IntPtr handle);
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_menu_item_set_use_underline(IntPtr handle, bool value);
[DllImport(LIBRARY_FILENAME)]
public static extern string gtk_menu_item_get_label(IntPtr handle);
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_menu_item_set_label(IntPtr handle, string text);
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gtk_menu_item_get_submenu(IntPtr handle);
[DllImport(LIBRARY_FILENAME)]
public static extern void gtk_menu_item_set_submenu(IntPtr handle, IntPtr submenu);
#endregion
#region Separator
[DllImport(LIBRARY_FILENAME)]
public static extern IntPtr gtk_separator_new(GtkBoxOrientation orientation);
#endregion
}
}

View File

@ -1,151 +0,0 @@
using System;
using UniversalEditor.UserInterface;
namespace UniversalEditor.Engines.GTK
{
public class MainWindow : GtkWindow, IHostApplicationWindow
{
private GtkWidget LoadCommandItem(CommandItem ci)
{
if (ci is CommandReferenceCommandItem)
{
CommandReferenceCommandItem crci = (ci as CommandReferenceCommandItem);
Command cmd = Engine.CurrentEngine.Commands [crci.CommandID];
if (cmd == null)
return null;
GtkMenuItem miFile = new GtkMenuItem ();
miFile.Text = cmd.Title;
if (cmd.Items.Count > 0)
{
GtkMenu miFile_Menu = new GtkMenu ();
miFile.Menu = miFile_Menu;
foreach (CommandItem ci1 in cmd.Items)
{
GtkWidget mi1 = LoadCommandItem (ci1);
if (mi1 == null)
continue;
miFile_Menu.Items.Add (mi1);
}
}
return miFile;
}
else if (ci is SeparatorCommandItem)
{
GtkSeparator sep = new GtkSeparator (GtkBoxOrientation.Horizontal);
return sep;
}
return null;
}
public MainWindow ()
{
this.Text = "Universal Editor";
GtkMenuBar mbMenuBar = new GtkMenuBar ();
foreach (CommandItem ci in Engine.CurrentEngine.MainMenu.Items)
{
GtkWidget mi = LoadCommandItem (ci);
if (mi == null)
continue;
mbMenuBar.Items.Add (mi);
}
GtkBox box = new GtkBox (GtkBoxOrientation.Vertical, 5);
box.Pack (PackDirection.Start, mbMenuBar, false, false, 3);
Controls.Add (box);
}
protected override void OnClosed (EventArgs e)
{
base.OnClosed (e);
GtkApplication.Quit ();
}
public event EventHandler WindowClosed;
protected virtual void OnWindowClosed(EventArgs e)
{
if (WindowClosed != null)
WindowClosed (this, e);
}
public void NewFile()
{
}
public void NewProject(bool combineObjects = false)
{
}
public void OpenFile() { }
public void OpenFile(params string[] fileNames) { }
public void OpenFile(params Document[] documents) { }
public void OpenProject(bool combineObjects = false) { }
public void OpenProject(string FileName, bool combineObjects = false) { }
public void SaveFile() { }
public void SaveFileAs() { }
public void SaveFileAs(string FileName, DataFormat df) { }
public void SaveProject() { }
public void SaveProjectAs() { }
public void SaveProjectAs(string FileName, DataFormat df) { }
public void SaveAll() { }
/// <summary>
/// Switches the current window's perspective.
/// </summary>
/// <param name="index">The index of the perspective to switch to.</param>
public void SwitchPerspective(int index) { }
public void CloseFile() { }
public void CloseProject() { }
public void CloseWindow() { }
public IEditorImplementation GetCurrentEditor()
{
return null;
}
public bool FullScreen { get; set; }
/// <summary>
/// Displays the "Options" dialog (on Windows, under the "Tools" menu; on Linux, under the "Edit"
/// menu, labeled as "Preferences").
/// </summary>
/// <returns>True if the user accepted the dialog; false otherwise.</returns>
public bool ShowOptionsDialog() { return false; }
public void ToggleMenuItemEnabled(string menuItemName, bool enabled) { }
public void RefreshCommand(object nativeCommandObject) { }
public void UpdateStatus(string statusText) { }
public void UpdateProgress(bool visible) { }
public void UpdateProgress(int minimum, int maximium, int value) { }
public void ActivateWindow()
{
}
public void ShowStartPage() { }
/// <summary>
/// Shows or hides the window list based on the given options.
/// </summary>
/// <param name="visible">True if the window list should be shown; false if the window list should be hidden.</param>
/// <param name="modal">True if the window list should be presented as a modal dialog; false if it should be presented as a popup (for example, during a window switch action).</param>
public void SetWindowListVisible(bool visible, bool modal) { }
}
}

View File

@ -1,11 +0,0 @@
using System;
namespace UniversalEditor.Engines.GTK
{
public enum PackDirection
{
Start,
End
}
}

View File

@ -0,0 +1,196 @@
using System;
using UniversalEditor.UserInterface;
using UniversalWidgetToolkit;
using UniversalWidgetToolkit.Controls;
namespace UniversalEditor.Engines.UWT
{
public class MainWindow : Window, IHostApplicationWindow
{
public MainWindow ()
{
foreach (CommandItem ci in UniversalEditor.UserInterface.Engine.CurrentEngine.MainMenu.Items) {
UniversalWidgetToolkit.MenuItem mi = LoadMenuItem (ci);
if (mi == null)
continue;
this.MenuBar.Items.Add (mi);
}
}
private UniversalWidgetToolkit.MenuItem LoadMenuItem(CommandItem ci)
{
if (ci is CommandReferenceCommandItem) {
CommandReferenceCommandItem crci = (ci as CommandReferenceCommandItem);
Command cmd = UniversalEditor.UserInterface.Engine.CurrentEngine.Commands [crci.CommandID];
if (cmd != null) {
CommandMenuItem mi = new CommandMenuItem (cmd.Title);
foreach (CommandItem ci1 in cmd.Items) {
UniversalWidgetToolkit.MenuItem mi1 = LoadMenuItem (ci1);
mi.Items.Add (mi1);
}
return mi;
} else {
Console.WriteLine ("attempted to load unknown cmd '" + crci.CommandID + "'");
}
return null;
} else if (ci is SeparatorCommandItem) {
return new UniversalWidgetToolkit.SeparatorMenuItem ();
}
return null;
}
#region IHostApplicationWindow implementation
public void NewFile ()
{
throw new NotImplementedException ();
}
public void NewProject (bool combineObjects = false)
{
throw new NotImplementedException ();
}
public void OpenFile ()
{
throw new NotImplementedException ();
}
public void OpenFile (params string[] fileNames)
{
throw new NotImplementedException ();
}
public void OpenFile (params Document[] documents)
{
throw new NotImplementedException ();
}
public void OpenProject (bool combineObjects = false)
{
throw new NotImplementedException ();
}
public void OpenProject (string FileName, bool combineObjects = false)
{
throw new NotImplementedException ();
}
public void SaveFile ()
{
throw new NotImplementedException ();
}
public void SaveFileAs ()
{
throw new NotImplementedException ();
}
public void SaveFileAs (string FileName, DataFormat df)
{
throw new NotImplementedException ();
}
public void SaveProject ()
{
throw new NotImplementedException ();
}
public void SaveProjectAs ()
{
throw new NotImplementedException ();
}
public void SaveProjectAs (string FileName, DataFormat df)
{
throw new NotImplementedException ();
}
public void SaveAll ()
{
throw new NotImplementedException ();
}
public void SwitchPerspective (int index)
{
throw new NotImplementedException ();
}
public void CloseFile ()
{
throw new NotImplementedException ();
}
public void CloseProject ()
{
throw new NotImplementedException ();
}
public void CloseWindow ()
{
throw new NotImplementedException ();
}
public IEditorImplementation GetCurrentEditor ()
{
throw new NotImplementedException ();
}
public bool ShowOptionsDialog ()
{
throw new NotImplementedException ();
}
public void ToggleMenuItemEnabled (string menuItemName, bool enabled)
{
throw new NotImplementedException ();
}
public void RefreshCommand (object nativeCommandObject)
{
throw new NotImplementedException ();
}
public void UpdateStatus (string statusText)
{
throw new NotImplementedException ();
}
public void UpdateProgress (bool visible)
{
throw new NotImplementedException ();
}
public void UpdateProgress (int minimum, int maximium, int value)
{
throw new NotImplementedException ();
}
public void ActivateWindow ()
{
throw new NotImplementedException ();
}
public void ShowStartPage ()
{
throw new NotImplementedException ();
}
public void SetWindowListVisible (bool visible, bool modal)
{
throw new NotImplementedException ();
}
public event EventHandler WindowClosed;
public bool FullScreen { get; set; }
#endregion
}
}

View File

@ -3,7 +3,7 @@ using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle ("UniversalEditor.Engines.GTK")]
[assembly: AssemblyTitle ("UniversalEditor.Engines.UWT")]
[assembly: AssemblyDescription ("")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("")]

View File

@ -1,24 +1,25 @@
using System;
using UniversalEditor;
using UniversalEditor.UserInterface;
namespace UniversalEditor.Engines.GTK
namespace UniversalEditor.Engines.UWT
{
public class GTKEngine : Engine
public class UWTEngine : Engine
{
protected override void InitializeInternal ()
#region implemented abstract members of Engine
protected override void ShowCrashDialog (Exception ex)
{
base.InitializeInternal ();
string[] argv = System.Environment.GetCommandLineArgs ();
int argc = argv.Length;
bool check = GtkApplication.Initialize (ref argc, ref argv);
throw new NotImplementedException ();
}
protected override void BeforeInitialization ()
{
UniversalWidgetToolkit.Application.Initialize();
}
protected override void MainLoop ()
{
GtkApplication.Run ();
UniversalWidgetToolkit.Application.Start ();
}
protected override IHostApplicationWindow OpenWindowInternal (params Document[] documents)
{
@ -26,18 +27,17 @@ namespace UniversalEditor.Engines.GTK
mw.Show ();
return mw;
}
protected override void ShowCrashDialog (Exception ex)
{
throw new NotImplementedException ();
}
public override void ShowAboutDialog (DataFormatReference dfr)
{
throw new NotImplementedException ();
}
public override bool ShowCustomOptionDialog (ref CustomOption.CustomOptionCollection customOptions, string title, EventHandler aboutButtonClicked)
public override bool ShowCustomOptionDialog (ref CustomOption.CustomOptionCollection customOptions, string title = null, EventHandler aboutButtonClicked = null)
{
throw new NotImplementedException ();
}
}
}
#endregion
}
}

View File

@ -5,10 +5,10 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>12.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{F1393A83-C180-417F-B5EE-C6EA3A3691E7}</ProjectGuid>
<ProjectGuid>{90B038C3-99D3-4E18-AFA8-FB5941909732}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>UniversalEditor.Engines.GTK</RootNamespace>
<AssemblyName>UniversalEditor.Engines.GTK</AssemblyName>
<RootNamespace>UniversalEditor.Engines.UWT</RootNamespace>
<AssemblyName>UniversalEditor.Engines.UWT</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -33,45 +33,26 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Internal\GTK\Methods.cs" />
<Compile Include="GTKEngine.cs" />
<Compile Include="Internal\GTK\Constants.cs" />
<Compile Include="Internal\GDK\Methods.cs" />
<Compile Include="GtkMenuBar.cs" />
<Compile Include="GtkWidget.cs" />
<Compile Include="GtkMenuItem.cs" />
<Compile Include="GtkMenu.cs" />
<Compile Include="Internal\GLib\Methods.cs" />
<Compile Include="Internal\GLib\Constants.cs" />
<Compile Include="Internal\GLib\Delegates.cs" />
<Compile Include="GtkWindow.cs" />
<Compile Include="MainWindow.cs" />
<Compile Include="GtkApplication.cs" />
<Compile Include="GtkMenuShell.cs" />
<Compile Include="GtkContainer.cs" />
<Compile Include="GtkBox.cs" />
<Compile Include="PackDirection.cs" />
<Compile Include="GtkSeparator.cs" />
<Compile Include="UWTEngine.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="Internal\" />
<Folder Include="Internal\GTK\" />
<Folder Include="Internal\GDK\" />
<Folder Include="Internal\GLib\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Libraries\UniversalEditor.Core\UniversalEditor.Core.csproj">
<Project>{2D4737E6-6D95-408A-90DB-8DFF38147E85}</Project>
<Name>UniversalEditor.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Libraries\UniversalEditor.UserInterface\UniversalEditor.UserInterface.csproj">
<Project>{8622EBC4-8E20-476E-B284-33D472081F5C}</Project>
<Name>UniversalEditor.UserInterface</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Libraries\UniversalEditor.Essential\UniversalEditor.Essential.csproj">
<Project>{30467E5C-05BC-4856-AADC-13906EF4CADD}</Project>
<Name>UniversalEditor.Essential</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\UniversalWidgetToolkit\Libraries\UniversalWidgetToolkit\UniversalWidgetToolkit.csproj">
<Project>{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}</Project>
<Name>UniversalWidgetToolkit</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Libraries\UniversalEditor.UserInterface\UniversalEditor.UserInterface.csproj">
<Project>{8622EBC4-8E20-476E-B284-33D472081F5C}</Project>
<Name>UniversalEditor.UserInterface</Name>
</ProjectReference>
</ItemGroup>
</Project>

View File

@ -56,7 +56,7 @@ namespace UniversalEditor
{
hue -= 360f;
}
return hue;
return (double)(hue / HSL_SCALE);
}
set { UpdateHSL (value, Saturation, Luminosity); }
}
@ -78,7 +78,7 @@ namespace UniversalEditor
{
num = 510 - num;
}
return (double)(maxRGB - minRGB) / (double)num;
return (double)((double)(maxRGB - minRGB) / (double)num) / HSL_SCALE;
}
set { UpdateHSL (Hue, value, Luminosity); }
}
@ -93,7 +93,7 @@ namespace UniversalEditor
{
int minRGB = Math.Min (this.RedInt32, Math.Min (this.GreenInt32, this.BlueInt32));
int maxRGB = Math.Max (this.RedInt32, Math.Max (this.GreenInt32, this.BlueInt32));
return (double)(maxRGB + minRGB) / 510.0;
return (double)((double)(maxRGB + minRGB) / 510.0) / HSL_SCALE;
}
set { UpdateHSL (Hue, Saturation, value); }
}
@ -119,6 +119,12 @@ namespace UniversalEditor
mvarBlue = GetColorComponent(temp1, temp2, h - 1.0 / 3.0);
}
}
else
{
mvarRed = 0.0;
mvarGreen = 0.0;
mvarBlue = 0.0;
}
}
private const double HSL_SCALE = 240.0;
@ -131,6 +137,11 @@ namespace UniversalEditor
return value;
}
public static Color FromHSL(int h, int s, int l)
{
return FromHSL ((double)h / HSL_SCALE, (double)s / HSL_SCALE, (double)l / HSL_SCALE);
}
public static Color FromHSL(double h, double s, double l)
{
double r = 0, g = 0, b = 0;
@ -148,7 +159,7 @@ namespace UniversalEditor
b = GetColorComponent(temp1, temp2, h - 1.0 / 3.0);
}
}
return Color.FromRGBA(r, g, b);
return Color.FromRGBA((int)(255 * r), (int)(255 * g), (int)(255 * b));
}
private static double GetColorComponent(double temp1, double temp2, double temp3)

View File

@ -19,11 +19,17 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Essential",
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engines", "Engines", "{B55B87C2-12E7-4622-A9CB-10A56666C8C6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GTK", "GTK", "{3BEAD9B7-C2C3-48FA-BF20-9AFF31FC3DE1}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UWT", "UWT", "{3BEAD9B7-C2C3-48FA-BF20-9AFF31FC3DE1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engines", "Engines", "{EB8C50C4-8C47-4644-94C6-3D2DC9A69D36}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Engines.GTK", "Engines\GTK\UniversalEditor.Engines.GTK\UniversalEditor.Engines.GTK.csproj", "{F1393A83-C180-417F-B5EE-C6EA3A3691E7}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Engines.UWT", "Engines\UWT\UniversalEditor.Engines.UWT\UniversalEditor.Engines.UWT.csproj", "{90B038C3-99D3-4E18-AFA8-FB5941909732}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{20F315E0-52AE-479F-AF43-3402482C1FC8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalWidgetToolkit", "..\..\UniversalWidgetToolkit\Libraries\UniversalWidgetToolkit\UniversalWidgetToolkit.csproj", "{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalWidgetToolkit.Engines.GTK", "..\..\UniversalWidgetToolkit\Engines\GTK\UniversalWidgetToolkit.Engines.GTK\UniversalWidgetToolkit.Engines.GTK.csproj", "{62DC7CF9-C608-49E5-8C39-305B2E3E93F6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{2ED32D16-6C06-4450-909A-40D32DA67FB4}"
EndProject
@ -163,6 +169,14 @@ Global
{26095090-3F7D-4DB5-A9BF-4C687230FC0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26095090-3F7D-4DB5-A9BF-4C687230FC0F}.Release|Any CPU.Build.0 = Release|Any CPU
{26095090-3F7D-4DB5-A9BF-4C687230FC0F}.Release|x86.ActiveCfg = Release|Any CPU
{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}.Debug|Any CPU.Build.0 = Debug|Any CPU
{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}.Debug|x86.ActiveCfg = Debug|Any CPU
{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}.Debug|x86.Build.0 = Debug|Any CPU
{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}.Release|Any CPU.ActiveCfg = Release|Any CPU
{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}.Release|Any CPU.Build.0 = Release|Any CPU
{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}.Release|x86.ActiveCfg = Release|Any CPU
{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}.Release|x86.Build.0 = Release|Any CPU
{2D4737E6-6D95-408A-90DB-8DFF38147E85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D4737E6-6D95-408A-90DB-8DFF38147E85}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D4737E6-6D95-408A-90DB-8DFF38147E85}.Debug|x86.ActiveCfg = Debug|Any CPU
@ -229,6 +243,14 @@ Global
{62CFC025-B8CF-42AA-880A-92F27377FCAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62CFC025-B8CF-42AA-880A-92F27377FCAF}.Release|Any CPU.Build.0 = Release|Any CPU
{62CFC025-B8CF-42AA-880A-92F27377FCAF}.Release|x86.ActiveCfg = Release|Any CPU
{62DC7CF9-C608-49E5-8C39-305B2E3E93F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{62DC7CF9-C608-49E5-8C39-305B2E3E93F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{62DC7CF9-C608-49E5-8C39-305B2E3E93F6}.Debug|x86.ActiveCfg = Debug|Any CPU
{62DC7CF9-C608-49E5-8C39-305B2E3E93F6}.Debug|x86.Build.0 = Debug|Any CPU
{62DC7CF9-C608-49E5-8C39-305B2E3E93F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{62DC7CF9-C608-49E5-8C39-305B2E3E93F6}.Release|Any CPU.Build.0 = Release|Any CPU
{62DC7CF9-C608-49E5-8C39-305B2E3E93F6}.Release|x86.ActiveCfg = Release|Any CPU
{62DC7CF9-C608-49E5-8C39-305B2E3E93F6}.Release|x86.Build.0 = Release|Any CPU
{64089452-6A08-47A5-A857-BF418F80D4A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64089452-6A08-47A5-A857-BF418F80D4A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64089452-6A08-47A5-A857-BF418F80D4A3}.Debug|x86.ActiveCfg = Debug|Any CPU
@ -289,6 +311,14 @@ Global
{899E3DD6-EA65-4168-AAE3-867A4F9650A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{899E3DD6-EA65-4168-AAE3-867A4F9650A6}.Release|Any CPU.Build.0 = Release|Any CPU
{899E3DD6-EA65-4168-AAE3-867A4F9650A6}.Release|x86.ActiveCfg = Release|Any CPU
{90B038C3-99D3-4E18-AFA8-FB5941909732}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{90B038C3-99D3-4E18-AFA8-FB5941909732}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90B038C3-99D3-4E18-AFA8-FB5941909732}.Debug|x86.ActiveCfg = Debug|Any CPU
{90B038C3-99D3-4E18-AFA8-FB5941909732}.Debug|x86.Build.0 = Debug|Any CPU
{90B038C3-99D3-4E18-AFA8-FB5941909732}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90B038C3-99D3-4E18-AFA8-FB5941909732}.Release|Any CPU.Build.0 = Release|Any CPU
{90B038C3-99D3-4E18-AFA8-FB5941909732}.Release|x86.ActiveCfg = Release|Any CPU
{90B038C3-99D3-4E18-AFA8-FB5941909732}.Release|x86.Build.0 = Release|Any CPU
{988052D4-92F5-4A6F-BE1D-33852D1E5D1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{988052D4-92F5-4A6F-BE1D-33852D1E5D1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{988052D4-92F5-4A6F-BE1D-33852D1E5D1E}.Debug|x86.ActiveCfg = Debug|Any CPU
@ -393,14 +423,6 @@ Global
{EF886E1A-D553-43DA-857C-29DA0D6E0DAE}.Release|Any CPU.Build.0 = Release|Any CPU
{EF886E1A-D553-43DA-857C-29DA0D6E0DAE}.Release|x86.ActiveCfg = Release|Any CPU
{EF886E1A-D553-43DA-857C-29DA0D6E0DAE}.Release|x86.Build.0 = Release|Any CPU
{F1393A83-C180-417F-B5EE-C6EA3A3691E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F1393A83-C180-417F-B5EE-C6EA3A3691E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F1393A83-C180-417F-B5EE-C6EA3A3691E7}.Debug|x86.ActiveCfg = Debug|Any CPU
{F1393A83-C180-417F-B5EE-C6EA3A3691E7}.Debug|x86.Build.0 = Debug|Any CPU
{F1393A83-C180-417F-B5EE-C6EA3A3691E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F1393A83-C180-417F-B5EE-C6EA3A3691E7}.Release|Any CPU.Build.0 = Release|Any CPU
{F1393A83-C180-417F-B5EE-C6EA3A3691E7}.Release|x86.ActiveCfg = Release|Any CPU
{F1393A83-C180-417F-B5EE-C6EA3A3691E7}.Release|x86.Build.0 = Release|Any CPU
{FD6B879E-46B0-47BE-860E-BF0C11135590}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD6B879E-46B0-47BE-860E-BF0C11135590}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD6B879E-46B0-47BE-860E-BF0C11135590}.Debug|x86.ActiveCfg = Debug|Any CPU
@ -435,7 +457,10 @@ Global
{30467E5C-05BC-4856-AADC-13906EF4CADD} = {0399182F-AF56-4E86-B229-EAB38C2EE6AF}
{3BEAD9B7-C2C3-48FA-BF20-9AFF31FC3DE1} = {B55B87C2-12E7-4622-A9CB-10A56666C8C6}
{EB8C50C4-8C47-4644-94C6-3D2DC9A69D36} = {3BEAD9B7-C2C3-48FA-BF20-9AFF31FC3DE1}
{F1393A83-C180-417F-B5EE-C6EA3A3691E7} = {EB8C50C4-8C47-4644-94C6-3D2DC9A69D36}
{20F315E0-52AE-479F-AF43-3402482C1FC8} = {3BEAD9B7-C2C3-48FA-BF20-9AFF31FC3DE1}
{90B038C3-99D3-4E18-AFA8-FB5941909732} = {EB8C50C4-8C47-4644-94C6-3D2DC9A69D36}
{29E1C1BB-3EA5-4062-B62F-85EEC703FE07} = {20F315E0-52AE-479F-AF43-3402482C1FC8}
{62DC7CF9-C608-49E5-8C39-305B2E3E93F6} = {20F315E0-52AE-479F-AF43-3402482C1FC8}
{64089452-6A08-47A5-A857-BF418F80D4A3} = {2ED32D16-6C06-4450-909A-40D32DA67FB4}
{BE4D0BA3-0888-42A5-9C09-FC308A4509D2} = {2ED32D16-6C06-4450-909A-40D32DA67FB4}
{D4D9C9A6-04A4-46AD-8238-2493A455723F} = {2ED32D16-6C06-4450-909A-40D32DA67FB4}