Exemple #1
0
Radiobutton::Radiobutton(QWidget *parent, const QString &group, int32 value, const QString &text, bool checked, const style::Radiobutton &st) : Button(parent),
_st(st),
a_over(0), a_checked(checked ? 1 : 0),
_a_over(animFunc(this, &Radiobutton::animStep_over)), _a_checked(animFunc(this, &Radiobutton::animStep_checked)),
_text(text), _fullText(text), _textWidth(st.font->width(text)),
_checked(checked), _group(radiobuttons.reg(group)), _value(value) {
	if (_st.width <= 0) {
		resize(_textWidth - _st.width, _st.height);
	} else {
		if (_st.width < _st.textPosition.x() + _textWidth + (_st.textPosition.x() - _st.diameter)) {
			_text = _st.font->elided(_fullText, qMax(_st.width - (_st.textPosition.x() + (_st.textPosition.x() - _st.diameter)), 1.));
			_textWidth = _st.font->width(_text);
		}
		resize(_st.width, _st.height);
	}
	_checkRect = myrtlrect(0, 0, _st.diameter, _st.diameter);

	connect(this, SIGNAL(clicked()), this, SLOT(onClicked()));
	connect(this, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(onStateChange(int, ButtonStateChangeSource)));

	setCursor(style::cur_pointer);

	setAttribute(Qt::WA_OpaquePaintEvent);

	reinterpret_cast<RadiobuttonGroup*>(_group)->insert(this, true);
	if (_checked) onChanged();
}
Exemple #2
0
PlayerWidget::PlayerWidget(QWidget *parent) : TWidget(parent),
_prevAvailable(false), _nextAvailable(false), _fullAvailable(false),
_over(OverNone), _down(OverNone), _downCoord(0), _downFrequency(AudioVoiceMsgFrequency), _downProgress(0.),
_stateAnim(animFunc(this, &PlayerWidget::stateStep)),
_index(-1), _history(0), _timeWidth(0), _repeat(false), _showPause(false), _position(0), _duration(0), _loaded(0),
a_progress(0., 0.), a_loadProgress(0., 0.), _progressAnim(animFunc(this, &PlayerWidget::progressStep)) {
	resize(st::wndMinWidth, st::playerHeight);
	setMouseTracking(true);
	memset(_stateHovers, 0, sizeof(_stateHovers));
}
    //-----------------------------------------------------------------------
    Controller<Real>* ControllerManager::createTextureAnimator(TextureUnitState* layer, Real sequenceTime)
    {
        SharedPtr< ControllerValue<Real> > texVal(OGRE_NEW TextureFrameControllerValue(layer));
        SharedPtr< ControllerFunction<Real> > animFunc(OGRE_NEW AnimationControllerFunction(sequenceTime));

        return createController(mFrameTimeController, texVal, animFunc);
    }
