14.14: tool bars scroll when narrow
This commit is contained in:
10 files changed
+147
-15
No files matched your search
@@ -165,10 +165,9 @@ BrushControls::BrushControls(EditorSession &session, QWidget *parent)
|
||||
widgets.insert(widgets.end(), {size, m_size, label(QStringLiteral("px"), this), hardness,
|
||||
m_hardnessSlider, m_hardness, label(QStringLiteral("%"), this), m_opacityLabel, m_opacitySlider, m_opacity,
|
||||
label(QStringLiteral("%"), this), m_radiusLabel, m_radiusSlider, m_radius, m_radiusUnit, m_smoothingLabel, m_smoothingSlider, m_smoothing, m_paintLabel, m_maskPaint, m_colourLabel, m_colour});
|
||||
for (QWidget *widget : widgets)
|
||||
row->insertWidget(row->count() - 1, widget);
|
||||
row->addWidget(m_cloneNote);
|
||||
row->addWidget(m_mask);
|
||||
// Swift 1.4.7: the notes scroll with the controls.
|
||||
widgets.insert(widgets.end(), {m_cloneNote, m_mask});
|
||||
scrolling(widgets, QStringLiteral("brushScroll"));
|
||||
connect(&m_session, &EditorSession::changed, this, &BrushControls::synchronize);
|
||||
synchronize();
|
||||
}
|
||||
|
||||
@@ -95,9 +95,8 @@ GradientControls::GradientControls(EditorSession &session, QWidget *parent)
|
||||
changeGradient(m_session, [value](GradientSettings &gradient) { gradient.opacity = value; });
|
||||
m_opacity->showValue();
|
||||
}});
|
||||
for (QWidget *widget : std::initializer_list<QWidget *>{m_linear, m_radial, m_swatch, m_style, m_reverse, opacity,
|
||||
m_opacitySlider, m_opacity, new QLabel(QStringLiteral("%"), this)})
|
||||
row->insertWidget(row->count() - 1, widget);
|
||||
scrolling({m_linear, m_radial, m_swatch, m_style, m_reverse, opacity, m_opacitySlider, m_opacity, new QLabel(QStringLiteral("%"), this)},
|
||||
QStringLiteral("gradientScroll"));
|
||||
for (QWidget *widget : std::initializer_list<QWidget *>{m_mask, m_cancel, m_apply})
|
||||
row->addWidget(widget);
|
||||
connect(&m_session, &EditorSession::changed, this, &GradientControls::synchronize);
|
||||
|
||||
@@ -193,12 +193,10 @@ LassoControls::LassoControls(EditorSession &session, QWidget *parent)
|
||||
scrub(m_featherUnit, m_featherAmount, 1, 250, [this] { return double(m_session.selectionFeatherAmount()); },
|
||||
[this](double amount) { m_session.setSelectionFeatherAmount(int(amount)); });
|
||||
// Swift's `unitSuffix`: a unit sits by each field.
|
||||
for (QWidget *widget : std::initializer_list<QWidget *>{m_rectangle, m_ellipse, m_wandMode, m_objectMode, m_freehand, m_polygonal, m_replace, m_add,
|
||||
m_subtract, m_toleranceLabel, m_tolerance, m_sampleSize, m_thisLayer, m_allLayers, m_contiguous,
|
||||
m_objectThisLayer, m_objectAllLayers, m_edgeLabel, m_edge, m_edgeUnit, m_antialias,
|
||||
divider, m_expand, m_expandAmount, m_expandUnit, m_contract, m_contractAmount,
|
||||
m_contractUnit, m_feather, m_featherAmount, m_featherUnit})
|
||||
row->insertWidget(row->count() - 1, widget);
|
||||
scrolling({m_rectangle, m_ellipse, m_wandMode, m_objectMode, m_freehand, m_polygonal, m_replace, m_add, m_subtract, m_toleranceLabel, m_tolerance,
|
||||
m_sampleSize, m_thisLayer, m_allLayers, m_contiguous, m_objectThisLayer, m_objectAllLayers, m_edgeLabel, m_edge, m_edgeUnit, m_antialias,
|
||||
divider, m_expand, m_expandAmount, m_expandUnit, m_contract, m_contractAmount, m_contractUnit, m_feather, m_featherAmount, m_featherUnit},
|
||||
QStringLiteral("selectionScroll"));
|
||||
row->addWidget(m_empty);
|
||||
row->addWidget(m_deselect);
|
||||
connect(&m_session, &EditorSession::changed, this, &LassoControls::synchronize);
|
||||
|
||||
@@ -27,3 +27,26 @@ ToolHeaderBar::ToolHeaderBar(const QString &text, QWidget *parent)
|
||||
row->addWidget(title);
|
||||
row->addStretch(1);
|
||||
}
|
||||
|
||||
QScrollArea *ToolHeaderBar::scrolling(const std::vector<QWidget *> &controls, const QString &name)
|
||||
{
|
||||
auto *content = new QWidget;
|
||||
auto *line = new QHBoxLayout(content);
|
||||
line->setContentsMargins(0, 0, 0, 0);
|
||||
line->setSpacing(row->spacing());
|
||||
for (QWidget *control : controls)
|
||||
line->addWidget(control);
|
||||
// The content keeps its size at the leading edge.
|
||||
line->addStretch(1);
|
||||
auto *area = new QScrollArea(this);
|
||||
area->setObjectName(name);
|
||||
area->setWidget(content);
|
||||
area->setWidgetResizable(true);
|
||||
area->setFrameShape(QFrame::NoFrame);
|
||||
area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
area->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
// It takes the spare room, as SwiftUI's does.
|
||||
row->insertWidget(row->count() - 1, area, 1);
|
||||
row->setStretch(row->count() - 1, 0);
|
||||
return area;
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
#include <QFont>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QScrollArea>
|
||||
#include <QWidget>
|
||||
#include <vector>
|
||||
|
||||
// Shared metrics: switching tools never moves the canvas.
|
||||
namespace ToolHeaderStyle {
|
||||
@@ -21,4 +23,6 @@ public:
|
||||
QLabel *const title;
|
||||
// Controls go before the stretch that ends the row.
|
||||
QHBoxLayout *const row;
|
||||
// Swift's horizontal ScrollView: these scroll, not squeeze, when narrow.
|
||||
QScrollArea *scrolling(const std::vector<QWidget *> &controls, const QString &name);
|
||||
};
|
||||
Reference in new issue
Block a user