How do you minimize?

ahhh, I see what you mean.

You may well be right then. That’s a Jules question…

Feel free to fix uit if you can though. :wink:

Oh well, heres to officially to sucking up another day… of which I basically got not one step closer to accomplishing anything. :shock:

Components just stay wherever you put them, and in the code above it doesn’t look like you’re even giving them any sizes or positions at all, so no wonder they don’t appear.

The way to do it is to create and add them to the parent comp in the constructor, then have a resized() method that repositions all the child components each time the window is resized.

And if you want a full-screen window, don’t just set it to the size of the desktop - use NativeDesktopWindow::setFullScreen, which copes with multiple monitors, screen resizing, taskbars, etc

but the position and size is set in the titlebar constructor as such…

[code]ApplicationTitleBar::ApplicationTitleBar()
: Component (T(“Title Bar”))
{
setBounds (0,0, getParentWidth(),21);

addAndMakeVisible (minimizeButton = new TextButton (
T("-"), Colours::black, Colour(0xFF88889F), Colour(0xFF222228),
T(“Minimize”)));
minimizeButton->addActionListener (this);
minimizeButton->setBounds(getParentWidth()-42,0,20,20);
minimizeButton->setName(“MinimizeButton”);

addAndMakeVisible (closeButton = new TextButton (
T(“X”), Colours::black, Colour(0xFF88889F), Colour(0xFF222228),
T(“Close”)));
closeButton->addActionListener (this);
closeButton->setBounds(getParentWidth()-21,0,20,20);
closeButton->setName(“CloseButton”);

// add application buttons
}[/code]

so why is it that the title bar doesn’t appear if the parent is manually set to 1024x768 upon instancing in the first place? The TitleBar constructor seems to ignore the getparentwidth() and simply use the desktop.

Sorry if I’m not making sense… I’m just trying to understand. The way valley wrote this makes sense to me… and I don’t understand why it doesn’t work. I would think no matter what I set the mainwindow too… the buttons will adjust to the size of the window when it is instanced in the first place. I’m not talking about resizing here… just the initialization.

I wouldn’t make the mistake of assuming my stuff is right.

I barely had chance to glance at the JUCE docs this weekend - I was mostly coding and posting in between plastering/sanding sessions. :wink:

Is my use of getParentWidth correct?

I’m assuming it gives the parent container (component), but is is possible it gives for example the screen, in which case this code would not work if you sized your base window compent smaller than your desktop.

I never tested that, as I was using the NativeDesktopWindow::setFullScreen method to set the initial window size.

RTFM lads - this is the help for getParentWidth()

/** Returns the width of the component's parent.

    If the component has no parent (i.e. if it's on the desktop), this will return
    the width of the screen.
*/

OK, I think I know what I did wrong Mod.

I’m guessing that the addAndMakeVisible creates the child before taking ownership of it, so probably at constructor time the child has no parent, so getParentWidth() will return the desktop size.

That code should be changed such that the size is set after the constructor has finished. Don’t think of this is a Delphi setParent/setSize way where everything can be donme in one pass from inside the constructor.

What this means is that each component layer needs a resize handler for its’ child components.

IE

MainForm
createChild1
createChild2
mainResizeHandler

Child1
createSubChild1
createSubChild2
createSubChild3
child1ResizeHandler

etc…

Hey valley, I think it makes more sense for this project to be in Juce/Projects/SampleEditor.

you seem to have it in /Juce

Think we could change that? :slight_smile:

This is definetly a hack I think…

But if you toss this in, you get the window set properly after un-minimizing it.

void ApplicationMainWindow::minimisationStateChanged (bool isNowMinimised)
{
	if (isNowMinimised == 0)
	{
		repaint(0, 0, getParentHeight(), getParentWidth());
	}
}

Quick fix for now…

Working to see why the children aren’t working (not sure if I even understand the problem yet.

editted: made it a more complete hack :slight_smile: This cant stay very long! Seems like its gonna cause some weird shit later… there should be a callback for this shit… where is it.

so I stayed up trying to figure out the buttons things… and I think I’ve finally come to grips with what’s going it.

It’s as valley and jules hinted, the constructor must finish before you go using getparent(), otherwise it’s it’s not actually a child in the case of the way the SampleEditor mock up was written.

So… I tried something and it worked… (btw, first time I used a debugger and it really helped me see what the hell was going on).

Ignore the hack nature…

// add title bar addAndMakeVisible(titleBar = new ApplicationTitleBar(), 0); titleBar->setBounds (0,0, titleBar->getParentWidth(),21);

it let’s the constructor create the object, then it sets the size and position afterwards. getParentWidth() will be the correct value… no matter what you size the main window.

the button became a problem because getParantWidth()

was being called in the titlebar constructor. The debugger revealed that the value it was returning was zero, thus 0-42 = no show on the screen.

so just as a test, I pulled the setbounds out… and threw them in resize() inside tittleBar…

void ApplicationTitleBar::resized() { // place buttons on title bar minimizeButton->setBounds(minimizeButton->getParentWidth()-42,0,20,20); closeButton->setBounds(closeButton->getParentWidth()-21,0,20,20); }

now it works, change the static size and the buttons follow… dunno if that’s proper… but it’s getting called after the contructor… thus the buttons being fed the proper widths of their parent.

Enuf geeking out tonight… C++ makes my brain hurt… just had to discuss my revelation before hitting the bed. Lots to learn with this c++ biz…

:roll: :wink:

ARGH! Now it places everything right, but the buttons are all sluggish now! WTF?! :shock: :? :evil:

too bad Im taking a break today… you better not fix it before I do! lol :slight_smile:

Hah! it’s because I was in debug mode! Okee righteous! So the buttons are placed correctly, now for the resize… muahahah! :twisted:

get on aim fool.