Jump to content

Recommended Posts

Posted

Hi.

Tell me please the correct way, with which you can, for example, one label to show on several pages.

Tried to replace the parent, but it does not work correctly.

It is necessary for mine to display information such as date, time and so on.

 

Best regards.

Posted

If you need information on multiple display pages the recommended way of doing things is making the page container smaller and adding the widgets that display the required information within the area not covered by that display page. There's an example of a statusbar widget in the download section.

If that is not possible (eg. due to how the UI is designed) you can actually change a widgets parent container. Here's a code snipped of a C++ wrapper class that is used inside the µGFX-Studio to accomplish this:

void UGfxWindow::setParent(const UGfxContainer* parent)
{
    // Sanity check
    if (!_ghandle) {
        return;
    }

    // Sanity check
    if (!parent || !parent->handle()) {
        return;
    }

    // Change parent container
    gwinHide(_ghandle);
    gdispGFlush(_ghandle->display);
    _ghandle->parent = parent->handle();
    gwinShow(_ghandle);
}

_ghandle is an attribute that is simply the GHandle of the µGFX window. Similary, parent->handle() is the GHandle of the new container.

Posted (edited)

HI.

I placed tow label widget in container, and changed parent properties this container.

// this code not displayed datetime bar

gwinHide(ghPageContainerStartPage);   // old parent page container for DateTimeBar

ghDateTimeBar->parent = ghPageContainerSelectByTerminalPage;

gwinShow(ghPageContainerSelectByTerminalPage);  // new parent page container for DateTimeBar

 

Container displayed only page, where was created. I using uGFX-studio for generate project.

In the previous case, I tried to change the property of parents label widgets. Sometimes this label widget displayed on new page? sometimes not displayed.

Best regards.

Edited by AlexK17
Posted

You misread the code that I posted (and probably the explanation/legend I posted below the code snipped). Just translate it to pure C code:

void widgetSetParent(GHandle widget, GHandle newParent)
{
	gwinHide(widget);
	gdispFlush();    // This is optional and only required in certain driver scenarios to prevent artifacts from showing up.
	widget->parent = newParent;
	gwinShow(widget);
}

 

Posted

Hi.

I do not know what I can do wrong.  I changed the parent to  label and container to which the label belongs, but both

labels are shown only on the start page. In debug window i see that the variable flagы is different when the label widget

is displayed on the page. Maybe it will tell you something.

flags = 0x00013F00 if widget visible on page.

flags = 0x00013D00 if widget not visible on page (parent this widget changed manually).

Best regards.

Posted
37 minutes ago, AlexK17 said:

I changed the parent to  label and container to which the label belongs, but both

labels are shown only on the start page.

You do not have to change anything on the parent container.

 

Just to be clear: What you want to achieve is to have two display pages ghContainerPage1 and ghContainerPage2 as well as a label ghLabel1. The label ghLabel1 is supposed to show up both on ghContainerPage1 and ghContainerPage2 when changing the display page. You use the widgetSetParent() function I posted above in the guiShowPage() that is being generated by the µGFX-Studio:

void guiShowPage(guiPage page)
{
	// Hide all pages
	gwinHide(ghContainerPage2);
	gwinHide(ghContainerPage1);

	// Show the selected page
	switch (page) {
		case PAGE2:
        		widgetSetParent(ghLabel1, ghContainerPage2);
			gwinShow(ghContainerPage2);
			break;

		case PAGE1:
        		widgetSetParent(ghLabel1, ghContainerPage1);
			gwinShow(ghContainerPage1);
			break;

		default:
			break;
	}
}

 

Posted

Hi.

I'm sorry, but it does not work. Labels are displayed only on the source page. What is my mistake, I do not understand.

I'm sorry to trouble you.

Best regards.

Posted (edited)
1 hour ago, AlexK17 said:

Hi.

I'm sorry, but it does not work. Labels are displayed only on the source page. What is my mistake, I do not understand.

I'm sorry to trouble you.

Best regards.

P.S. In my project there is  page where there i't a single widget, just a background of two pictures. Only on this page the label widget are displayed normally.

If i placed any widget on empty page, tow time label are not displayed.

Edited by AlexK17
Posted

Note that reparenting a widget is a real hack and is officially not supported by uGFX. The reason is that there are dependencies that may stop things working eg...

1. A child object must always be completely enclosed within its parent container

2. A child object must always have a higher z order than its parent container.

3. There are visibility dependencies.

I am sure there are others too but those three alone are enough to make this a complex operation requiring deep understanding of the internal workings of uGFX to get right. That complexity is why it is not a standard part of the uGFX API.

It is much better that you arrange your containers and widgets as non-overlapping, or duplicate such controls across the pages. As an example see the console object on the widgets demo.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...