Update spellcheck and ui submodules.

This commit is contained in:
John Preston
2019-12-14 17:46:31 +03:00
parent dc3e9e2f3d
commit 1f2b5ba0a2
10 changed files with 35 additions and 25 deletions
@@ -54,7 +54,7 @@ void DiscreteSlider::setSelectOnPress(bool selectOnPress) {
}
void DiscreteSlider::addSection(const QString &label) {
_sections.push_back(Section(label, getLabelFont()));
_sections.push_back(Section(label, getLabelStyle()));
resizeToWidth(width());
}
@@ -63,7 +63,7 @@ void DiscreteSlider::setSections(const QStringList &labels) {
_sections.clear();
for (const auto &label : labels) {
_sections.push_back(Section(label, getLabelFont()));
_sections.push_back(Section(label, getLabelStyle()));
}
stopAnimation();
if (_activeIndex >= _sections.size()) {
@@ -152,12 +152,16 @@ int DiscreteSlider::getIndexFromPosition(QPoint pos) {
return count - 1;
}
DiscreteSlider::Section::Section(const QString &label, const style::font &font)
: label(label)
, labelWidth(font->width(label)) {
DiscreteSlider::Section::Section(
const QString &label,
const style::TextStyle &st)
: label(st, label) {
}
SettingsSlider::SettingsSlider(QWidget *parent, const style::SettingsSlider &st) : DiscreteSlider(parent)
SettingsSlider::SettingsSlider(
QWidget *parent,
const style::SettingsSlider &st)
: DiscreteSlider(parent)
, _st(st) {
setSelectOnPress(_st.ripple.showDuration == 0);
}
@@ -166,8 +170,8 @@ void SettingsSlider::setRippleTopRoundRadius(int radius) {
_rippleTopRoundRadius = radius;
}
const style::font &SettingsSlider::getLabelFont() const {
return _st.labelFont;
const style::TextStyle &SettingsSlider::getLabelStyle() const {
return _st.labelStyle;
}
int SettingsSlider::getAnimationDuration() const {
@@ -206,8 +210,8 @@ std::vector<float64> SettingsSlider::countSectionsWidths(
auto labelsWidth = 0;
auto commonWidth = true;
enumerateSections([&](const Section &section) {
labelsWidth += section.labelWidth;
if (section.labelWidth >= sectionWidth) {
labelsWidth += section.label.maxWidth();
if (section.label.maxWidth() >= sectionWidth) {
commonWidth = false;
}
return true;
@@ -219,7 +223,7 @@ std::vector<float64> SettingsSlider::countSectionsWidths(
enumerateSections([&](const Section &section) {
Expects(currentWidth != result.end());
*currentWidth = padding + section.labelWidth + padding;
*currentWidth = padding + section.label.maxWidth() + padding;
++currentWidth;
return true;
});
@@ -275,7 +279,6 @@ void SettingsSlider::paintEvent(QPaintEvent *e) {
auto clip = e->rect();
auto activeLeft = getCurrentActiveLeft();
p.setFont(_st.labelFont);
enumerateSections([&](Section &section) {
auto active = 1. - snap(qAbs(activeLeft - section.left) / float64(section.width), 0., 1.);
if (section.ripple) {
@@ -302,9 +305,14 @@ void SettingsSlider::paintEvent(QPaintEvent *e) {
if (tofill) {
p.fillRect(myrtlrect(from, _st.barTop, tofill, _st.barStroke), _st.barFg);
}
if (myrtlrect(section.left, _st.labelTop, section.width, _st.labelFont->height).intersects(clip)) {
if (myrtlrect(section.left, _st.labelTop, section.width, _st.labelStyle.font->height).intersects(clip)) {
p.setPen(anim::pen(_st.labelFg, _st.labelFgActive, active));
p.drawTextLeft(section.left + (section.width - section.labelWidth) / 2, _st.labelTop, width(), section.label, section.labelWidth);
section.label.drawLeft(
p,
section.left + (section.width - section.label.maxWidth()) / 2,
_st.labelTop,
section.label.maxWidth(),
width());
}
return true;
});