2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2016-02-08 10:56:18 +00:00
|
|
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-04-07 18:05:28 +00:00
|
|
|
#include "ui/button.h"
|
|
|
|
#include "ui/flatcheckbox.h"
|
|
|
|
#include "ui/animation.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
class FlatButton : public Button {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
FlatButton(QWidget *parent, const QString &text, const style::flatButton &st);
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
void step_appearance(float64 ms, bool timer);
|
2014-05-30 08:53:19 +00:00
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
void setOpacity(float64 o);
|
2015-09-19 09:13:21 +00:00
|
|
|
float64 opacity() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void setText(const QString &text);
|
|
|
|
void setWidth(int32 w);
|
|
|
|
|
2014-12-22 23:11:37 +00:00
|
|
|
int32 textWidth() const;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
~FlatButton() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void onStateChange(int oldState, ButtonStateChangeSource source);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2015-06-16 21:01:43 +00:00
|
|
|
QString _text, _textForAutoSize;
|
2014-05-30 08:53:19 +00:00
|
|
|
int32 _textWidth;
|
|
|
|
|
|
|
|
style::flatButton _st;
|
|
|
|
|
2015-06-17 19:05:05 +00:00
|
|
|
anim::cvalue a_bg, a_text;
|
2015-12-08 12:33:37 +00:00
|
|
|
Animation _a_appearance;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
float64 _opacity;
|
2015-12-08 12:33:37 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class LinkButton : public Button {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
LinkButton(QWidget *parent, const QString &text, const style::linkButton &st = st::btnDefLink);
|
|
|
|
|
2016-08-22 17:16:21 +00:00
|
|
|
int naturalWidth() const override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void setText(const QString &text);
|
|
|
|
|
|
|
|
~LinkButton();
|
|
|
|
|
2016-08-22 17:16:21 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-08-22 17:16:21 +00:00
|
|
|
public slots:
|
2014-05-30 08:53:19 +00:00
|
|
|
void onStateChange(int oldState, ButtonStateChangeSource source);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString _text;
|
2016-08-28 19:16:23 +00:00
|
|
|
int _textWidth = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
style::linkButton _st;
|
2016-08-22 17:16:21 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
class IconedButton : public Button {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
IconedButton(QWidget *parent, const style::iconedButton &st, const QString &text = QString());
|
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
void step_appearance(float64 ms, bool timer);
|
2014-05-30 08:53:19 +00:00
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
|
|
|
|
void setOpacity(float64 o);
|
|
|
|
|
2014-09-29 02:47:30 +00:00
|
|
|
void setText(const QString &text);
|
2015-04-11 10:04:10 +00:00
|
|
|
QString getText() const;
|
2016-01-01 09:58:05 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void onStateChange(int oldState, ButtonStateChangeSource source);
|
|
|
|
|
2014-12-12 16:27:03 +00:00
|
|
|
protected:
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QString _text;
|
|
|
|
|
|
|
|
style::iconedButton _st;
|
2014-10-17 12:57:14 +00:00
|
|
|
int32 _width;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
anim::fvalue a_opacity;
|
|
|
|
anim::cvalue a_bg;
|
2015-12-08 12:33:37 +00:00
|
|
|
Animation _a_appearance;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
float64 _opacity;
|
|
|
|
};
|
2014-12-12 16:27:03 +00:00
|
|
|
|
|
|
|
class MaskedButton : public IconedButton {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
MaskedButton(QWidget *parent, const style::iconedButton &st, const QString &text = QString());
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
|
|
|
|
};
|
2015-10-03 10:09:09 +00:00
|
|
|
|
2016-01-01 09:58:05 +00:00
|
|
|
class EmojiButton : public IconedButton {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
EmojiButton(QWidget *parent, const style::iconedButton &st);
|
|
|
|
|
|
|
|
void paintEvent(QPaintEvent *e);
|
|
|
|
void setLoading(bool loading);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool _loading;
|
|
|
|
FloatAnimation a_loading;
|
|
|
|
Animation _a_loading;
|
|
|
|
|
|
|
|
void step_loading(uint64 ms, bool timer) {
|
|
|
|
if (timer) {
|
2016-05-12 16:05:20 +00:00
|
|
|
updateCallback();
|
2016-01-01 09:58:05 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-12 16:05:20 +00:00
|
|
|
void updateCallback() {
|
|
|
|
update();
|
|
|
|
}
|
2016-01-01 09:58:05 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-10-03 10:09:09 +00:00
|
|
|
class BoxButton : public Button {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-06-22 17:11:35 +00:00
|
|
|
BoxButton(QWidget *parent, const QString &text, const style::RoundButton &st);
|
2015-10-03 10:09:09 +00:00
|
|
|
|
2016-04-08 14:16:52 +00:00
|
|
|
void setText(const QString &text);
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
2015-10-03 10:09:09 +00:00
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
void step_over(float64 ms, bool timer);
|
2015-10-03 10:09:09 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void onStateChange(int oldState, ButtonStateChangeSource source);
|
|
|
|
|
|
|
|
private:
|
2016-04-08 14:16:52 +00:00
|
|
|
void resizeToText();
|
2015-10-03 10:09:09 +00:00
|
|
|
|
|
|
|
QString _text, _fullText;
|
|
|
|
int32 _textWidth;
|
|
|
|
|
2016-06-22 17:11:35 +00:00
|
|
|
const style::RoundButton &_st;
|
2015-10-03 10:09:09 +00:00
|
|
|
|
|
|
|
anim::fvalue a_textBgOverOpacity;
|
|
|
|
anim::cvalue a_textFg;
|
|
|
|
Animation _a_over;
|
2016-04-08 14:16:52 +00:00
|
|
|
|
2015-10-03 10:09:09 +00:00
|
|
|
};
|