JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
juce::StretchableObjectResizer Class Reference

A utility class for fitting a set of objects whose sizes can vary between a minimum and maximum size, into a space. More...

#include "juce_StretchableObjectResizer.h"

Public Member Functions

 StretchableObjectResizer ()
 Creates an empty object resizer.
 
 ~StretchableObjectResizer ()
 Destructor.
 
void addItem (double currentSize, double minSize, double maxSize, int order=0)
 Adds an item to the list.
 
void resizeToFit (double targetSize)
 Resizes all the items to fit this amount of space.
 
int getNumItems () const noexcept
 Returns the number of items that have been added.
 
double getItemSize (int index) const noexcept
 Returns the size of one of the items.
 

Detailed Description

A utility class for fitting a set of objects whose sizes can vary between a minimum and maximum size, into a space.

This is a trickier algorithm than it would first seem, so I've put it in this class to allow it to be shared by various bits of code.

To use it, create one of these objects, call addItem() to add the list of items you need, then call resizeToFit(), which will change all their sizes. You can then retrieve the new sizes with getItemSize() and getNumItems().

It's currently used by the TableHeaderComponent for stretching out the table headings to fill the table's width.

@tags{GUI}

Definition at line 46 of file juce_StretchableObjectResizer.h.

Constructor & Destructor Documentation

◆ StretchableObjectResizer()

juce::StretchableObjectResizer::StretchableObjectResizer ( )

Creates an empty object resizer.

Definition at line 29 of file juce_StretchableObjectResizer.cpp.

◆ ~StretchableObjectResizer()

juce::StretchableObjectResizer::~StretchableObjectResizer ( )

Destructor.

Definition at line 30 of file juce_StretchableObjectResizer.cpp.

Member Function Documentation

◆ addItem()

void juce::StretchableObjectResizer::addItem ( double  currentSize,
double  minSize,
double  maxSize,
int  order = 0 
)

Adds an item to the list.

The order parameter lets you specify groups of items that are resized first when some space needs to be found. Those items with an order of 0 will be the first ones to be resized, and if that doesn't provide enough space to meet the requirements, the algorithm will then try resizing the items with an order of 1, then 2, and so on.

Definition at line 32 of file juce_StretchableObjectResizer.cpp.

◆ getItemSize()

double juce::StretchableObjectResizer::getItemSize ( int  index) const
noexcept

Returns the size of one of the items.

Definition at line 48 of file juce_StretchableObjectResizer.cpp.

◆ getNumItems()

int juce::StretchableObjectResizer::getNumItems ( ) const
noexcept

Returns the number of items that have been added.

Definition at line 81 of file juce_StretchableObjectResizer.h.

◆ resizeToFit()

void juce::StretchableObjectResizer::resizeToFit ( double  targetSize)

Resizes all the items to fit this amount of space.

This will attempt to fit them in without exceeding each item's minimum and maximum sizes. In cases where none of the items can be expanded or enlarged any further, the final size may be greater or less than the size passed in.

After calling this method, you can retrieve the new sizes with the getItemSize() method.

Definition at line 54 of file juce_StretchableObjectResizer.cpp.


The documentation for this class was generated from the following files: