942 views
in GUI Development by
Hello all,

This is my first try to create user interface. I have "Main Screen" and "Setting" screens. From main window I call Settings as Modal window - it looks ok (seems as correct..).

When I am Ending Modal window (rootObject.EndModal( rootObject.GetModalGroup() );) I still see all window elements. So I have to count them and then remove each of them one by one by multiple calling this.Remove( GetViewAtIndex(0) );

Seems it is not correct :-) Still working but... looks and feel ugly.

My project here, please look:

https://drive.google.com/open?id=0B8plE2t3z9EEbWJzNmpqejFhNTA

2 Answers

0 votes
by

Hi Alex,

first of all, sorry for the delayed answer - your question was blocked by the system because of the external link...

Concerning your project: There is no need to remove every member of your settings component within a loop.

The idea is, that you create your component by placing all necessary members within the Composer and that you create the component dynamically during runtime and add it to the application in order to make it visible on the screen.

If you want to remove the settings component from the screen it is sufficient to call Remove() only for the settings component itself and not for each member:

GetRoot().Remove( this );

Please note, that your current implementation does not remove the settings component itself - you can see that previous instances are still within the memory, when you open and close the settings screen several times and then having a look into the Garbage Collector window.

By the way: Your project contains some conflicts, because you defined an Init() method which is already available within one of the base classes. To avoid such conflicts, please override the inherited method.

0 votes
by

Hello everybody,

i have an similar Problem as Alex. I create dynamically a component during runtime and add it to the application like this:

if ( !SimpleTouchHandler.AutoDeflected )
{
  // Determine the item at the tap position.
  var int32 inx = VerticalList.GetItemAtPosition( SimpleTouchHandler.CurrentPos );

  // An item found?
  if ( inx >= 0 )
  {
    // First create a new instance of the view class 'Views::Rectangle'
    var App::App myView= new App::MyView;

    // Area of the Widget component. Don't overlap the buttons.
    myView.Bounds.origin.x = 0;
    myView.Bounds.origin.y = 150;

    myView.RoomName = "Test";

    // Now make the just created view be a part of the GUI component.
    GetRoot().Add( myView, -1);
  }

Now i want to Remove this created component, if the user want to see a other component. Right now the new component is overlaying the other components. How do i get the "old" component, that i can remove it, befor the "new" component is create and add?
With GetRoot().Remove(this), i remove instead my VerticalList and not the component myView.

Best regards,
Torben

by
Hi,

you can simply put a variable into your component that keeps the "current" view. When you want to remove the current view, you can call Remove() and set the variable to null.

Does this help?

Best regards,

Manfred.
by
Hi,

i made a Variable CurrentView with the Type App::myView in a DeviceClass. When i create the component i do this:
App::Device.CurrentView = myNewView;

Befor a new Component is create, i check if the variable App::Device.CurrentView == null. If not i call GetRoot().Remove( App::Device.CurrentView ) and set the variable to null.

The Problem is, it works sometimes and the view/component is removed from the screen, but sometimes not. Is there a better way to do this?
by

In principle the approach to store the current view and to remove it is good - maybe the implementation can be improved...

I assume, that your application manages the current screen - so it would be sufficient to place a variable (type App::MyView) into the application.

Since you place the variable into a device class (which I assume is just an autoobject) - it is necessary to prevent the autoobject from beeing deleted and reinialized. For this purpuse it is necessary to keep a variable within the application that refers to the autoobject. Please have a look to the section lifetime of autobject. Maybe this is the reason, why it is only working sometimes...

Please have a look into the provided example SolarDemo, especially into the class Solar::PanelCarousel. There you will find three variables: CenterPanel, LeftPanel, RightPanel. The variable CenterPanel refers to the currently visible panel, the LeftPanel/RightPanel variables refer to the neighboured panels that will be shown by a slide gesture.

The method ArrangeCarousel is responsible to add and remove the panels and to update the panels within the carousel. Maybe this implementation can serve as some inspiration.

Best regards,

Manfred.

 

by
Thank you for your fast reply. I will check out your approaches.
I don't have the SolarDemo. I can find it  only on your webside to open it in the browser. Can you tell me, where i can find it as an embedded wizard project to have a look into the code?

greets,

Torben
by

You will find the examples installed together with Embedded Wizard Studio - just open example....

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...