mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Update spellcheck and ui submodules.
This commit is contained in:
@@ -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 §ion) {
|
||||
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 §ion) {
|
||||
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 §ion) {
|
||||
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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user