mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-24 23:31:32 +08:00
Change splitter proportion from int to double
- Allows for fine grain control (can now set 0.75 or 0.6) - Makes more sense
This commit is contained in:
parent
19192541f9
commit
d394930d74
@ -95,7 +95,7 @@ struct DockWidgetPrivate
|
||||
QList<QAction*> TitleBarActions;
|
||||
CDockWidget::eMinimumSizeHintMode MinimumSizeHintMode = CDockWidget::MinimumSizeHintFromDockWidget;
|
||||
WidgetFactory* Factory = nullptr;
|
||||
int DefaultOverlayDockProportion = 4;
|
||||
double DefaultOverlayDockProportion = 0.25;
|
||||
|
||||
/**
|
||||
* Private data constructor
|
||||
@ -1135,12 +1135,14 @@ bool CDockWidget::isCurrentTab() const
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockWidget::setDefaultOverlayDockProportion(int Proportion)
|
||||
void CDockWidget::setDefaultOverlayDockProportion(double Proportion)
|
||||
{
|
||||
d->DefaultOverlayDockProportion = Proportion;
|
||||
}
|
||||
|
||||
int CDockWidget::DefaultOverlayDockProportion() const
|
||||
|
||||
//============================================================================
|
||||
double CDockWidget::DefaultOverlayDockProportion() const
|
||||
{
|
||||
return d->DefaultOverlayDockProportion;
|
||||
}
|
||||
|
@ -514,15 +514,15 @@ public:
|
||||
|
||||
/*
|
||||
* Set default dock proportion when overlayed
|
||||
* 4 is a quarter of the size, 2 is half the size, 1 is the entire size
|
||||
* see *DefaultOverlayDockProportion()
|
||||
*/
|
||||
void setDefaultOverlayDockProportion(int Proportion);
|
||||
void setDefaultOverlayDockProportion(double Proportion);
|
||||
|
||||
/*
|
||||
* Set default dock proportion when overlayed
|
||||
* 4 is a quarter of the size, 2 is half the size, 1 is the entire size
|
||||
* 0.25 is a quarter of the size, 0.5 is half the size, 1 is the entire size
|
||||
*/
|
||||
int DefaultOverlayDockProportion() const;
|
||||
double DefaultOverlayDockProportion() const;
|
||||
|
||||
public: // reimplements QFrame -----------------------------------------------
|
||||
/**
|
||||
|
@ -243,20 +243,28 @@ void COverlayDockContainer::addDockWidget(CDockWidget* DockWidget)
|
||||
|
||||
|
||||
//============================================================================
|
||||
void COverlayDockContainer::setDockSizeProportion(int SplitterProportion)
|
||||
void COverlayDockContainer::setDockSizeProportion(double SplitterProportion)
|
||||
{
|
||||
if (SplitterProportion < 0 || SplitterProportion > 1)
|
||||
{
|
||||
ADS_PRINT("SplitterProportion must be set between 0 and 1.");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto dockSize = static_cast<int>(static_cast<double>(INT_MAX) * SplitterProportion);
|
||||
const auto remainingSize = INT_MAX - dockSize;
|
||||
switch (d->Area)
|
||||
{
|
||||
case CDockWidgetSideTab::Left:
|
||||
{
|
||||
d->Splitter->setSizes({ INT_MAX / SplitterProportion, INT_MAX - INT_MAX / SplitterProportion });
|
||||
d->Splitter->setSizes({ dockSize, remainingSize });
|
||||
break;
|
||||
}
|
||||
case CDockWidgetSideTab::Right:
|
||||
[[fallthrough]];
|
||||
case CDockWidgetSideTab::Bottom:
|
||||
{
|
||||
d->Splitter->setSizes({ INT_MAX - INT_MAX / SplitterProportion, INT_MAX / SplitterProportion });
|
||||
d->Splitter->setSizes({ remainingSize, dockSize });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -98,10 +98,10 @@ public:
|
||||
/*
|
||||
* Set default splitter sizes. Don't use when restoring state
|
||||
* As we want the size from the XML
|
||||
* Takes an int which determines the size proportion of the child dock
|
||||
* E.g. 4 is a quarter of the size, 2 is half the size and 1 is the entire size of the container
|
||||
* Takes a float between 0 and 1
|
||||
* E.g. 0.25 is a quarter of the size, 0.5 is half the size and 1 is the entire size of the container
|
||||
*/
|
||||
void setDockSizeProportion(int SplitterProportion = 4);
|
||||
void setDockSizeProportion(double SplitterProportion = 0.25);
|
||||
|
||||
/**
|
||||
* Returns the side tab bar area of this overlay dock container
|
||||
|
Loading…
Reference in New Issue
Block a user