diff --git a/Editor/Include/Editor/Widget/Editor.h b/Editor/Include/Editor/Widget/Editor.h new file mode 100644 index 00000000..54281539 --- /dev/null +++ b/Editor/Include/Editor/Widget/Editor.h @@ -0,0 +1,16 @@ +// +// Created by Kindem on 2025/3/22. +// + +#pragma once + +#include + +namespace Editor { + class Editor final : public QWidget { + Q_OBJECT + + public: + Editor(); + }; +} diff --git a/Editor/Qml/EProjectHub.qml b/Editor/Qml/EProjectHub.qml index 1a978211..3592eb89 100644 --- a/Editor/Qml/EProjectHub.qml +++ b/Editor/Qml/EProjectHub.qml @@ -1,5 +1,56 @@ import QtQuick +import QtQuick.Layouts Rectangle { - color: ETheme.bgColor + RowLayout { + anchors.fill: parent + spacing: 0 + + ColumnLayout { + Layout.preferredWidth: 5 + Layout.fillWidth: true + Layout.fillHeight: true + + Rectangle { + Layout.fillWidth: true + Layout.fillHeight: true + color: ETheme.primaryBgColor + + ColumnLayout { + id: menuCol + anchors.fill: parent + anchors.margins: 20 + + RowLayout { + Layout.preferredHeight: 1 + Layout.fillHeight: true + Layout.fillWidth: true + + Image { + source: Qt.url('Resource/Image/Logo.png') + sourceSize.width: menuCol.width + } + } + + RowLayout { + Layout.preferredHeight: 7 + Layout.fillHeight: true + Layout.fillWidth: true + } + } + } + } + + ColumnLayout { + Layout.preferredWidth: 14 + Layout.fillWidth: true + Layout.fillHeight: true + + Rectangle { + Layout.fillWidth: true + Layout.fillHeight: true + color: ETheme.bgColor + } + } + } } diff --git a/Editor/Qml/ESwitch.qml b/Editor/Qml/ESwitch.qml index b40b65a3..1ee5a285 100644 --- a/Editor/Qml/ESwitch.qml +++ b/Editor/Qml/ESwitch.qml @@ -2,9 +2,7 @@ import QtQuick import QtQuick.Controls import QtQuick.Controls.Basic - Item { - enum Size { Small, Middle, @@ -13,7 +11,7 @@ Item { enum Filler { None, - Withchar + Text } property string text: '' @@ -38,33 +36,32 @@ Item { indicator: Rectangle { function getBackgroundColor(checked, disabled) { if (disabled) { - return checked ? ETheme.disabledCheckedColor : ETheme.disabledColor; + return checked ? ETheme.primaryDisabledColor : ETheme.disabledColor; } return checked ? ETheme.primaryColor : ETheme.secondaryBgColor; } - implicitWidth: 40 + 2 * (root.size - 1) + implicitWidth: 45 + 2 * (root.size - 1) implicitHeight: 24 + 2 * (root.size - 1) x: switchWidget.leftPadding anchors.verticalCenter: parent.verticalCenter - radius: width / 2 + radius: width / 4 color: getBackgroundColor(switchWidget.checked, root.disabled) Rectangle { function getX(check, down) { if (check && down) - return parent.width - 2 * radius - 8; + return parent.width - 4 * radius - 8; else - return check ? parent.width - width - 2 : 2 - + return check ? parent.width - width - 4 : 4 } id: handle x: getX(switchWidget.checked, switchWidget.down) anchors.verticalCenter: parent.verticalCenter - radius: switchWidget.checked ? 9 + root.size : 7 + root.size + radius: 7 + root.size height: 2 * radius - width: switchWidget.down ? 2 * radius + 6 : 2 * radius + width: 2 * radius color: ETheme.fontColor; Behavior on width { @@ -75,17 +72,16 @@ Item { Behavior on x { NumberAnimation { duration: 100 - easing.type: easing.InOutCubic } } } Text { - function getChar(filler, checked, down) { - if (filler == ESwitch.Filler.None || down) { + function getText(filler, checked, down) { + if (filler === ESwitch.Filler.None || down) { return ''; } else { - return checked ? "开" : "关"; + return checked ? "Y" : "N"; } } @@ -95,11 +91,10 @@ Item { color: ETheme.fontColor x: switchWidget.checked ? (parent.width - handle.radius * 2 - font.pixelSize - 2) / 2 : (parent.width + handle.radius * 2 - font.pixelSize + 2) / 2; anchors.verticalCenter: parent.verticalCenter - text: getChar(root.filler, switchWidget.checked, switchWidget.down) + text: getText(root.filler, switchWidget.checked, switchWidget.down) Behavior on x { NumberAnimation { duration: 100 - easing.type: easing.OutExpo } } } diff --git a/Editor/Qml/ETheme.qml b/Editor/Qml/ETheme.qml index bf845b3a..dbda69a7 100644 --- a/Editor/Qml/ETheme.qml +++ b/Editor/Qml/ETheme.qml @@ -4,9 +4,11 @@ import QtQuick QtObject { property color bgColor: Qt.color('#212121') + property color primaryBgColor: Qt.color('#2a2a2a') property color primaryColor: Qt.color('#e74c3c') property color primaryHoverColor: Qt.color('#ce4d40') property color primaryFocusColor: Qt.color('#c0392b') + property color primaryDisabledColor: Qt.color('#4b4a49') property color secondaryColor: Qt.color('#d58845') property color secondaryHoverColor: Qt.color('#d58845') property color secondaryFocusColor: Qt.color('#9b6a40') @@ -14,10 +16,9 @@ QtObject { property color fontColor: Qt.color('#ecf0f1') property color linkFontColor: Qt.color('#91b9c4') property color secondaryBgColor: Qt.color('#8e8e8e') - property color disabledCheckedColor: Qt.color('#c9a9a6') - property FontLoader normalFont: FontLoader { source: Qt.url('Resource/Font/MiSans-Normal.ttf') } - property FontLoader boldFont: FontLoader { source: Qt.url('Resource/Font/MiSans-Bold.ttf') } + property FontLoader normalFont: FontLoader { source: Qt.url('Resource/Font/MiSans-Medium.ttf') } + property FontLoader boldFont: FontLoader { source: Qt.url('Resource/Font/MiSans-Semibold.ttf') } property int tiele1FontSize: 20 property int title2FontSize: 18 property int title3FontSize: 16 diff --git a/Editor/Qml/EWidgetSamples.qml b/Editor/Qml/EWidgetSamples.qml index 6928c69f..e2f6c427 100644 --- a/Editor/Qml/EWidgetSamples.qml +++ b/Editor/Qml/EWidgetSamples.qml @@ -281,6 +281,7 @@ Rectangle { style: EText.Style.Title1 } } + RowLayout { ESwitch { text: 'Small Switch' @@ -295,6 +296,7 @@ Rectangle { size: ESwitch.Size.Large } } + RowLayout { ESwitch { text: 'Disabled Checked' @@ -308,7 +310,7 @@ Rectangle { } ESwitch { text: 'Filled Symbol' - filler: ESwitch.Filler.Withchar + filler: ESwitch.Filler.Text } } } diff --git a/Editor/Qml/Resource/Font/MiSans-Demibold.ttf b/Editor/Qml/Resource/Font/MiSans-Demibold.ttf new file mode 100644 index 00000000..b9512931 Binary files /dev/null and b/Editor/Qml/Resource/Font/MiSans-Demibold.ttf differ diff --git a/Editor/Qml/Resource/Font/MiSans-ExtraLight.ttf b/Editor/Qml/Resource/Font/MiSans-ExtraLight.ttf new file mode 100644 index 00000000..a55e5d15 Binary files /dev/null and b/Editor/Qml/Resource/Font/MiSans-ExtraLight.ttf differ diff --git a/Editor/Qml/Resource/Font/MiSans-Heavy.ttf b/Editor/Qml/Resource/Font/MiSans-Heavy.ttf new file mode 100644 index 00000000..16d5c2b1 Binary files /dev/null and b/Editor/Qml/Resource/Font/MiSans-Heavy.ttf differ diff --git a/Editor/Qml/Resource/Font/MiSans-Light.ttf b/Editor/Qml/Resource/Font/MiSans-Light.ttf new file mode 100644 index 00000000..784bdb12 Binary files /dev/null and b/Editor/Qml/Resource/Font/MiSans-Light.ttf differ diff --git a/Editor/Qml/Resource/Font/MiSans-Medium.ttf b/Editor/Qml/Resource/Font/MiSans-Medium.ttf new file mode 100644 index 00000000..7bc0d9cb Binary files /dev/null and b/Editor/Qml/Resource/Font/MiSans-Medium.ttf differ diff --git a/Editor/Qml/Resource/Font/MiSans-Regular.ttf b/Editor/Qml/Resource/Font/MiSans-Regular.ttf new file mode 100644 index 00000000..a408ed81 Binary files /dev/null and b/Editor/Qml/Resource/Font/MiSans-Regular.ttf differ diff --git a/Editor/Qml/Resource/Font/MiSans-Semibold.ttf b/Editor/Qml/Resource/Font/MiSans-Semibold.ttf new file mode 100644 index 00000000..013e68dd Binary files /dev/null and b/Editor/Qml/Resource/Font/MiSans-Semibold.ttf differ diff --git a/Editor/Qml/Resource/Font/MiSans-Thin.ttf b/Editor/Qml/Resource/Font/MiSans-Thin.ttf new file mode 100644 index 00000000..17dd2a50 Binary files /dev/null and b/Editor/Qml/Resource/Font/MiSans-Thin.ttf differ diff --git a/Editor/Qml/Resource/Image/Logo.png b/Editor/Qml/Resource/Image/Logo.png new file mode 100644 index 00000000..47990c8e Binary files /dev/null and b/Editor/Qml/Resource/Image/Logo.png differ diff --git a/Editor/Src/Main.cpp b/Editor/Src/Main.cpp index 1629a2eb..86efc078 100644 --- a/Editor/Src/Main.cpp +++ b/Editor/Src/Main.cpp @@ -6,17 +6,18 @@ #include #include +#include #include #include #if BUILD_CONFIG_DEBUG #include -static Core::CmdlineArgValue caGraphicsWindowSample( +static Core::CmdlineArgValue caGraphicsSample( "graphicsSample", "-graphicsSample", false, "Whether to run graphics sample instead of editor"); -static Core::CmdlineArgValue caRunSample( +static Core::CmdlineArgValue caWidgetSamples( "widgetSamples", "-widgetSamples", false, "Whether to run widget samples instead of editor"); #endif @@ -29,9 +30,46 @@ static Core::CmdlineArgValue caProjectRoot( "projectRoot", "-project", "", "project root path"); -static void InitializePreQtApp(int argc, char** argv) +enum class EditorApplicationModel : uint8_t { +#if BUILD_CONFIG_DEBUG + graphicsSample, + widgetSamples, +#endif + projectHub, + editor, + max +}; + +static EditorApplicationModel GetAppModel() { - Core::Cli::Get().Parse(argc, argv); +#if BUILD_CONFIG_DEBUG + if (caGraphicsSample.GetValue()) { + return EditorApplicationModel::graphicsSample; + } + if (caWidgetSamples.GetValue()) { + return EditorApplicationModel::widgetSamples; + } +#endif + if (caProjectRoot.GetValue().empty()) { + return EditorApplicationModel::projectHub; + } + return EditorApplicationModel::editor; +} + +static bool NeedInitCore(EditorApplicationModel inModel) +{ + bool result = inModel == EditorApplicationModel::editor; +#if BUILD_CONFIG_DEBUG + result = result || inModel == EditorApplicationModel::graphicsSample; +#endif + return result; +} + +static void InitializePreQtApp(EditorApplicationModel inModel) +{ + if (!NeedInitCore(inModel)) { + return; + } Runtime::EngineInitParams params {}; params.logToFile = true; @@ -46,35 +84,46 @@ static void InitializePostQtApp() Editor::QmlEngine::Get().Start(); } -static void Cleanup() +static void Cleanup(EditorApplicationModel inModel) { Editor::QmlEngine::Get().Stop(); + + if (!NeedInitCore(inModel)) { + return; + } Runtime::EngineHolder::Unload(); } +static Common::UniquePtr CreateMainWidget(EditorApplicationModel inModel) +{ +#if BUILD_CONFIG_DEBUG + if (inModel == EditorApplicationModel::graphicsSample) { + return new Editor::GraphicsSampleWidget(); + } + if (inModel == EditorApplicationModel::widgetSamples) { + return new Editor::WidgetSamples(); + } +#endif + if (inModel == EditorApplicationModel::projectHub) { // NOLINT + return new Editor::ProjectHub(); + } + return new Editor::Editor(); +} + int main(int argc, char* argv[]) { - InitializePreQtApp(argc, argv); + Core::Cli::Get().Parse(argc, argv); + const auto appModel = GetAppModel(); + + InitializePreQtApp(appModel); QApplication qtApplication(argc, argv); InitializePostQtApp(); - Common::UniquePtr mainWidget; -#if BUILD_CONFIG_DEBUG - if (caGraphicsWindowSample.GetValue()) { - mainWidget = new Editor::GraphicsSampleWidget(); - } else if (caRunSample.GetValue()) { - mainWidget = new Editor::WidgetSamples(); - } else -#endif - if (caProjectRoot.GetValue().empty()) { // NOLINT - mainWidget = new Editor::ProjectHub(); - } else { - // TODO editor main - } + Common::UniquePtr mainWidget = CreateMainWidget(appModel); mainWidget->show(); const int execRes = QApplication::exec(); - mainWidget = nullptr; - Cleanup(); + mainWidget.Reset(); + Cleanup(appModel); return execRes; } diff --git a/Editor/Src/Widget/Editor.cpp b/Editor/Src/Widget/Editor.cpp new file mode 100644 index 00000000..6ffb29d2 --- /dev/null +++ b/Editor/Src/Widget/Editor.cpp @@ -0,0 +1,10 @@ +// +// Created by Kindem on 2025/3/22. +// + +#include +#include + +namespace Editor { + Editor::Editor() = default; +} // namespace Editor diff --git a/Editor/Src/Widget/ProjectHub.cpp b/Editor/Src/Widget/ProjectHub.cpp index 1fa2c85a..a80b291d 100644 --- a/Editor/Src/Widget/ProjectHub.cpp +++ b/Editor/Src/Widget/ProjectHub.cpp @@ -10,6 +10,6 @@ namespace Editor { : QmlWidget("EProjectHub.qml") { setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint); - setFixedSize(1024, 768); + setFixedSize(800, 600); } }