move to UWT ContainerLayout/Glade UI, add IcarusCommandPlay
This commit is contained in:
parent
177b4854f6
commit
0ca87e490f
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkDialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Expression Editor</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="cmdOK">
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<style>
|
||||
<class name="suggested-action"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="cmdCancel">
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="ct">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.2 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkTreeStore" id="tm">
|
||||
<columns>
|
||||
<!-- column-name colCommand -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkWindow">
|
||||
<property name="can_focus">False</property>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="tv">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="model">tm</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection"/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="tvcCommand">
|
||||
<property name="resizable">True</property>
|
||||
<property name="title" translatable="yes">Command</property>
|
||||
<property name="clickable">True</property>
|
||||
<property name="reorderable">True</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
@ -304,6 +304,8 @@
|
||||
<Content Include="Editors\Documentation\DocumentationEditor.glade" />
|
||||
<Content Include="Editors\Multimedia\VectorImage\VectorImageEditor.glade" />
|
||||
<Content Include="Configuration\QuickAccessToolbar.uexml" />
|
||||
<Content Include="Editors\RavenSoftware\Icarus\IcarusScriptEditor.glade" />
|
||||
<Content Include="Editors\RavenSoftware\Icarus\Dialogs\IcarusExpressionHelperDialog.glade" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Configuration\Application.upl" />
|
||||
|
||||
@ -1,54 +0,0 @@
|
||||
//
|
||||
// IcarusExpressionHelperDialog.Designer.cs - UWT designer initialization for IcarusExpressionHelperDialog
|
||||
//
|
||||
// Author:
|
||||
// Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2019-2020 Mike Becker's Software
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
|
||||
using MBS.Framework.UserInterface;
|
||||
using MBS.Framework.UserInterface.Controls;
|
||||
using MBS.Framework.UserInterface.Layouts;
|
||||
|
||||
namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Dialogs.Icarus
|
||||
{
|
||||
partial class IcarusExpressionHelperDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// UWT designer initialization for <see cref="IcarusExpressionHelperDialog" />.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// UWT designer initialization in code is deprecated; continue improving the cross-platform Glade XML parser for <see cref="ContainerLayoutAttribute" />!
|
||||
/// </remarks>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.Buttons.Add(new Button(StockType.OK, cmdOK_Click));
|
||||
this.Buttons.Add(new Button(StockType.Cancel, DialogResult.Cancel));
|
||||
|
||||
this.Layout = new BoxLayout(Orientation.Horizontal);
|
||||
|
||||
this.Name = "IcarusExpressionHelperDialog";
|
||||
this.Text = "Expression Helper";
|
||||
}
|
||||
|
||||
protected override void OnCreating(EventArgs e)
|
||||
{
|
||||
base.OnCreating(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -20,8 +20,11 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
|
||||
using MBS.Framework.UserInterface;
|
||||
using MBS.Framework.UserInterface.Controls;
|
||||
using MBS.Framework.UserInterface.Layouts;
|
||||
|
||||
using UniversalEditor.ObjectModels.Icarus;
|
||||
using UniversalEditor.ObjectModels.Icarus.Expressions;
|
||||
using UniversalEditor.Plugins.RavenSoftware.UserInterface.Controls.Icarus;
|
||||
@ -31,11 +34,33 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Dialogs.Icarus
|
||||
/// <summary>
|
||||
/// Provides a UWT-based <see cref="CustomDialog" /> with controls for editing an expression in an Icarus script.
|
||||
/// </summary>
|
||||
[ContainerLayout("~/Editors/RavenSoftware/Icarus/Dialogs/IcarusExpressionHelperDialog.glade")]
|
||||
public partial class IcarusExpressionHelperDialog : CustomDialog
|
||||
{
|
||||
public IcarusExpressionHelperDialog()
|
||||
private Button cmdOK;
|
||||
private Button cmdCancel;
|
||||
|
||||
private Container ct;
|
||||
|
||||
protected override void OnCreated(EventArgs e)
|
||||
{
|
||||
InitializeComponent();
|
||||
base.OnCreated(e);
|
||||
|
||||
DefaultButton = cmdOK;
|
||||
UpdateCommandParameters();
|
||||
}
|
||||
|
||||
private void UpdateCommandParameters()
|
||||
{
|
||||
if (!IsCreated) return;
|
||||
|
||||
ct.Controls.Clear();
|
||||
for (int i = 0; i < _Command.Parameters.Count; i++)
|
||||
{
|
||||
IcarusExpressionEditor ed = new IcarusExpressionEditor();
|
||||
ed.Parameter = _Command.Parameters[i];
|
||||
ct.Controls.Add(ed, new BoxLayout.Constraints(true, true));
|
||||
}
|
||||
}
|
||||
|
||||
private IcarusCommand _Command = null;
|
||||
@ -45,22 +70,16 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Dialogs.Icarus
|
||||
set
|
||||
{
|
||||
_Command = value;
|
||||
|
||||
this.Controls.Clear();
|
||||
for (int i = 0; i < _Command.Parameters.Count; i++)
|
||||
{
|
||||
IcarusExpressionEditor ed = new IcarusExpressionEditor();
|
||||
ed.Parameter = _Command.Parameters[i];
|
||||
this.Controls.Add(ed, new BoxLayout.Constraints(true, true));
|
||||
}
|
||||
UpdateCommandParameters();
|
||||
}
|
||||
}
|
||||
|
||||
[EventHandler(nameof(cmdOK), "Click")]
|
||||
private void cmdOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
for (int i = 0; i < _Command.Parameters.Count; i++)
|
||||
{
|
||||
IcarusExpressionEditor ed = Controls[i] as IcarusExpressionEditor;
|
||||
IcarusExpressionEditor ed = ct.Controls[i] as IcarusExpressionEditor;
|
||||
if (ed.cboExpressionType.SelectedItem == (ed.cboExpressionType.Model as DefaultTreeModel).Rows[0])
|
||||
{
|
||||
// constant
|
||||
|
||||
@ -1,55 +0,0 @@
|
||||
//
|
||||
// IcarusScriptEditor.Designer.cs - UWT designer initialization for IcarusScriptEditor
|
||||
//
|
||||
// Author:
|
||||
// Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2019-2020 Mike Becker's Software
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using MBS.Framework.UserInterface;
|
||||
using MBS.Framework.UserInterface.Controls;
|
||||
using MBS.Framework.UserInterface.Controls.ListView;
|
||||
using MBS.Framework.UserInterface.Layouts;
|
||||
|
||||
namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Editors.Icarus
|
||||
{
|
||||
partial class IcarusScriptEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// UWT designer initialization for <see cref="IcarusScriptEditor" />.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// UWT designer initialization in code is deprecated; continue improving the cross-platform Glade XML parser for <see cref="ContainerLayoutAttribute" />!
|
||||
/// </remarks>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.Layout = new BoxLayout(Orientation.Vertical);
|
||||
|
||||
this.tm = new DefaultTreeModel(new Type[] { typeof(string) });
|
||||
|
||||
this.tv = new ListViewControl();
|
||||
this.tv.ContextMenuCommandID = "Icarus_ContextMenu";
|
||||
this.tv.Model = this.tm;
|
||||
this.tv.Columns.Add(new ListViewColumnText(this.tm.Columns[0], "Command"));
|
||||
this.tv.RowActivated += new ListViewRowActivatedEventHandler(this.tv_RowActivated);
|
||||
this.Controls.Add(this.tv, new BoxLayout.Constraints(true, true));
|
||||
}
|
||||
|
||||
private DefaultTreeModel tm;
|
||||
private ListViewControl tv;
|
||||
}
|
||||
}
|
||||
@ -42,8 +42,11 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Editors.Icarus
|
||||
/// <summary>
|
||||
/// Provides a UWT-based <see cref="Editor" /> for an <see cref="IcarusScriptObjectModel" />.
|
||||
/// </summary>
|
||||
public partial class IcarusScriptEditor : Editor
|
||||
[ContainerLayout("~/Editors/RavenSoftware/Icarus/IcarusScriptEditor.glade")]
|
||||
public class IcarusScriptEditor : Editor
|
||||
{
|
||||
private ListViewControl tv;
|
||||
|
||||
public static IcarusScriptEditorConfiguration IcarusConfiguration { get; } = new IcarusScriptEditorConfiguration();
|
||||
|
||||
private static EditorReference _er = null;
|
||||
@ -58,11 +61,22 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Editors.Icarus
|
||||
return _er;
|
||||
}
|
||||
|
||||
protected override void OnCreated(EventArgs e)
|
||||
{
|
||||
base.OnCreated(e);
|
||||
|
||||
tv.ContextMenuCommandID = "Icarus_ContextMenu";
|
||||
OnObjectModelChanged(EventArgs.Empty);
|
||||
}
|
||||
|
||||
protected override void OnToolboxItemActivated(ToolboxItemEventArgs e)
|
||||
{
|
||||
base.OnToolboxItemActivated(e);
|
||||
IcarusScriptEditorCommand cmd = e.Item.GetExtraData<IcarusScriptEditorCommand>("command");
|
||||
|
||||
BeginEdit();
|
||||
RecursiveAddCommand(ScriptEditorCommandToOMCommand(cmd));
|
||||
EndEdit();
|
||||
}
|
||||
|
||||
private IcarusCommand ScriptEditorCommandToOMCommand(IcarusScriptEditorCommand cmd)
|
||||
@ -200,7 +214,6 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Editors.Icarus
|
||||
|
||||
public IcarusScriptEditor()
|
||||
{
|
||||
InitializeComponent();
|
||||
// mnuContextRun.Font = new Font(mnuContextRun.Font, FontStyle.Bold);
|
||||
// mnuContextRun.IsDefault = true;
|
||||
|
||||
@ -477,16 +490,20 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Editors.Icarus
|
||||
{
|
||||
base.OnObjectModelChanged(e);
|
||||
|
||||
if (!IsCreated) return;
|
||||
|
||||
tv.Model.Rows.Clear();
|
||||
treeNodesForCommands.Clear();
|
||||
|
||||
IcarusScriptObjectModel script = (ObjectModel as IcarusScriptObjectModel);
|
||||
if (script == null) return;
|
||||
|
||||
BeginEdit();
|
||||
foreach (IcarusCommand command in script.Commands)
|
||||
{
|
||||
RecursiveAddCommand(command);
|
||||
}
|
||||
EndEdit();
|
||||
}
|
||||
|
||||
private void RecursiveAddCommand(IcarusCommand command, TreeModelRow parent = null)
|
||||
@ -561,6 +578,7 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Editors.Icarus
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
[EventHandler(nameof(tv), "RowActivated")]
|
||||
private void tv_RowActivated(object sender, ListViewRowActivatedEventArgs e)
|
||||
{
|
||||
if (e.Row != null)
|
||||
|
||||
@ -32,9 +32,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Dialogs\Icarus\IcarusExpressionHelperDialog.cs" />
|
||||
<Compile Include="Dialogs\Icarus\IcarusExpressionHelperDialog.Designer.cs" />
|
||||
<Compile Include="Editors\Icarus\IcarusScriptEditor.cs" />
|
||||
<Compile Include="Editors\Icarus\IcarusScriptEditor.Designer.cs" />
|
||||
<Compile Include="Controls\Icarus\IcarusExpressionEditor.cs" />
|
||||
<Compile Include="Editors\Icarus\IcarusScriptEditorEnumeration.cs" />
|
||||
<Compile Include="Editors\Icarus\IcarusScriptEditorConfiguration.cs" />
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
//
|
||||
// IcarusCommandPlay.cs - represents the ICARUS 'play' command
|
||||
//
|
||||
// Author:
|
||||
// Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2020 Mike Becker's Software
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using UniversalEditor.ObjectModels.Icarus.Parameters;
|
||||
|
||||
namespace UniversalEditor.ObjectModels.Icarus.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the ICARUS 'play' command.
|
||||
/// </summary>
|
||||
public class IcarusCommandPlay : IcarusPredefinedCommand
|
||||
{
|
||||
public IcarusCommandPlay()
|
||||
{
|
||||
Parameters.Add(new IcarusGenericParameter("Type"));
|
||||
Parameters.Add(new IcarusGenericParameter("Target"));
|
||||
}
|
||||
|
||||
public override string Name => "play";
|
||||
|
||||
public IcarusExpression Type { get { return Parameters[0].Value; } set { Parameters[0].Value = value; } }
|
||||
public IcarusExpression Target { get { return Parameters[1].Value; } set { Parameters[1].Value = value; } }
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
IcarusCommandPlay clone = new IcarusCommandPlay();
|
||||
clone.Type = (Type.Clone() as IcarusExpression);
|
||||
clone.Target = (Target.Clone() as IcarusExpression);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -81,6 +81,7 @@
|
||||
<Compile Include="ObjectModels\Icarus\Expressions\IcarusFunctionExpression.cs" />
|
||||
<Compile Include="ObjectModels\Icarus\IcarusTagType.cs" />
|
||||
<Compile Include="ObjectModels\Icarus\Commands\IcarusCommandIf.cs" />
|
||||
<Compile Include="ObjectModels\Icarus\Commands\IcarusCommandPlay.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user