自定义内存分配池
This commit is contained in:
@@ -18,8 +18,8 @@ public:
|
||||
Background background;
|
||||
Content content;
|
||||
Button() {
|
||||
paintAbles.append(&background);
|
||||
paintAbles.append(&content);
|
||||
paintAbles.push_back(&background);
|
||||
paintAbles.push_back(&content);
|
||||
}
|
||||
[[nodiscard]] QSize sizeHint() const override {
|
||||
auto ret = content.sizeHint();
|
||||
@@ -34,7 +34,7 @@ inline Button* create_icon(const QString& path, const QColor& background, const
|
||||
auto ret = new Button();
|
||||
ret->content.set_icon(path, QColor(Qt::color0));
|
||||
ret->background.set_color(background);
|
||||
ret->background.mouse_handlers.append(f);
|
||||
ret->background.mouse_handlers.push_back(f);
|
||||
return ret;
|
||||
};
|
||||
struct Switch_Button : Base {
|
||||
@@ -44,9 +44,9 @@ public:
|
||||
Content content1;
|
||||
Content content2;
|
||||
Switch_Button() {
|
||||
paintAbles.append(&background);
|
||||
paintAbles.append(&content1);
|
||||
paintAbles.append(&content2);
|
||||
paintAbles.push_back(&background);
|
||||
paintAbles.push_back(&content1);
|
||||
paintAbles.push_back(&content2);
|
||||
content1.show = true;
|
||||
content2.show = false;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ inline Switch_Button* create_switch_icon(const QColor& background, const QString
|
||||
ret->content1.set_icon(path, QColor(Qt::color0));
|
||||
ret->content2.set_icon(path2, QColor(Qt::color0));
|
||||
ret->background.set_color(background);
|
||||
ret->background.mouse_handlers.append([ret, f, f2](QEvent::Type t, QMouseEvent* e) {
|
||||
ret->background.mouse_handlers.push_back([ret, f, f2](QEvent::Type t, QMouseEvent* e) {
|
||||
if (t == QEvent::MouseButtonPress) {
|
||||
if (ret->content1.show) {
|
||||
f(t, e);
|
||||
|
||||
Reference in New Issue
Block a user