[UI][UPD] Minor updates

- Tested version (Can build & run)
This commit is contained in:
Linloir 2022-12-16 17:54:22 +08:00
parent e5abe8c248
commit be3eda82f2
No known key found for this signature in database
GPG Key ID: 58EEB209A0F2C366
6 changed files with 39 additions and 20 deletions

View File

@ -108,6 +108,7 @@
<ClCompile Include="ebo.cpp" />
<ClCompile Include="editorpage.cpp" />
<ClCompile Include="framelesswindow.cpp" />
<ClCompile Include="lineeditwidget.cpp" />
<ClCompile Include="logger.cpp" />
<ClCompile Include="mesh.cpp" />
<ClCompile Include="model.cpp" />
@ -135,10 +136,11 @@
<QtMoc Include="sceneviewer.h" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="aboutpage.h" />
<QtMoc Include="aboutpage.h" />
<ClInclude Include="camera.h" />
<QtMoc Include="editorpage.h" />
<QtMoc Include="framelesswindow.h" />
<QtMoc Include="lineeditwidget.h" />
<ClInclude Include="logger.h" />
<ClInclude Include="mesh.h" />
<ClInclude Include="model.h" />

View File

@ -141,6 +141,9 @@
<ClCompile Include="aboutpage.cpp">
<Filter>Source Files\Qt Widgets\Pages\About Page</Filter>
</ClCompile>
<ClCompile Include="lineeditwidget.cpp">
<Filter>Source Files\Qt Widgets\GUI Components</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="camera.h">
@ -191,9 +194,6 @@
<ClInclude Include="scrolllist.h">
<Filter>Header Files\Qt Widgets\GUI Components</Filter>
</ClInclude>
<ClInclude Include="aboutpage.h">
<Filter>Header Files\Qt Widgets\Pages\About Page</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<QtMoc Include="mainwindow.h">
@ -220,6 +220,12 @@
<QtMoc Include="roundedcornerwidget.h">
<Filter>Header Files\Qt Widgets\GUI Components</Filter>
</QtMoc>
<QtMoc Include="aboutpage.h">
<Filter>Header Files\Qt Widgets\Pages\About Page</Filter>
</QtMoc>
<QtMoc Include="lineeditwidget.h">
<Filter>Header Files\Qt Widgets\GUI Components</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<None Include="fragmentshader.fs">

View File

