Files
2026-07-29 18:08:57 +08:00

64 lines
1.8 KiB
C++

#pragma once
#include <QColor>
#include <QDebug>
#include <QLinearGradient>
#include <vector>
#include <map>
#include <QPixmap>
#include <QString>
#include <QWidget>
enum Rect_Type { R11,
R12,
R13,
R21,
R22,
R23,
R31,
R32,
R33,
null,
Drag_R };
using change_size = std::function<void()>;
class Frame_Less_Widget : public QWidget {
public:
explicit Frame_Less_Widget(QWidget* parent = nullptr);
int top_margin;
int bottom_margin;
int right_margin;
int left_margin;
int space;
QRect r11, r12, r13, r21, r22, r23, r31, r32, r33;
int x1{}, x2{}, x3{}, y1{}, y2{}, y3{};
bool changing_size = false;
bool drag_moving = false;
Rect_Type cur_r = null;
int start_x{};
int start_y{};
int start_global_x{};
int start_global_y{};
int start_w{};
int start_h{};
int dx{}, dy{};
std::vector<Qt::CursorShape> shapes;
std::vector<change_size> change_sizes;
int radius;
QColor background_color = QColor(150, 150, 150, 130);
virtual int get_min_width();
virtual int get_min_height();
void set_pos();
void set_rs();
[[nodiscard]] Rect_Type get_rect_type(const QPoint& pos) const;
// window->showFullScreen();
// window->showNormal();
// window->showMinimized();
// window->showMaximized();
protected:
void paintEvent(QPaintEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
bool event(QEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void showEvent(QShowEvent* event) override;
};