void RoundButton::Numbers::paint(Painter &p, int x, int y, int outerWidth) { auto digitsCount = _digits.size(); if (!digitsCount) return; auto progress = anim::easeOutCirc(1., _a_ready.current(1.)); auto width = anim::interpolate(_fromWidth, _toWidth, progress); QString singleChar('0'); if (rtl()) x = outerWidth - x - width; x += width - _digits.size() * _digitWidth; auto fromTop = anim::interpolate(0, _st.font->height, progress) * (_growing ? 1 : -1); auto toTop = anim::interpolate(_st.font->height, 0, progress) * (_growing ? -1 : 1); for (auto i = 0; i != digitsCount; ++i) { auto &digit = _digits[i]; auto from = digit.from; auto to = digit.to; if (from.unicode()) { p.setOpacity(1. - progress); singleChar[0] = from; p.drawText(x + (_digitWidth - digit.fromWidth) / 2, y + fromTop + _st.font->ascent, singleChar); } if (to.unicode()) { p.setOpacity(progress); singleChar[0] = to; p.drawText(x + (_digitWidth - digit.toWidth) / 2, y + toTop + _st.font->ascent, singleChar); } x += _digitWidth; } p.setOpacity(1.); }
void matchSingleChar() const { givenACodeSampleToTokenize singleChar("a", true); ASSERT_EQUALS(true, Token::Match(singleChar.tokens(), "[a|bc]")); ASSERT_EQUALS(false, Token::Match(singleChar.tokens(), "[d|ef]")); Token multiChar(0); multiChar.str("[ab"); ASSERT_EQUALS(false, Token::Match(&multiChar, "[ab|def]")); }