About Glide, Pyxis, Gadgetos, NET Clix graphics performance

Sure, Gus!
I’m now working on this. :slight_smile:
And will let to know when any demo is available.

@ skewworks

Just another issue: please consider when you add controls to children collection of object inherited from Container you force it to rerender himself and all of its controls with every addition. So in the above example it takes so long just to add 90 labels to a panel and every time to render the hierarchy.

Excellent as NETMF could use more graphics support.

Glide XML

<Glide Version="1.0.3">
  <Window Name="window" Width="320" Height="240" BackColor="FFFFFF">
    <TextBlock Name="txt3" X="0" Y="208" Width="320" Height="32" Alpha="255" Text="TextBlock" TextAlign="Left" TextVerticalAlign="Middle" Font="4" FontColor="0" BackColor="000000" ShowBackColor="False"/>
    <TextBlock Name="txt2" X="0" Y="104" Width="320" Height="32" Alpha="255" Text="TextBlock" TextAlign="Left" TextVerticalAlign="Middle" Font="4" FontColor="0" BackColor="000000" ShowBackColor="False"/>
    <TextBlock Name="txt1" X="0" Y="0" Width="320" Height="32" Alpha="255" Text="TextBlock" TextAlign="Left" TextVerticalAlign="Middle" Font="4" FontColor="0" BackColor="000000" ShowBackColor="False"/>
  </Window>
</Glide>

Glide Code

using System;
using System.Threading;

using GHIElectronics.NETMF.Glide;
using GHIElectronics.NETMF.Glide.Display;
using GHIElectronics.NETMF.Glide.UI;

namespace Test
{
    public class Program
    {
        static Window window;

        public static void Main()
        {
            window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Window));

            GlideTouch.Initialize();
            Glide.MainWindow = window;

            Thread thread = new Thread(Loop);
            thread.Start();

            Thread.Sleep(-1);
        }

        public static void Loop()
        {
            TextBlock textblock;
            while (true)
            {
                DateTime dt = DateTime.Now;

                string hour = (dt.Hour < 10) ? "0" + dt.Hour.ToString() : dt.Hour.ToString();
                string minute = (dt.Minute < 10) ? "0" + dt.Minute.ToString() : dt.Minute.ToString();
                string second = (dt.Second < 10) ? "0" + dt.Second.ToString() : dt.Second.ToString();
                string result = hour + ":" + minute + ":" + second;

                for (int i = 0; i < window.NumChildren; i++)
                {
                    textblock = (TextBlock)window[i];
                    textblock.Text = result;
                    window.FillRect(textblock.Rect);
                    textblock.Invalidate();
                }
            }
        }
    }
}

@ Gothic That’s the the .suspended property is for :wink: If you suspend the parent while adding a mess of controls you’ll only get 1 redraw when you set the suspend back to false.

Is there a reason for setting 90 labels to all have transparent backgrounds? I could tweak the code to take a slightly more Windows approach and supply a redraw frame and only refresh controls hitting that frame but it would still always be necessary to refresh the parent of a transparent child because you never know what if anything in behind the child has changed.

@ Josh

It would be better to incapsulate this in the TextBlock.Text property, 'cause it’s not obvious and not good that to simply change text value we have to do 2 additional calls. Smth like that:


public string Text
    {
        get
        {
            return this._text;
        }
        set
        {
            this._text = value;
            parentWindow.FillRect(this.Rect);
            this.Invalidate();
        }
    }

@ skewworks

It’s good but not obvious. I think user shouldn’t worry about that he should use it while adding many children and not use while adding one/two children. At least I wouldn’t guess if you haven’t told.

Dear customers of my product! I strongly recommend you not to use transparent backgrounds for Labels and not to use more then X Labels in your projects! ;D BTW as for me I rarely saw Labels having solid background color for all my 13-year programming experience ???

Agree. But why the parent must refresh not only the area behind the changed child, but also full itself and all (!!!) the other children?
In Josh’s example above the code looks more reasonable:


                    window.FillRect(textblock.Rect);
                    textblock.Invalidate();

@ Gothic,

  1. The suspend property is listed in the doc and is also the same way Windows controls work :wink:

  2. Haha. I didn’t say not to use them, I just asked a question. And I also already stated I could put in an area refresh to help optimize it; so you’ll see that in 1.2.

As for not seeing solid backed labels in 13 years you must not be using Microsoft then. Start a new Visual Studio windows file. C# or VB it doesn’t matter. Drag a label onto the Form. Oh look, it has a solid default background color. Just saying.

@ skewworks
Didn’t use any other then MS though.
Yes, Label placed on a form in VS has solid background color equal to form color, so it’s an illusion of transparency. I ment I rarely saw labels with backcolor different from parent one. I just mean that while placing label on a form I don’t want to think what color has that form to assign the same color to my label. I simply want to create transparent label and place it anywhere and don’t care about color of area behind my label. Thus I can place it on two areas with different colors and don’t care how to make a half of label of one color and the other half of another one. Just force these parent’s areas to invalidate their corresponding rectangles parts.

I think it would be much better approach than that used so far.

I consider if one is making a product which he wants to sold, there hasn’t to be any assumption to get simplicity by bad quality. If only one doesn’t plan to price his product in a couple of bucks. But why then such a product is needed at all.
So taking into account all that great job that you did you should do you gui part also good!
And things like


public string Text
    {
        set
        {
            ..........
                if (base._parent != null)
                {
                    base._parent.Render(true);
                }
        }

are not acceptable. (btw, you use it as well in Font property and others)

.NET Clix code & Gadgetos code aren’t the same. :wink:
I made several upgrade when I ported the controls out.

That property you’re showing (I assume is the label from Gadgetos) reads a bit different these days.

public string Text
        {
            get { return _text; }
            set
            {
                _text = value;
                if (_transparent || _autosize)
                {
                    if (_parent != null)
                        _parent.Render(true);
                }
                else
                    Render(true);
            }
        }

You can see it now checks whether it is transparent or autosized and if so refreshes the parent. Otherwise it only redraws itself.

I appreciate your feedback, but please at least run some tests before you think early beta code for one project is the same as commercial code for another, no matter how similar they are.

Edit/Add I’ve already started making improvements where instead of calling a _parent.Render(true) it invoke a new InvalidateRect method.

@ skewworks

I saw you changed the code in Gadgetos.

this is very-very-very good!!! :slight_smile:

@ all
Guys, I don’t persuit the goal to shame anybody or to show up someone’s unsufficient professionality! Our discussion here is only to make things clear and improve them as much as possible. I think in this way we can create perfect products and make a useful contribution to our community! :wink:

@ skewworks

btw, if you are developing a “game slate” platform now then you must be creating a giu library for it as well.
May I ask, does that lib correlate with the ones for gadgetos/clix?