Move some bugs to github issues, start of dialog

This commit is contained in:
Miguel de Icaza
2018-01-06 22:53:47 -05:00
parent 6666d19202
commit 7447a81e52
5 changed files with 73 additions and 19 deletions

12
Core.cs
View File

@@ -801,12 +801,14 @@ namespace Terminal {
/// </remarks>
static public event EventHandler Iteration;
public static void MakeFirstResponder (Responder newResponder)
/// <summary>
/// Returns a rectangle that is centered in the screen for the provided size.
/// </summary>
/// <returns>The centered rect.</returns>
/// <param name="size">Size for the rectangle.</param>
public static Rect MakeCenteredRect (Size size)
{
if (newResponder == null)
throw new ArgumentNullException ();
throw new NotImplementedException ();
return new Rect (new Point ((Driver.Cols - size.Width) / 2, (Driver.Rows - size.Height) / 2), size);
}
class MainLoopSyncContext : SynchronizationContext {

20
TODO.md
View File

@@ -44,6 +44,11 @@ Wanted:
- Popup menus
- Make windows draggable
High-level widgets:
- Time selector
- Date selector
- File selector
- Masked input
## Layout manager
@@ -64,21 +69,10 @@ characters everywhere
For now it is split, in case we want to introduce formal view
controllers. But the design becomes very ugly.
# Bugs
There is a problem with the high-intensity colors, they are not showing up
Add resizing support (still needs layout as well)
# Mouse support
It is still pending.
Should allow for views to be dragged, in particular Window should allow this
# Mono-Curses
The only missing feature in Mono-Curses that still relies on a native library
is to fetch the OS SIGTSTP signal, we could hardcode this value if we had
a way of detecting the host operating system and architecture, and just hardcode
the value based on this.
the value based on this.

View File

@@ -45,6 +45,7 @@
<Compile Include="Views\Checkbox.cs" />
<Compile Include="Views\Menu.cs" />
<Compile Include="Views\ScrollView.cs" />
<Compile Include="Views\Dialog.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="mono-curses.dll">

51
Views/Dialog.cs Normal file
View File

@@ -0,0 +1,51 @@
//
// Dialog.cs: Dialog box
//
// Authors:
// Miguel de Icaza (miguel@gnome.org)
//
using System;
using System.Collections.Generic;
namespace Terminal {
/// <summary>
/// The dialog box is a window that by default is centered and contains one
/// or more buttons.
/// </summary>
public class Dialog : Window {
List<Button> buttons = new List<Button> ();
public Dialog (string title, int width, int height, params Button [] buttons) : base (Application.MakeCenteredRect (new Size (width, height)))
{
foreach (var b in buttons) {
this.buttons.Add (b);
Add (b);
}
}
public override void LayoutSubviews ()
{
base.LayoutSubviews ();
int buttonSpace = 0;
int maxHeight = 0;
foreach (var b in buttons) {
buttonSpace += b.Frame.Width + 1;
maxHeight = Math.Max (maxHeight, b.Frame.Height);
}
const int borderWidth = 2;
var start = (Frame.Width-borderWidth - buttonSpace) / 2;
var y = Frame.Height - borderWidth - 2 - maxHeight;
foreach (var b in buttons) {
var bf = b.Frame;
b.Frame = new Rect (start, y, bf.Width, bf.Height);
start += bf.Width + 1;
}
}
}
}

View File

@@ -24,6 +24,12 @@ class Demo {
);
}
static void NewFile ()
{
var d = new Dialog ("New File", 50, 20, new Button ("Ok"), new Button ("Cancel"));
Application.Run (d);
}
static void Main ()
{
Application.Init ();
@@ -33,7 +39,7 @@ class Demo {
var win = new Window (new Rect (0, 1, tframe.Width, tframe.Height-1), "Hello");
var menu = new MenuBar (new MenuBarItem [] {
new MenuBarItem ("_File", new MenuItem [] {
new MenuItem ("_New", "Creates new file", null),
new MenuItem ("_New", "Creates new file", NewFile),
new MenuItem ("_Open", "", null),
new MenuItem ("_Close", "", null),
new MenuItem ("_Quit", "", null)