Page 1 of 1

wxPanel re-sizing issues

Posted: Wed Jul 24, 2019 7:49 am
by widgetMaster696969
Hi everyone,

I am currently working on a UI with wxWidgets. I'm constructing a space in the application to display a live stream video, with a big wxPanel "panelContent" that itself contains two smaller wxPanels: one to display the actual stream, "panelStream", and the other, smaller, one, "controlPanel" to go below the stream and display various buttons to seek, start, pause and stop the stream. The problem I have is not knowing how to set up these panels to allow for the panelStream to be resized according to how big the user makes the mainframe, but for the controlPanel to ALWAYS appear regardless of any resizing, subject to a minimum size. Right now, with the code posted below, the mainframe is maximized by default on Init() and thus displays everything correctly. When resizing, however, the controlPanel is the first to disappear. DevicePanel is the main window that governs all three panels mentioned above, plus one other that isn't relevant to this post. The code is a lot but I think my query is a reasonable one. Thanks for any help in advance :D

Code: Select all

void DevicePanel::Init()
{
	//main sizer to govern the two main panels
	devViewSizer = new wxBoxSizer(wxHORIZONTAL);
	SetSizer(devViewSizer);
	
	//panel to display list of bonded devices
	listSizer = new wxGridSizer(1, 0, 0);
	drawDeviceListPanel(devViewSizer, listSizer);

	//panel to display stream selected from list of devices and control panel
	sizerContent = new wxBoxSizer(wxVERTICAL);
	drawContentPanel(devViewSizer, sizerContent);

	//create a panel within deviceContentPanel to display video stream
	sizerShow = new wxBoxSizer(wxVERTICAL);
	drawVideoStreamPanel(sizerContent, sizerShow);

	//this panel contains all the streaming control buttons
	controlSizer = new wxBoxSizer(wxHORIZONTAL);
	drawControlPanel(sizerContent, controlSizer);
}

//this panel contains videoStreamPanel and controlPanel
void DevicePanel::drawContentPanel(wxSizer* devViewSizer, wxSizer* ownSizer)
{
	deviceContentPanel = new wxPanel(this, wxID_ANY, wxPoint(0, 0), wxSize(DWIDTH - 260 - 80, DHEIGHT));
	devViewSizer->Add(deviceContentPanel);
	deviceContentPanel->SetSizer(ownSizer);
}

//this panel displays the actual stream
void DevicePanel::drawVideoStreamPanel(wxSizer* devViewSizer, wxSizer* ownSizer)
{
	vidStreamPanel = new wxPanel(deviceContentPanel, wxID_ANY, wxPoint(0, 0), wxSize(DWIDTH - 260 - 80, DHEIGHT - 80 - 120));
	devViewSizer->Add(vidStreamPanel);
	//ownSizer->Add(new wxPanel(vidStreamPanel, wxID_ANY, wxPoint(0, 0), wxSize(DWIDTH - 260 - 80, (DHEIGHT - 80 - 120) / 2)));
	//vidStreamPanel->SetSizer(ownSizer);
}

//this panel contains all the streaming control buttons
void DevicePanel::drawControlPanel(wxSizer* devViewSizer, wxSizer* ownSizer)
{
	controlPanel = new wxPanel(deviceContentPanel, wxID_ANY, wxPoint(0, 0), wxSize(DWIDTH - 260 - 80, 160));
	devViewSizer->Add(controlPanel);
	controlPanel->SetSizer(ownSizer);

}

Re: wxPanel re-sizing issues

Posted: Wed Jul 24, 2019 8:36 am
by catalin
First of all, you should really trim down your code to the minimum when asking such questions. What you can easily remove are the calls that affect background, window style and creating the numerous buttons. Another inconvenient in your code is the confusing parameter names passed to your functions ("devViewSizer" everywhere?).

The answer might be as simple as

Code: Select all

    // in drawContentPanel() replace
    devViewSizer->Add(deviceContentPanel);
    // with
    devViewSizer->Add(deviceContentPanel, wxSizerFlags(1).Expand());

    // in drawVideoStreamPanel() replace
    devViewSizer->Add(vidStreamPanel);
    //with
    devViewSizer->Add(vidStreamPanel, wxSizerFlags(1).Expand());

Re: wxPanel re-sizing issues

Posted: Thu Jul 25, 2019 2:25 am
by widgetMaster696969
Sorry about that, I realized after posting that there was way too much extraneous code, but I tried to edit the post and it wouldn't let me!

Re: wxPanel re-sizing issues

Posted: Thu Jul 25, 2019 2:45 am
by widgetMaster696969
And thanks for the prompt reply! It works just the way I want it to. I don't know how I missed these flags in the documentation. Thanks again.

Re: wxPanel re-sizing issues

Posted: Thu Jul 25, 2019 9:15 am
by Nunki
Hi widgetMaster696969,

For what it's worth. I work with DialogBlocks from anthemion (written by one of the founders of wxWidgets). It's a wysiwyg way of drawing your dialogs and frames. As output you may use the generated C++ source or XRC files (=xml) which you can load and display. Saves you a lot of coding and helps you with problems like this one.

Happy coding :-)

Nunki

Re: wxPanel re-sizing issues

Posted: Tue Jul 30, 2019 8:45 am
by rocrail
Hi,
widgetMaster696969 wrote:
Wed Jul 24, 2019 7:49 am
I am currently working on a UI with wxWidgets. I'm constructing a space in the application to display a live stream video,
Maybe of topic, but I'm very interested in displaying a video live stream in a wxWidgets App.
Can/will you share your solution?

Re: wxPanel re-sizing issues

Posted: Tue Jul 30, 2019 3:45 pm
by doublemax
rocrail wrote:
Tue Jul 30, 2019 8:45 am
Hi,
widgetMaster696969 wrote:
Wed Jul 24, 2019 7:49 am
I am currently working on a UI with wxWidgets. I'm constructing a space in the application to display a live stream video,
Maybe of topic, but I'm very interested in displaying a video live stream in a wxWidgets App.
Can/will you share your solution?
You should look into wxVLC. viewtopic.php?t=44697

Re: wxPanel re-sizing issues

Posted: Tue Jul 30, 2019 7:51 pm
by rocrail
Thanks,

but I discovered that the wxWebView can handle mjpg streaming. :)
And it is standard wxWidgets.

This Python3 scripts works like a charm in combination with wxWebView:
https://picamera.readthedocs.io/en/late ... -streaming

At least testing under macOS. Windows and Linux I will test tomorrow.