mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Add optional setDrawsInRightMargin to disable clipping of right edge of TreeViewItems
This commit is contained in:
parent
a595f19d0f
commit
5265bbf81e
2 changed files with 21 additions and 2 deletions
|
|
@ -1150,6 +1150,7 @@ TreeViewItem::TreeViewItem()
|
|||
drawLinesInside (false),
|
||||
drawLinesSet (false),
|
||||
drawsInLeftMargin (false),
|
||||
drawsInRightMargin (false),
|
||||
openness (opennessDefault)
|
||||
{
|
||||
static int nextUID = 0;
|
||||
|
|
@ -1505,6 +1506,11 @@ void TreeViewItem::setDrawsInLeftMargin (bool canDrawInLeftMargin) noexcept
|
|||
drawsInLeftMargin = canDrawInLeftMargin;
|
||||
}
|
||||
|
||||
void TreeViewItem::setDrawsInRightMargin (bool canDrawInRightMargin) noexcept
|
||||
{
|
||||
drawsInRightMargin = canDrawInRightMargin;
|
||||
}
|
||||
|
||||
namespace TreeViewHelpers
|
||||
{
|
||||
static int calculateDepth (const TreeViewItem* item, const bool rootIsVisible) noexcept
|
||||
|
|
@ -1532,7 +1538,7 @@ void TreeViewItem::paintRecursively (Graphics& g, int width)
|
|||
return;
|
||||
|
||||
const int indent = getIndentX();
|
||||
const int itemW = itemWidth < 0 ? width - indent : itemWidth;
|
||||
const int itemW = (itemWidth < 0 || drawsInRightMargin) ? width - indent : itemWidth;
|
||||
|
||||
{
|
||||
Graphics::ScopedSaveState ss (g);
|
||||
|
|
@ -1544,7 +1550,7 @@ void TreeViewItem::paintRecursively (Graphics& g, int width)
|
|||
if (isSelected())
|
||||
g.fillAll (ownerView->findColour (TreeView::selectedItemBackgroundColourId));
|
||||
|
||||
paintItem (g, itemW, itemHeight);
|
||||
paintItem (g, itemWidth < 0 ? width - indent : itemWidth, itemHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -446,6 +446,18 @@ public:
|
|||
*/
|
||||
void setDrawsInLeftMargin (bool canDrawInLeftMargin) noexcept;
|
||||
|
||||
/** Sets a flag to indicate that the item wants to be allowed
|
||||
to draw all the way across to the left edge of the treeview.
|
||||
|
||||
Similar to setDrawsInLeftMargin: when this flag is set to true,
|
||||
then the graphics context isn't clipped on the right side. Note,
|
||||
that, in contrast to setDrawsInLeftMargin, you will very rarely need
|
||||
to use this function, as, by default, the paintItem() method
|
||||
won't be clipped on the right hand side, unless your TreeViewItem
|
||||
overrides getItemWidth.
|
||||
*/
|
||||
void setDrawsInRightMargin (bool canDrawInRightMargin) noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Saves the current state of open/closed nodes so it can be restored later.
|
||||
|
||||
|
|
@ -544,6 +556,7 @@ private:
|
|||
bool drawLinesInside : 1;
|
||||
bool drawLinesSet : 1;
|
||||
bool drawsInLeftMargin : 1;
|
||||
bool drawsInRightMargin : 1;
|
||||
unsigned int openness : 2;
|
||||
|
||||
friend class TreeView;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue