1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-21 01:24:21 +00:00

Cleaned up some table look+feel code.

This commit is contained in:
jules 2013-09-28 11:50:49 +01:00
parent 3e233c2f24
commit c7cab8e020
7 changed files with 81 additions and 70 deletions

View file

@ -773,3 +773,19 @@ void IntrojucerLookAndFeel::drawButtonBackground (Graphics& g,
g.setColour (Colours::black.withAlpha (0.4f * mainAlpha));
g.strokePath (outline, PathStrokeType (1.0f));
}
void IntrojucerLookAndFeel::drawTableHeaderBackground (Graphics& g, TableHeaderComponent& header)
{
Rectangle<int> r (header.getLocalBounds());
g.setColour (Colours::black.withAlpha (0.5f));
g.fillRect (r.removeFromBottom (1));
g.setColour (Colours::white.withAlpha (0.6f));
g.fillRect (r);
g.setColour (Colours::black.withAlpha (0.5f));
for (int i = header.getNumColumns (true); --i >= 0;)
g.fillRect (header.getColumnPosition (i).removeFromRight (1));
}

View file

@ -88,28 +88,29 @@ public:
int getTabButtonOverlap (int tabDepth) override;
int getTabButtonSpaceAroundImage() override;
int getTabButtonBestWidth (TabBarButton& button, int tabDepth) override;
static Colour getTabBackgroundColour (TabBarButton& button);
void drawTabButton (TabBarButton& button, Graphics& g, bool isMouseOver, bool isMouseDown) override;
int getTabButtonBestWidth (TabBarButton&, int tabDepth) override;
static Colour getTabBackgroundColour (TabBarButton&);
void drawTabButton (TabBarButton& button, Graphics&, bool isMouseOver, bool isMouseDown) override;
Rectangle<int> getTabButtonExtraComponentBounds (const TabBarButton& button, Rectangle<int>& textArea, Component& comp) override;
Rectangle<int> getTabButtonExtraComponentBounds (const TabBarButton&, Rectangle<int>& textArea, Component&) override;
void drawTabAreaBehindFrontButton (TabbedButtonBar&, Graphics&, int, int) override {}
void drawStretchableLayoutResizerBar (Graphics& g, int /*w*/, int /*h*/, bool /*isVerticalBar*/, bool isMouseOver, bool isMouseDragging) override;
void drawStretchableLayoutResizerBar (Graphics&, int w, int h, bool isVerticalBar, bool isMouseOver, bool isMouseDragging) override;
Rectangle<int> getPropertyComponentContentPosition (PropertyComponent&) override;
bool areScrollbarButtonsVisible() override { return false; }
void drawScrollbar (Graphics& g, ScrollBar& scrollbar, int x, int y, int width, int height, bool isScrollbarVertical,
int thumbStartPosition, int thumbSize, bool /*isMouseOver*/, bool /*isMouseDown*/) override;
void drawScrollbar (Graphics&, ScrollBar&, int x, int y, int width, int height, bool isScrollbarVertical,
int thumbStartPosition, int thumbSize, bool isMouseOver, bool isMouseDown) override;
void drawConcertinaPanelHeader (Graphics& g, const Rectangle<int>& area,
bool isMouseOver, bool isMouseDown,
ConcertinaPanel& concertina, Component& panel) override;
void drawConcertinaPanelHeader (Graphics&, const Rectangle<int>& area, bool isMouseOver, bool isMouseDown,
ConcertinaPanel&, Component&) override;
void drawButtonBackground (Graphics& g, Button& button, const Colour& backgroundColour,
void drawButtonBackground (Graphics&, Button&, const Colour& backgroundColour,
bool isMouseOverButton, bool isButtonDown) override;
void drawTableHeaderBackground (Graphics&, TableHeaderComponent&) override;
static Colour getScrollbarColourForBackground (Colour background);
private:

View file

@ -403,7 +403,7 @@ bool MainWindowList::openFile (const File& file)
if (file.hasFileExtension (Project::projectFileExtension))
{
ScopedPointer <Project> newDoc (new Project (file));
ScopedPointer<Project> newDoc (new Project (file));
if (newDoc->loadFrom (file, true))
{

View file

@ -26,6 +26,40 @@
#define __JUCER_ICONS_JUCEHEADER__
//==============================================================================
struct Icon
{
Icon() : path (nullptr) {}
Icon (const Path& p, Colour c) : path (&p), colour (c) {}
Icon (const Path* p, Colour c) : path (p), colour (c) {}
void draw (Graphics& g, const Rectangle<float>& area, bool isCrossedOut) const
{
if (path != nullptr)
{
g.setColour (colour);
const RectanglePlacement placement (RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize);
g.fillPath (*path, placement.getTransformToFit (path->getBounds(), area));
if (isCrossedOut)
{
g.setColour (Colours::red.withAlpha (0.8f));
g.drawLine ((float) area.getX(), area.getY() + area.getHeight() * 0.2f,
(float) area.getRight(), area.getY() + area.getHeight() * 0.8f, 3.0f);
}
}
}
Icon withContrastingColourTo (Colour background) const
{
return Icon (path, background.contrasting (colour, 0.6f));
}
const Path* path;
Colour colour;
};
//==============================================================================
class Icons
{

View file

@ -54,41 +54,6 @@ void showUTF8ToolWindow (ScopedPointer<Component>& ownerPointer);
bool cancelAnyModalComponents();
bool reinvokeCommandAfterCancellingModalComps (const ApplicationCommandTarget::InvocationInfo&);
//==============================================================================
struct Icon
{
Icon() : path (nullptr) {}
Icon (const Path& p, Colour c) : path (&p), colour (c) {}
Icon (const Path* p, Colour c) : path (p), colour (c) {}
void draw (Graphics& g, const Rectangle<float>& area, bool isCrossedOut) const
{
if (path != nullptr)
{
g.setColour (colour);
const RectanglePlacement placement (RectanglePlacement::centred | RectanglePlacement::onlyReduceInSize);
g.fillPath (*path, placement.getTransformToFit (path->getBounds(), area));
if (isCrossedOut)
{
g.setColour (Colours::red.withAlpha (0.8f));
g.drawLine ((float) area.getX(), area.getY() + area.getHeight() * 0.2f,
(float) area.getRight(), area.getY() + area.getHeight() * 0.8f, 3.0f);
}
}
}
Icon withContrastingColourTo (Colour background) const
{
return Icon (path, background.contrasting (colour, 0.6f));
}
const Path* path;
Colour colour;
};
//==============================================================================
class RolloverHelpComp : public Component,
private Timer

View file

@ -2365,19 +2365,19 @@ void LookAndFeel::drawTableHeaderBackground (Graphics& g, TableHeaderComponent&
{
g.fillAll (Colours::white);
const int w = header.getWidth();
const int h = header.getHeight();
Rectangle<int> area (header.getLocalBounds());
area.removeFromTop (area.getHeight() / 2);
g.setGradientFill (ColourGradient (Colour (0xffe8ebf9), 0.0f, h * 0.5f,
Colour (0xfff6f8f9), 0.0f, h - 1.0f,
g.setGradientFill (ColourGradient (Colour (0xffe8ebf9), 0.0f, (float) area.getY(),
Colour (0xfff6f8f9), 0.0f, (float) area.getBottom(),
false));
g.fillRect (0, h / 2, w, h);
g.fillRect (area);
g.setColour (Colour (0x33000000));
g.fillRect (0, h - 1, w, 1);
g.fillRect (area.removeFromBottom (1));
for (int i = header.getNumColumns (true); --i >= 0;)
g.fillRect (header.getColumnPosition (i).getRight() - 1, 0, 1, h - 1);
g.fillRect (header.getColumnPosition (i).removeFromRight (1));
}
void LookAndFeel::drawTableHeaderColumn (Graphics& g, const String& columnName, int /*columnId*/,
@ -2390,28 +2390,25 @@ void LookAndFeel::drawTableHeaderColumn (Graphics& g, const String& columnName,
else if (isMouseOver)
g.fillAll (Colour (0x5599aadd));
int rightOfText = width - 4;
Rectangle<int> area (width, height);
area.reduce (4, 0);
if ((columnFlags & (TableHeaderComponent::sortedForwards | TableHeaderComponent::sortedBackwards)) != 0)
{
const float top = height * ((columnFlags & TableHeaderComponent::sortedForwards) != 0 ? 0.35f : (1.0f - 0.35f));
const float bottom = height - top;
const float w = height * 0.5f;
const float x = rightOfText - (w * 1.25f);
rightOfText = (int) x;
Path sortArrow;
sortArrow.addTriangle (x, bottom, x + w * 0.5f, top, x + w, bottom);
sortArrow.addTriangle (0.0f, 0.0f,
0.5f, (columnFlags & TableHeaderComponent::sortedForwards) != 0 ? -0.8f : 0.8f,
1.0f, 0.0f);
g.setColour (Colour (0x99000000));
g.fillPath (sortArrow);
g.fillPath (sortArrow, RectanglePlacement (RectanglePlacement::centred)
.getTransformToFit (sortArrow.getBounds(),
area.removeFromRight (height * 0.5f).reduced (2).toFloat()));
}
g.setColour (Colours::black);
g.setFont (Font (height * 0.5f, Font::bold));
const int textX = 4;
g.drawFittedText (columnName, textX, 0, rightOfText - textX, height, Justification::centredLeft, 1);
g.drawFittedText (columnName, area, Justification::centredLeft, 1);
}
//==============================================================================

View file

@ -315,12 +315,10 @@ public:
*/
virtual void tableColumnsChanged (TableHeaderComponent* tableHeader) = 0;
/** This is called when one or more of the table's columns are resized.
*/
/** This is called when one or more of the table's columns are resized. */
virtual void tableColumnsResized (TableHeaderComponent* tableHeader) = 0;
/** This is called when the column by which the table should be sorted is changed.
*/
/** This is called when the column by which the table should be sorted is changed. */
virtual void tableSortOrderChanged (TableHeaderComponent* tableHeader) = 0;
/** This is called when the user begins or ends dragging one of the columns around.