@ -82,7 +82,7 @@ PushButton* EditorPage::getPageTextButton(QWidget* context) {
_textButtonWidget = new QWidget(_textButton);
_textButtonLayout = new QHBoxLayout(_textButtonWidget);
_textButtonLayout->setContentsMargins(0, 0, 0, 0);
_textButtonLayout->setSpacing(8);
_textButtonLayout->setSpacing(12);
_textButtonWidget->setLayout(_textButtonLayout);
// Generate text button contents

View File

@ -29,11 +29,9 @@ MainWindow::MainWindow(QWidget *parent)
}
if (previousPage != nullptr) {
previousPage->offStage();
return;
}
if (currentPage != nullptr) {
currentPage->onStage();
return;
}
});
_sideBar->setMouseTracking(true);
@ -45,8 +43,12 @@ MainWindow::MainWindow(QWidget *parent)
// Create editor page and connect to side bar
_editorPage = new EditorPage(_placeHolderWidget);
_editorPage->setMouseTracking(true);
_editorPage->show();
_sideBar->addPage(_editorPage);
// Create about page and connect to side bar
_aboutPage = new AboutPage(_placeHolderWidget);
_aboutPage->setMouseTracking(true);
_sideBar->addPage(_aboutPage);
}
MainWindow::~MainWindow() {
@ -63,6 +65,7 @@ void MainWindow::resizePages(QResizeEvent* event) {
// Resize the editor page
_editorPage->resize(size);
_aboutPage->resize(size);
}
void MainWindow::showEvent(QShowEvent* event) {
@ -71,6 +74,7 @@ void MainWindow::showEvent(QShowEvent* event) {
// Resize all the pages based on the placeholder widget
_editorPage->resize(_placeHolderWidget->size());
_aboutPage->resize(_placeHolderWidget->size());
}
bool MainWindow::eventFilter(QObject* object, QEvent* event) {

View File

@ -5,6 +5,7 @@
#include "framelesswindow.h"
#include "sidebar.h"
#include "editorpage.h"
#include "aboutpage.h"
class MainWindow : public FramelessWindow
{
@ -21,6 +22,7 @@ private:
// Side bar and corresponding pages
SideBar* _sideBar = nullptr;
EditorPage* _editorPage = nullptr;
AboutPage* _aboutPage = nullptr;
// Place holder widget for resizing pages
QWidget* _placeHolderWidget = nullptr;

View File

@ -13,26 +13,31 @@ PageWidget::PageWidget(QWidget* parent) : QWidget(parent) {
// Construct content widget
_contentWidget = new QWidget(this);
_stretchLayout->addWidget(_contentWidget);
_contentWidget->show();
// Add opacity effect to real content
_pageOpacityEffect = new QGraphicsOpacityEffect(_contentWidget);
_pageOpacityEffect->setOpacity(0);
_contentWidget->setGraphicsEffect(_pageOpacityEffect);
// Move offstage
move(_originPagePosition + QPoint(0, 150));
hide();
}
PageWidget::~PageWidget() {}
void PageWidget::onStage() {
// Move up and fade in
QParallelAnimationGroup* onStageAnimation = new QParallelAnimationGroup(_contentWidget);
QPropertyAnimation* moveAnimation = new QPropertyAnimation(_contentWidget, "pos");
QParallelAnimationGroup* onStageAnimation = new QParallelAnimationGroup(this);
QPropertyAnimation* moveAnimation = new QPropertyAnimation(this, "pos");
QPropertyAnimation* fadeInAnimation = new QPropertyAnimation(_pageOpacityEffect, "opacity");
moveAnimation->setDuration(300);
moveAnimation->setEasingCurve(QEasingCurve::OutCubic);
moveAnimation->setStartValue(_contentWidget->pos());
moveAnimation->setDuration(600);
moveAnimation->setEasingCurve(QEasingCurve::OutExpo);
moveAnimation->setStartValue(pos());
moveAnimation->setEndValue(_originPagePosition);
fadeInAnimation->setDuration(300);
fadeInAnimation->setEasingCurve(QEasingCurve::OutQuad);
fadeInAnimation->setDuration(500);
fadeInAnimation->setEasingCurve(QEasingCurve::InQuad);
fadeInAnimation->setStartValue(_pageOpacityEffect->opacity());
fadeInAnimation->setEndValue(0.999);
onStageAnimation->addAnimation(moveAnimation);
@ -40,20 +45,19 @@ void PageWidget::onStage() {
onStageAnimation->start(QAbstractAnimation::DeleteWhenStopped);
// Show page
_contentWidget->show();
show();
}
void PageWidget::offStage() {
// Move down and fade out
QParallelAnimationGroup* offStageAnimation = new QParallelAnimationGroup(_contentWidget);
QParallelAnimationGroup* offStageAnimation = new QParallelAnimationGroup(this);
//QPropertyAnimation* moveAnimation = new QPropertyAnimation(_contentWidget, "pos");
QPropertyAnimation* fadeOutAnimation = new QPropertyAnimation(_pageOpacityEffect, "opacity");
//moveAnimation->setDuration(300);
//moveAnimation->setEasingCurve(QEasingCurve::OutCubic);
//moveAnimation->setStartValue(_contentWidget->pos());
//moveAnimation->setEndValue(_originPagePosition - QPoint(0, 100));
fadeOutAnimation->setDuration(300);
fadeOutAnimation->setEasingCurve(QEasingCurve::OutQuad);
fadeOutAnimation->setDuration(200);
fadeOutAnimation->setStartValue(_pageOpacityEffect->opacity());
fadeOutAnimation->setEndValue(0);
//offStageAnimation->addAnimation(moveAnimation);
@ -62,6 +66,7 @@ void PageWidget::offStage() {
// Connect animation finished signal to hide page
connect(offStageAnimation, &QParallelAnimationGroup::finished, [=]() {
_contentWidget->hide();
move(_originPagePosition + QPoint(0, 150));
hide();
});
}