Commit Graph

8211 Commits

Author SHA1 Message Date
Daniel Cazzulino
ebb3c186ce Add support for ISupportInitialize/ISupportInitializeNotification for UIs (#261)
When building UIs, it's quite common to separate the UI/control building code
from the interaction logic by placing it all in a single method, usually
`InitializeComponent` or similar. This also allows other tooling to generate
such a method from potentially other UI languages (XML/Json/Yaml/whatever)
at build-time.

Even if no codegen is involved, having the UI building in a single place
allows for creating base views that provide some common boilerplate that
derived views can subsequently extend by overriding the base "initialize"
method.

The tricky part is that the base class cannot provide (at least that's
against the .NET guidelines and it certainly makes for some confusing and
potentially hard to reason bugs) a *virtual* method to do so and invoke
it from the constructor, since the base class constructor is called and
finishes *before* the derived class constructor does. This means that
fields that may be required by the derived view to build its UI in its
override of the "initialize" method would not be available by the time
the base class calls it.

Which is why the best place to handle such an approach is in the library
itself, which controls the exact time when a view is about to be shown.
Since no other method is provided for "initialize once before showing
for the first time" scenario, a good trade-off is to simply enable this
mechanism as totally opt-in by allowing views to implement `ISupportInitialize`
(which provides the `BeginInit`/`EndInit` pair) or `ISupportInitializeNotification`
(which adds `IsInitialized`/`Initialized` property/event). If the former
is implemented, the Begin/End will be called on every `Run`, since the
library has no way of knowing if the view has already been initialized
before. In these cases, the views could just clear all its controls in
the `BeginInit` and reconstruct the UI entirely in `EndInit`. The
`ISupportInitializeNotification` interface allows more control for views
that require that Begin/End init are called exactly once.
2019-10-25 16:43:48 -04:00
Daniel Cazzulino
00c5997daa Unify projects in SDK-style and PackageReference (#54)
* Unify projects in SDK-style and PackageReference

* Add a note on the known issue about dlls not being copied

* Bump CI to a more recent stable version of Mono

This adds support for .net472, the first version of .NET
with full support for netstandard2.0
2019-10-25 16:43:04 -04:00
Daniel Cazzulino
4e85b5117e Upgrade from PackageLicenseUrl to PackageLicenseExpression (#270)
The existing property is now considered legacy and results in a build warning: 

```
##[warning]C:\Program Files\dotnet\sdk\3.0.100\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(198,5): Warning NU5125: The 'licenseUrl' element will be deprecated. Consider using the 'license' element instead.
```
2019-10-25 16:42:05 -04:00
Miguel de Icaza
0d9ea2c409 Comments 2019-10-25 13:39:09 -04:00
giladlevi
5424e6d43b [Core - Subviews]: added InternalSubview property without allocations (the calling to subviews.AsReadOnly() actually allocates and Copy the List) for internal usages and keeps the public Subview property for api compatibility. (#277) 2019-10-25 13:37:21 -04:00
Daniel Cazzulino
9a70c1319b Avoid throwing when the tokenSource is cancelled (#266)
When invoking an action in the main loop, the token will be cancelled (see
`MainLoop.Invoke` and `WindowsDriver.Wakeup`). At this point when the
EventsPending is running we must avoid throwing by waiting using a cancelled token:

`eventReady.Wait(waitTimeout, tokenSource.Token)`

And make sure we reach the disposal of the token source. Otherwise we keep throwing
over and over and cause a severe performance problem for the running app.
2019-10-25 13:34:36 -04:00
giladlevi
a20d244d59 bugfix in WindowsDriver: removed the TerminalResized member that hides the inherited one from ConsoleDriver (#273) 2019-10-25 13:32:33 -04:00
Yanwei Wang
2a27cbdea5 Fix: Changed FileDialog.FilePath to full path (#263) 2019-10-25 13:29:58 -04:00
giladlevi
f0a079b242 [Re]move unwanted allocation (new CancellationTokenSource()) in WindowsDriver.EventsPending to only when needed (#274) 2019-10-25 13:29:16 -04:00
giladlevi
c832688112 Menu: added OnOpenMenu event handler. (#276) 2019-10-25 13:27:37 -04:00
Daniel Cazzulino
369e305871 Add equality comparison support for most common Dims (#278)
Specifically factor, fill and absolute now support making comparisons.
2019-10-25 10:08:19 -04:00
Daniel Cazzulino
62f5a96553 Don't force full PDBs, portable works just fine (#268) 2019-10-25 10:07:37 -04:00
Miguel de Icaza
e89a6122df View.{BrinbSubviewForward,SendSubviewBackwards,SendSubviewToBack,BringSubviewToFront 2019-10-16 10:45:58 -04:00
miguel
3097f346d3 Update 2019-09-03 23:47:29 -04:00
Daniel Cazzulino
90ce395484 Add Application.Run<T> entry point (#247)
In more "modern" app programming models (such as WPF/UWP/XF), the "app" is a
derived class that contains the UI building behavior and is the entry point.

Typically in the constructor of such a class, you'd build the main UI, menus,
etc. In the context of gui.cs, that would mean the `Main` method would typically
be:

```
Application.Init();
Application.Run(new App());
```

In order to make the code flow consistent with the existing behavior, the existing
`Init` implementation was moved to a private method that now receives a `Func<TopLevel>`
to create the top level view upon initialization. The existing behavior is unchanged
since the new `Init` just invokes the previous `TopLevel.Create` as before.

The new `Run<T>` allows the `Main` method to simply be:

```
Application.Run<App>();
```

NOTE: this was added since doing `Application.Run(new App());` failed in the
`Window`-derived class when trying to access the static `Colors` since those were
initialized as part of `Init` and creating the `App` class was too early, preventing
this slightly simpler model.
2019-09-03 23:14:27 -04:00
giladlevi
a50d79bd7b bugfix in Button.ProcessKey and expose a new function for all drivers (#253)
* added a public api function called SetTerminalResized for drivers

* bugfix: overflow exception has occurred on (Rune)c when c is an integer => casting to uint solved the problem

* Apply suggestions from code review

Co-Authored-By: Marius Ungureanu <teromario@yahoo.com>
2019-09-03 23:13:53 -04:00
Miguel de Icaza
401c872b31 ListView: simple selection implemented 2019-08-29 11:58:02 -04:00
damageboy
95f169a771 Fix linux build failure on reference assemblies (#245)
- Closes #244
2019-08-14 16:03:48 -04:00
Martin Björkström
bacf7cb688 Fixes changing focus using backtab (#243)
- Focus is now moved correctly when using tab and backtab
2019-08-14 16:00:58 -04:00
Daniel Cazzulino
3331f028d8 Update README.md (#242)
Add fancy badges :)
2019-08-06 15:56:58 -04:00
miguel
c2a1f926a5 TimeField 2019-05-29 22:58:42 -04:00
miguel
f26a626716 Zero lines makes no sense 2019-05-22 21:32:20 -04:00
miguel
56dea7423e Add timefield from Jörg Preiß 2019-05-20 21:11:22 -04:00
Miguel de Icaza
838fa8971d 0.23 2019-05-20 13:36:58 -04:00
Szymon Pobiega
add31bd83a Implement WakeUp in WindowsDriver (#208) 2019-05-12 22:01:32 -04:00
Miguel de Icaza
76d79e8852 Fix build 2019-05-09 11:33:10 -04:00
Miguel de Icaza
4653a15bda Comment 2019-05-09 11:28:27 -04:00
miguel
17c938fa50 0.23 2019-05-04 22:26:36 -04:00
miguel
42d194079b Support navigation in the presence of disabled items 2019-05-04 22:25:06 -04:00
miguel
f43dd1329d [Label] Initial move is redundant, and wrong 2019-05-04 22:25:06 -04:00
Jörg Preiß
4c03c9434b Make Alt+Hotkey in menus work (#194) 2019-05-04 22:23:52 -04:00
Kit Eason
979f5ba444 Fix caps num lock (#189)
* Fix Caps Lock and Num Lock behaviour.

* Fix inadvertent layout change.

* Indentation fix.

* Change some spaces back to tabs.
2019-05-02 12:24:46 -04:00
DieselMeister
a41b060a59 Change Cursor Position before "Changed Event" is triggert. (Issue #2 on Termina.Gui.Elmish) (#187)
In the elmish wrapper for the Termial.Gui I need the "right" cursor position when the "Changed" event is triggered. In the current Implementation the cursor position is set after the event is triggered, so either I have to wait some ms asynchronously before I can process the event or I change the order inside the ProcessKey Method by using a helper variable "oldCurPos" and set the cursor position before the SetText method is called.

Related to: https://github.com/DieselMeister/Terminal.Gui.Elmish/issues/2
2019-05-01 07:26:50 -04:00
Miguel de Icaza
29ec7aaddb Prepare for 0.22 2019-04-29 14:59:54 -04:00
Miguel de Icaza
3329e2b345 Couple of user requests 2019-04-29 14:56:54 -04:00
Miguel de Icaza
4f25625ed3 Fix #180 2019-04-29 14:36:08 -04:00
0xflotus
c8ee13195c improved Markup and fixed small error (#185) 2019-04-29 14:04:49 -04:00
Miguel de Icaza
bc19c74c60 Docs 2019-04-29 13:49:45 -04:00
Marc Talbot
8be664ce5d Spelling (#183) 2019-04-29 08:45:45 -04:00
Sergii Fesenko
6723f8f870 Fix FSharp example compilation (#184) 2019-04-29 08:45:14 -04:00
DieselMeister
e96f1e70ed Correct the ScrollView behaviour for vertical scrolling (#186)
Corrected the ScrollView behavior for vertical scrolling. In case of a vertical scrollbar the position of the "arrow" can not be determinated by the Bound.Width.
2019-04-29 08:44:41 -04:00
miguel
c4d4b6126d Update README 2019-04-14 10:25:49 -04:00
Miguel de Icaza
4141a0daaa Release notes 2019-04-10 12:28:40 -04:00
miguel
ba5d0b4c3d Fix typo: #171 2019-04-09 22:35:56 -04:00
miguel
cd684a405c Add Attribute.Make that delegates the color creation to the platform driver to more easily create attributes that can be used 2019-04-09 22:32:30 -04:00
David Pendray
df855947c0 Fix dotnet command (#176) 2019-04-04 23:27:17 -04:00
Miguel de Icaza
82398758e2 Expose some Curses APIs to the public 2019-03-14 09:39:56 -04:00
Sebastian Göls
866411ce39 Fix typo (#169) 2019-03-13 19:10:24 -07:00
Miguel de Icaza
b14ca90a34 Improve sample 2019-02-18 19:52:54 -05:00
Miguel de Icaza
9ae5dc8ca8 Update README.md 2019-02-03 23:34:23 +01:00