Exemple #4
0
BlueTitleClose::BlueTitleClose(QWidget *parent) : Button(parent)
, a_iconFg(st::boxBlueCloseBg->c)
, _a_over(animFunc(this, &BlueTitleClose::animStep_over)) {
	resize(st::boxTitleHeight, st::boxTitleHeight);
	setCursor(style::cur_pointer);
	connect(this, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(onStateChange(int, ButtonStateChangeSource)));
}
Exemple #5
0
Checkbox::Checkbox(QWidget *parent, const QString &text, bool checked, const style::Checkbox &st) : Button(parent),
_st(st),
a_over(0), a_checked(checked ? 1 : 0),
_a_over(animFunc(this, &Checkbox::animStep_over)), _a_checked(animFunc(this, &Checkbox::animStep_checked)),
_text(text), _fullText(text), _textWidth(st.font->width(text)),
_checked(checked) {
	if (_st.width <= 0) {
		resize(_textWidth - _st.width, _st.height);
	} else {
		if (_st.width < _st.textPosition.x() + _textWidth + (_st.textPosition.x() - _st.diameter)) {
			_text = _st.font->elided(_fullText, qMax(_st.width - (_st.textPosition.x() + (_st.textPosition.x() - _st.diameter)), 1.));
			_textWidth = _st.font->width(_text);
		}
		resize(_st.width, _st.height);
	}
	_checkRect = myrtlrect(0, 0, _st.diameter, _st.diameter);

	connect(this, SIGNAL(clicked()), this, SLOT(onClicked()));
	connect(this, SIGNAL(stateChanged(int, ButtonStateChangeSource)), this, SLOT(onStateChange(int, ButtonStateChangeSource)));

	setCursor(style::cur_pointer);

	setAttribute(Qt::WA_OpaquePaintEvent);
}
Exemple #6
0
MaxInviteBox::MaxInviteBox(const QString &link) : AbstractBox(st::boxWidth),
_close(this, lang(lng_box_ok), st::defaultBoxButton),
_text(st::boxTextFont, lng_participant_invite_sorry(lt_count, cMaxGroupCount()), _confirmBoxTextOptions, st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()),
_link(link), _linkOver(false),
a_goodOpacity(0, 0), a_good(animFunc(this, &MaxInviteBox::goodAnimStep)) {
	setMouseTracking(true);

	_textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right();
	_textHeight = qMin(_text.countHeight(_textWidth), 16 * int(st::boxTextStyle.lineHeight));
	setMaxHeight(st::boxPadding.top() + _textHeight + st::boxTextFont->height + st::boxTextFont->height * 2 + st::newGroupLinkPadding.bottom() + st::boxButtonPadding.top() + _close.height() + st::boxButtonPadding.bottom());

	connect(&_close, SIGNAL(clicked()), this, SLOT(onClose()));

	prepare();
}
Exemple #7
0
InputField::InputField(QWidget *parent, const style::InputField &st, const QString &ph, const QString &val) : TWidget(parent),
_inner(this, val),
_oldtext(val),
_keyEvent(0),

_undoAvailable(false),
_redoAvailable(false),

_fakeMargin(0),
_customUpDown(false),

_placeholderFull(ph),
_placeholderVisible(val.isEmpty()),
a_placeholderLeft(_placeholderVisible ? 0 : st.placeholderShift),
a_placeholderOpacity(_placeholderVisible ? 1 : 0),
a_placeholderFg(st.placeholderFg->c),
_placeholderFgAnim(animFunc(this, &InputField::placeholderFgStep)),
_placeholderShiftAnim(animFunc(this, &InputField::placeholderShiftStep)),

a_borderOpacityActive(0),
a_borderFg(st.borderFg->c),
_borderAnim(animFunc(this, &InputField::borderStep)),

_focused(false), _error(false),

_st(&st),

_touchPress(false),
_touchRightButton(false),
_touchMove(false),
_replacingEmojis(false) {
	_inner.setAcceptRichText(false);
	resize(_st->width, _st->height);

	_inner.setWordWrapMode(QTextOption::NoWrap);
	_inner.setLineWrapMode(QTextEdit::NoWrap);

	_inner.setFont(_st->font->f);
	_inner.setAlignment(cRtl() ? Qt::AlignRight : Qt::AlignLeft);

	_placeholder = _st->font->m.elidedText(_placeholderFull, Qt::ElideRight, width() - _st->textMargins.left() - _st->textMargins.right() - _st->placeholderMargins.left() - _st->placeholderMargins.right() - 1);

	QPalette p(palette());
	p.setColor(QPalette::Text, _st->textFg->c);
	setPalette(p);

	_inner.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	_inner.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

	_inner.setFrameStyle(QFrame::NoFrame | QFrame::Plain);
	_inner.viewport()->setAutoFillBackground(false);

	_inner.setContentsMargins(0, 0, 0, 0);
	_inner.document()->setDocumentMargin(0);

	setAttribute(Qt::WA_AcceptTouchEvents);
	_inner.viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
	_touchTimer.setSingleShot(true);
	connect(&_touchTimer, SIGNAL(timeout()), this, SLOT(onTouchTimer()));

	connect(_inner.document(), SIGNAL(contentsChange(int, int, int)), this, SLOT(onDocumentContentsChange(int, int, int)));
	connect(_inner.document(), SIGNAL(contentsChanged()), this, SLOT(onDocumentContentsChanged()));
	connect(&_inner, SIGNAL(undoAvailable(bool)), this, SLOT(onUndoAvailable(bool)));
	connect(&_inner, SIGNAL(redoAvailable(bool)), this, SLOT(onRedoAvailable(bool)));
	if (App::wnd()) connect(&_inner, SIGNAL(selectionChanged()), App::wnd(), SLOT(updateGlobalMenu()));
}