Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Proper SplitterFrame removal++
Proper SplitterFrame removal++ [message #58221] Mon, 28 March 2022 08:51 Go to next message
luoganda is currently offline  luoganda
Messages: 175
Registered: November 2016
Experienced Member
1st question is more about c++, but anyway:
I have this struct.
struct SCtrl:Ctrl{
	void Paint(Draw& w)override{
		...
	}
};
Array<Ctrl> ctrls;
Array<SCtrl> sctrls;
ctrls.Create<Button>(); //this is ok
sctrls.Create<Button>(); //this produces error(no matching member function for call to 'Add')

Can the last one be done, so that SCtrl is somehow subclassed but still used as Ctrl to be used as Button,...?
Any idea how to do this properly? maybe provide copyCtor?
~~~~

2nd question:
Simple app is included in attachment.
I would want a layout design something like foobar2000(win) or deadbeef(linux) has.
Could someone check that and try to correct it
and do it properly - since i don't know fully how SplitterFrame works and how i would do this properly.
When i add frames - it's ok(altough now childFrames are added and are children of parent ctrls - which when clicking on parent and removing it - children are then also removed, i would want to remove only SplitterFrame on which i click->Remove, but for this nonChildren would probably need to be used - siblings - altough i don't know if this is possible with SplitterFrames to do it properly).
When i remove it - problems happens, see and try code.

How to properly remove frames?
if i call sc->spl.FrameRemove(); instead of par->RemoveFrame(sc->spl) i get segmentation fault via repaint(this is called from SCtrl::RightUp...)

pwnd points to global main window,
when called from childCtrl - pfrom points to that from SCtrl::RightUp

SCtrl& AddSplitter(int where,Ctrl *pfrom){
	//SSplitterFrame& spl=splitters.Create<SSplitterFrame>();
	//spl.FrameAdd(InsetFrame());
	SCtrl& sc=ctrls.Create<SCtrl>();
	sc.spl.Set(sc.SizePos(),100,where);
	if(!pfrom)pfrom=pwnd; sc.frmid=pfrom->GetFrameCount();
	pfrom->AddFrame(sc.spl);
	return sc;
}

void NewPanel(int where,Ctrl *pfrom){
	SCtrl&ctrl=AddSplitter(where,pfrom);
	//ctrl.ctrl.Create<Button>();
	//Button&b=*(Button*)ctrl.ctrl.Get();b.SetLabel("Marana");b.LeftPos(20,100);b.TopPos(20,40);
	////ctrl.ctrl->Add(b);
}
Re: Proper SplitterFrame removal++ [message #58402 is a reply to message #58221] Tue, 17 May 2022 15:34 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13623
Registered: November 2005
Ultimate Member
luoganda wrote on Mon, 28 March 2022 08:51
1st question is more about c++, but anyway:
I have this struct.
struct SCtrl:Ctrl{
	void Paint(Draw& w)override{
		...
	}
};
Array<Ctrl> ctrls;
Array<SCtrl> sctrls;
ctrls.Create<Button>(); //this is ok
sctrls.Create<Button>(); //this produces error(no matching member function for call to 'Add')

Can the last one be done, so that SCtrl is somehow subclassed but still used as Ctrl to be used as Button,...?


You can only Create instances of classes that are derived from T. Button is descendant of Ctrl, but not SCtrl.

Quote:

Any idea how to do this properly? maybe provide copyCtor?


Do what? Smile

Mirek
Re: Proper SplitterFrame removal++ [message #58458 is a reply to message #58402] Wed, 25 May 2022 21:58 Go to previous message
luoganda is currently offline  luoganda
Messages: 175
Registered: November 2016
Experienced Member
1st question:
"Do what?"
I am subclassing Ctrl as SCtrl,
and i would like to use it - like it's written - in Array<SCtrl> sctrl;
How to do that? since now it throws error - like it's written in 1st post.

2nd question:
i observed how frames are done in foobar2000(windows) and deadbeef(linux).
Like i have suspected, both programs don't have an option to pick-and-point with mouse
to delete just any children, but have an option to delete/replace parent(which also deletes all it's children).
This is easier(recommended if one want's to stay sane Smile ), and is also how i am
currently doing it - but more sophisticated method would be to pick and delete any child of a child of a child...
Previous Topic: How would I virtualize a scrollable view to dynamically load Ctrls?
Next Topic: Add compilable testcases for nontrivial problems!
Goto Forum:
  


Current Time: Thu May 26 23:54:28 CEST 2022

Total time taken to generate the page: 0.01534 seconds