Files
dragonpilot/selfdrive/ui/qt/widgets/toggle.h
Dean Lee 7222d0f20d Cleanup selfdrive/ includes (#20822)
* cleanup include path

* continue

* format includes

* fix testraw.cc

* remove include path from SConstruct

* regroup

* rebase master

* almost done

* apply review

* rename FileReader.xx to filereader.xx

* rename Unlogger.x->unlogger.x

* rename FrameReader.xx -> framereader.xx

* apply reviews

* ui.h

* continue

* fix framebuffer.cc build error:mv util.h up

* full path to msm_media_info

* fix qcom2 camerad

Co-authored-by: Comma Device <device@comma.ai>
2021-05-08 22:15:17 -07:00

43 lines
873 B
C++

#pragma once
#include <QtWidgets>
class Toggle : public QAbstractButton {
Q_OBJECT
Q_PROPERTY(int offset_circle READ offset_circle WRITE set_offset_circle CONSTANT)
public:
Toggle(QWidget* parent = nullptr);
void togglePosition();
bool on;
int animation_duration = 150;
int immediateOffset = 0;
int offset_circle() const {
return _x_circle;
}
void set_offset_circle(int o) {
_x_circle = o;
update();
}
bool getEnabled();
void setEnabled(bool value);
protected:
void paintEvent(QPaintEvent*) override;
void mouseReleaseEvent(QMouseEvent*) override;
void enterEvent(QEvent*) override;
private:
QColor circleColor;
QColor green;
bool enabled = true;
int _x_circle, _y_circle;
int _height, _radius;
int _height_rect, _y_rect;
QPropertyAnimation *_anim = nullptr;
signals:
void stateChanged(bool new_state);
};