getLookAndFeel().layoutFileBrowserComponent

This add ability to decide in the look and feel how to layout the FileBrowserComponent.

juce_FileBrowserComponent:

[code]void FileBrowserComponent::resized()

{
getLookAndFeel().layoutFileBrowserComponent (*this,
fileListComponent,
previewComp,
currentPathBox,
filenameBox,
goUpButton);
}[/code]

LookAndFeel.h:

[code]
class FileBrowserComponent;
class DirectoryContentsDisplayComponent;
class FilePreviewComponent;

// …

virtual void layoutFileBrowserComponent (FileBrowserComponent& browserComp,
                                         DirectoryContentsDisplayComponent* fileListComponent,
                                         FilePreviewComponent* previewComp,
                                         ComboBox* currentPathBox,
                                         TextEditor* filenameBox,
                                         Button* goUpButton);[/code]

LookAndFeel.cpp

#include "../filebrowser/juce_FilenameComponent.h"
#include "../filebrowser/juce_FileBrowserComponent.h"

// ...

void LookAndFeel::layoutFileBrowserComponent (FileBrowserComponent& browserComp,
                                              DirectoryContentsDisplayComponent* fileListComponent,
                                              FilePreviewComponent* previewComp,
                                              ComboBox* currentPathBox,
                                              TextEditor* filenameBox,
                                              Button* goUpButton)
{
    const int x = 8;
    int w = browserComp.getWidth() - x - x;

    if (previewComp != 0)
    {
        const int previewWidth = w / 3;
        previewComp->setBounds (x + w - previewWidth, 0, previewWidth, browserComp.getHeight());

        w -= previewWidth + 4;
    }

    int y = 4;

    const int controlsHeight = 22;
    const int bottomSectionHeight = controlsHeight + 8;
    const int upButtonWidth = 50;

    currentPathBox->setBounds (x, y, w - upButtonWidth - 6, controlsHeight);
    goUpButton->setBounds (x + w - upButtonWidth, y, upButtonWidth, controlsHeight);

    y += controlsHeight + 4;

    Component* const listAsComp = dynamic_cast <Component*> (fileListComponent);
    listAsComp->setBounds (x, y, w, browserComp.getHeight() - y - bottomSectionHeight);

    y = listAsComp->getBottom() + 4;
    filenameBox->setBounds (x + 50, y, w - 50, controlsHeight);
}

hope to see checked in !!

eventually would be cool also to have:

LookAndFeel.h

LookAndFeel.cpp

[code]Button* LookAndFeel::createFileBrowserGoUpButton (const String& buttonName)
{
DrawableButton* goUpButton = new DrawableButton (buttonName, DrawableButton::ImageOnButtonBackground);

Path arrowPath;
arrowPath.addArrow (50.0f, 100.0f, 50.0f, 0.0, 40.0f, 100.0f, 50.0f);

DrawablePath arrowImage;
arrowImage.setSolidFill (Colours::black.withAlpha (0.4f));
arrowImage.setPath (arrowPath);

goUpButton->setImages (&arrowImage);

return goUpButton;

}[/code]

FileBrowserComponent.h

FileBrowserComponent.cpp

[code] addAndMakeVisible (label);
label->attachToComponent (filenameBox, true);

addAndMakeVisible (goUpButton = getLookAndFeel().createFileBrowserGoUpButton ("up"));

goUpButton->addButtonListener (this);
goUpButton->setTooltip (TRANS ("go up to parent directory"));[/code]

ah and what about this ?

LookAndFeel.h

LookAndFeel.cpp

int LookAndFeel::getFileListComponentRowHeight () { return 22; }

FileListComponent.h

[code]FileListComponent::FileListComponent (DirectoryContentsList& listToShow)

: DirectoryContentsDisplayComponent (listToShow),

  ListBox (String::empty, 0)

{

setModel (this);
setRowHeight (getLookAndFeel().getFileListComponentRowHeight());

fileList.addChangeListener (this);

}[/code]

:smiley:

any chances to commit in those changes ?

Seems pretty sensible - I’ll check something in tomorrow when I get a moment…

great thanks a lot !

thanx for adding those request, you only missed setting default rowheight for file list component in look and feel: i need to save avery pixel i can :slight_smile:

virtual int getFileListComponentRowHeight ();

yeah, that one didn’t really fit because it was called in the constructor, at which point the look and feel isn’t set. It’d need to be added to the lookAndFeelChanged callback or something.

ah ok i’ve missed that one :slight_smile: anyway it is working here ?

Maybe it’s working because you’ve set a default l+f?

ah yes obviously

Sorry to get this old thread out but I want to set the height of the row of my FileListComponent and wanted to know if you implement it in another because I can’t find anything like getFileListComponentRowHeight.

FileListBoxComponent is just a ListBox, so you can just call setRowHeight on it directly.

But how can I have access to the FileListBoxComponent member of my FileBrowserComponent?

Hmm, yes, the FileBrowserComponent probably needs an accessor method to return that component. I’ll add one…