命名规范

This commit is contained in:
2026-07-29 12:30:40 +08:00
parent f5f1bf9cc7
commit 18edce4838
59 changed files with 1690 additions and 1795 deletions
+94 -105
View File
@@ -1,146 +1,135 @@
#ifndef BaseWidgetMenu_H
#define BaseWidgetMenu_H
#include "YSGraphic_Core/export.h"
#ifndef Base_Widget_Menu_H
#define Base_Widget_Menu_H
#include "Renderive/export.h"
#include <QMap>
#include <QPushButton>
#include <QWidget>
#include "Widget/base/Node.hpp"
#include "Widget/base/Roll_Object.h"
class QHBoxLayout;
class QVBoxLayout;
class AbstractTextButton;
class AbstractMenuButton;
class BaseWidgetMenu : public QWidget, public YSG::Node<BaseWidgetMenu> {
class Abstract_Text_Button;
class Abstract_Menu_Button;
class Base_Widget_Menu : public QWidget, public renderive::Node<Base_Widget_Menu> {
Q_OBJECT
public:
explicit BaseWidgetMenu(QWidget* parent);
QVBoxLayout *mMainLayout;
QHBoxLayout *mFirstLayout;
QHBoxLayout *mSecondLayout;
AbstractMenuButton *parentBtn{};
YSG::Roll_Object<AbstractMenuButton> mRollObject;
BaseWidgetMenu* createSubWidgetMenu(AbstractMenuButton * btn);
void esc(BaseWidgetMenu* menu);
explicit Base_Widget_Menu(QWidget* parent);
QVBoxLayout* main_layout;
QHBoxLayout* first_layout;
QHBoxLayout* second_layout;
Abstract_Menu_Button* parent_btn{};
renderive::Roll_Object<Abstract_Menu_Button> roll_object;
Base_Widget_Menu* create_sub_widget_menu(Abstract_Menu_Button* btn);
void esc(Base_Widget_Menu* menu);
void confirm();
void addMenuButtonOnLayout1(const QVector<AbstractMenuButton *>& buttons, int stretch);
void addMenuButtonOnLayout2(const QVector<AbstractMenuButton *>& buttons, int stretch);
void addMenuButtonOnLayout1(const QVector<AbstractMenuButton *>& buttons);
void addMenuButtonOnLayout2(const QVector<AbstractMenuButton *>& buttons);
signals:
void showThat();
void hideThat();
protected:
void paintEvent(QPaintEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void showEvent(QShowEvent *event) override;
void hideEvent(QHideEvent *event) override;
};
void add_menu_button_on_layout1(const QVector<Abstract_Menu_Button*>& buttons, int stretch);
void add_menu_button_on_layout2(const QVector<Abstract_Menu_Button*>& buttons, int stretch);
void add_menu_button_on_layout1(const QVector<Abstract_Menu_Button*>& buttons);
void add_menu_button_on_layout2(const QVector<Abstract_Menu_Button*>& buttons);
signals :
class AbstractMenuButton : public QPushButton {
void show_that();
void hide_that();
protected:
void paintEvent(QPaintEvent* event) override;
void keyPressEvent(QKeyEvent* event) override;
void showEvent(QShowEvent* event) override;
void hideEvent(QHideEvent* event) override;
};
class Abstract_Menu_Button : public QPushButton {
public:
AbstractMenuButton() = default;
BaseWidgetMenu *mParentMenu{};
BaseWidgetMenu *mOwnMenu{};
bool mClickHide = true;
void init(int fontSize){
Abstract_Menu_Button() = default;
Base_Widget_Menu* parent_menu{};
Base_Widget_Menu* own_menu{};
bool click_hide = true;
void init(int font_size) {
setFocusPolicy(Qt::NoFocus);
setFlat(true);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setCheckable(true);
setChecked(false);
QFont font;
font.setPixelSize(fontSize);
font.setPixelSize(font_size);
setFont(font);
}
void mousePressEvent(QMouseEvent *e) override {
mParentMenu->mRollObject.setCur(this);
mParentMenu->confirm();
void mousePressEvent(QMouseEvent* e) override {
parent_menu->roll_object.set_cur(this);
parent_menu->confirm();
}
void hideRoot();
void hide_root();
};
class MenuButton : public AbstractMenuButton{
class Menu_Button : public Abstract_Menu_Button {
public:
std::function<void(void)> mClick = nullptr;
MenuButton(const QString &text, int fontSize, const std::function<void(void)> &click){
mClick = click;
std::function<void(void)> click = nullptr;
Menu_Button(const QString& text, int font_size, const std::function<void(void)>& click) {
this->click = click;
setText(text);
init(fontSize);
connect(this, &AbstractMenuButton::clicked, [this](){
mClick();
init(font_size);
connect(this, &Abstract_Menu_Button::clicked, [this]() {
this->click();
});
}
};
class DoubleTextMenuButton : public AbstractMenuButton{
class Double_Text_Menu_Button : public Abstract_Menu_Button {
public:
std::function<void(bool)> mSwitchClick = nullptr;
QString mText1, mText2;
bool mIsText1 = false;
DoubleTextMenuButton(const QString &text1, const QString &text2, int fontSize, const std::function<void(bool)> &click){
mClickHide = false;
mText1 = text1;
mText2 = text2;
mSwitchClick = click;
std::function<void(bool)> switch_click = nullptr;
QString text1, text2;
bool is_text1 = false;
Double_Text_Menu_Button(const QString& text1, const QString& text2, int font_size, const std::function<void(bool)>& click) {
click_hide = false;
this->text1 = text1;
this->text2 = text2;
switch_click = click;
setText(text1);
init(fontSize);
connect(this, &AbstractMenuButton::clicked, [this](){
mIsText1 = !mIsText1;
mSwitchClick(mIsText1);
if(mIsText1){
setText(mText2);
} else {
setText(mText1);
init(font_size);
connect(this, &Abstract_Menu_Button::clicked, [this]() {
is_text1 = !is_text1;
switch_click(is_text1);
if (is_text1) {
setText(this->text2);
}
else {
setText(this->text1);
}
});
}
};
class ValueMenuButton : public AbstractMenuButton{
class Value_Menu_Button : public Abstract_Menu_Button {
public:
double mValue{};
QString mText;
std::function<void(ValueMenuButton*, bool add)> mValueChanged;
void setValue(double value){
mValue = value;
setText(mText.arg(mValue));
double value{};
QString text;
std::function<void(Value_Menu_Button*, bool add)> value_changed;
void setValue(double value) {
this->value = value;
setText(text.arg(this->value));
}
ValueMenuButton(const QString &text, int fontSize,
const std::function<void(ValueMenuButton*,bool)> &valueChanged, double firstValue) {
mText = text;
init(fontSize);
mValueChanged = valueChanged;
setValue(firstValue);
Value_Menu_Button(const QString& text, int font_size,
const std::function<void(Value_Menu_Button*, bool)>& valueChanged, double first_value) {
this->text = text;
init(font_size);
value_changed = valueChanged;
setValue(first_value);
}
};
// class ValueMenuButton : public AbstractMenuButton{
// class Value_Menu_Button : public Abstract_Menu_Button{
// public:
// std::function<void(ValueMenuButton*)> mHandleUp = nullptr;
// std::function<void(ValueMenuButton*)> mHandleDown = nullptr;
// QString mText;
// double mValue{};
// ValueMenuButton(const QString &text, int fontSize,
// const std::function<void(ValueMenuButton*)> &handleUp,
// const std::function<void(ValueMenuButton*)> &handleDown){
// mClickHide = false;
// mText = text;
// mHandleUp = handleUp;
// mHandleDown = handleDown;
// setValue(mValue);
// init(fontSize);
// std::function<void(Value_Menu_Button*)> handle_up = nullptr;
// std::function<void(Value_Menu_Button*)> handle_down = nullptr;
// QString text;
// double value{};
// Value_Menu_Button(const QString &text, int font_size,
// const std::function<void(Value_Menu_Button*)> &handleUp,
// const std::function<void(Value_Menu_Button*)> &handleDown){
// click_hide = false;
// text = text;
// handle_up = handleUp;
// handle_down = handleDown;
// setValue(value);
// init(font_size);
// }
// void setValue(double value){
// mValue = value;
// setText(mText.arg(mValue));
// value = value;
// setText(text.arg(value));
// }
// };
#endif