wxPanel re-sizing issues Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
widgetMaster696969
In need of some credit
In need of some credit
Posts: 8
Joined: Wed Jul 24, 2019 7:38 am

wxPanel re-sizing issues

Post by widgetMaster696969 » Wed Jul 24, 2019 7:49 am

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);

}
Last edited by widgetMaster696969 on Thu Jul 25, 2019 2:30 am, edited 2 times in total.

catalin
Moderator
Moderator
Posts: 1526
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: wxPanel re-sizing issues

Post by catalin » Wed Jul 24, 2019 8:36 am

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());

widgetMaster696969
In need of some credit
In need of some credit
Posts: 8
Joined: Wed Jul 24, 2019 7:38 am

Re: wxPanel re-sizing issues

Post by widgetMaster696969 » Thu Jul 25, 2019 2:25 am

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!

widgetMaster696969
In need of some credit
In need of some credit
Posts: 8
Joined: Wed Jul 24, 2019 7:38 am

Re: wxPanel re-sizing issues

Post by widgetMaster696969 » Thu Jul 25, 2019 2:45 am

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.

Nunki
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 200
Joined: Fri Sep 14, 2012 8:26 am
Location: Kontich, Belgium
Contact:

Re: wxPanel re-sizing issues

Post by Nunki » Thu Jul 25, 2019 9:15 am

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

User avatar
rocrail
I live to help wx-kind
I live to help wx-kind
Posts: 179
Joined: Fri Oct 02, 2009 2:02 pm
Contact:

Re: wxPanel re-sizing issues

Post by rocrail » 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?
Best regards,
Rob.

User avatar
doublemax
Moderator
Moderator
Posts: 14198
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxPanel re-sizing issues

Post by doublemax » Tue Jul 30, 2019 3:45 pm

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
Use the source, Luke!

User avatar
rocrail
I live to help wx-kind
I live to help wx-kind
Posts: 179
Joined: Fri Oct 02, 2009 2:02 pm
Contact:

Re: wxPanel re-sizing issues

Post by rocrail » Tue Jul 30, 2019 7:51 pm

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.
Best regards,
Rob.

Post Reply