2016-10-20 11:34:48 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-10-20 11:34:48 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-10-20 11:34:48 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "styles/style_widgets.h"
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
2016-11-21 16:24:23 +00:00
|
|
|
class RoundCheckbox {
|
2016-10-20 11:34:48 +00:00
|
|
|
public:
|
2017-02-26 11:32:13 +00:00
|
|
|
RoundCheckbox(const style::RoundCheckbox &st, base::lambda<void()> updateCallback);
|
2016-10-20 11:34:48 +00:00
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
void paint(Painter &p, TimeMs ms, int x, int y, int outerWidth, float64 masterScale = 1.);
|
2016-10-20 11:34:48 +00:00
|
|
|
|
2016-11-21 16:24:23 +00:00
|
|
|
void setDisplayInactive(bool displayInactive);
|
2016-10-20 13:41:46 +00:00
|
|
|
bool checked() const {
|
|
|
|
return _checked;
|
2016-10-20 11:34:48 +00:00
|
|
|
}
|
2016-10-20 13:41:46 +00:00
|
|
|
enum class SetStyle {
|
|
|
|
Animated,
|
|
|
|
Fast,
|
|
|
|
};
|
2016-11-21 16:24:23 +00:00
|
|
|
void setChecked(bool newChecked, SetStyle speed = SetStyle::Animated);
|
2016-10-20 11:34:48 +00:00
|
|
|
|
2016-12-20 13:03:51 +00:00
|
|
|
void invalidateCache();
|
|
|
|
|
2016-10-20 11:34:48 +00:00
|
|
|
private:
|
2016-11-21 16:24:23 +00:00
|
|
|
void prepareInactiveCache();
|
2016-10-20 11:34:48 +00:00
|
|
|
|
2016-11-21 16:24:23 +00:00
|
|
|
const style::RoundCheckbox &_st;
|
2017-02-26 11:32:13 +00:00
|
|
|
base::lambda<void()> _updateCallback;
|
2016-10-20 11:34:48 +00:00
|
|
|
|
2016-10-20 13:41:46 +00:00
|
|
|
bool _checked = false;
|
2017-11-27 18:40:39 +00:00
|
|
|
Animation _checkedProgress;
|
2016-10-20 11:34:48 +00:00
|
|
|
|
2016-11-21 16:24:23 +00:00
|
|
|
bool _displayInactive = false;
|
|
|
|
QPixmap _inactiveCacheBg, _inactiveCacheFg;
|
|
|
|
|
2016-10-20 11:34:48 +00:00
|
|
|
};
|
|
|
|
|
2016-11-21 16:24:23 +00:00
|
|
|
class RoundImageCheckbox {
|
|
|
|
public:
|
|
|
|
using PaintRoundImage = base::lambda<void(Painter &p, int x, int y, int outerWidth, int size)>;
|
2017-02-26 11:32:13 +00:00
|
|
|
RoundImageCheckbox(const style::RoundImageCheckbox &st, base::lambda<void()> updateCallback, PaintRoundImage &&paintRoundImage);
|
2016-11-21 16:24:23 +00:00
|
|
|
|
2016-12-01 19:20:33 +00:00
|
|
|
void paint(Painter &p, TimeMs ms, int x, int y, int outerWidth);
|
2016-11-21 16:24:23 +00:00
|
|
|
float64 checkedAnimationRatio() const;
|
|
|
|
|
|
|
|
bool checked() const {
|
|
|
|
return _check.checked();
|
|
|
|
}
|
|
|
|
using SetStyle = RoundCheckbox::SetStyle;
|
|
|
|
void setChecked(bool newChecked, SetStyle speed = SetStyle::Animated);
|
|
|
|
|
2016-12-20 13:03:51 +00:00
|
|
|
void invalidateCache() {
|
|
|
|
_check.invalidateCache();
|
|
|
|
}
|
|
|
|
|
2016-11-21 16:24:23 +00:00
|
|
|
private:
|
|
|
|
void prepareWideCache();
|
|
|
|
|
|
|
|
const style::RoundImageCheckbox &_st;
|
2017-02-26 11:32:13 +00:00
|
|
|
base::lambda<void()> _updateCallback;
|
2016-11-21 16:24:23 +00:00
|
|
|
PaintRoundImage _paintRoundImage;
|
|
|
|
|
|
|
|
QPixmap _wideCache;
|
2016-12-07 13:32:25 +00:00
|
|
|
Animation _selection;
|
2016-11-21 16:24:23 +00:00
|
|
|
|
|
|
|
RoundCheckbox _check;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-10-20 11:34:48 +00:00
|
|
|
} // namespace Ui
|