tdesktop/Telegram/SourceFiles/ui/flatbutton.h

109 lines
2.5 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
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 16:16:42 +03: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.
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
2016-02-08 13:56:18 +03:00
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
*/
#pragma once
#include "ui/button.h"
#include "ui/animation.h"
2015-12-08 15:33:37 +03:00
class FlatButton : public Button {
Q_OBJECT
public:
FlatButton(QWidget *parent, const QString &text, const style::flatButton &st);
2015-12-08 15:33:37 +03:00
void step_appearance(float64 ms, bool timer);
void paintEvent(QPaintEvent *e);
void setOpacity(float64 o);
2015-09-19 12:13:21 +03:00
float64 opacity() const;
void setText(const QString &text);
void setWidth(int32 w);
int32 textWidth() const;
~FlatButton() {
}
public slots:
void onStateChange(int oldState, ButtonStateChangeSource source);
private:
2015-06-17 00:01:43 +03:00
QString _text, _textForAutoSize;
int _width, _textWidth;
const style::flatButton &_st;
anim::fvalue a_over;
2015-12-08 15:33:37 +03:00
Animation _a_appearance;
float64 _opacity = 1.;
2015-12-08 15:33:37 +03:00
};
class LinkButton : public Button {
Q_OBJECT
public:
LinkButton(QWidget *parent, const QString &text, const style::linkButton &st = st::btnDefLink);
int naturalWidth() const override;
void setText(const QString &text);
~LinkButton();
protected:
void paintEvent(QPaintEvent *e) override;
public slots:
void onStateChange(int oldState, ButtonStateChangeSource source);
private:
QString _text;
int _textWidth = 0;
const style::linkButton &_st;
};
2015-10-03 13:09:09 +03:00
class BoxButton : public Button {
Q_OBJECT
public:
BoxButton(QWidget *parent, const QString &text, const style::RoundButton &st);
2015-10-03 13:09:09 +03:00
void setText(const QString &text);
void paintEvent(QPaintEvent *e) override;
2015-10-03 13:09:09 +03:00
2015-12-08 15:33:37 +03:00
void step_over(float64 ms, bool timer);
2015-10-03 13:09:09 +03:00
public slots:
void onStateChange(int oldState, ButtonStateChangeSource source);
private:
void resizeToText();
2015-10-03 13:09:09 +03:00
QString _text, _fullText;
int32 _textWidth;
const style::RoundButton &_st;
2015-10-03 13:09:09 +03:00
};