From 7ad237edc1cf8f41f5348b2f8435f2481d074daf Mon Sep 17 00:00:00 2001 From: James Grogan Date: Thu, 17 Nov 2022 08:39:49 +0000 Subject: [PATCH] Sample editor back working. --- apps/sample-gui/MediaTool.cpp | 21 +++++-------------- .../audio_editor/AudioEditorView.cpp | 2 +- src/ui_elements/widgets/Button.cpp | 10 +++++++++ src/ui_elements/widgets/Label.cpp | 12 ++++++++++- src/ui_elements/widgets/StackWidget.cpp | 2 ++ src/ui_elements/widgets/Widget.cpp | 19 ++++++++++------- src/ui_elements/widgets/Widget.h | 7 ++++++- src/visual_elements/AbstractVisualNode.h | 12 +++++++++++ src/visual_elements/RectangleNode.cpp | 9 -------- src/visual_elements/RectangleNode.h | 1 - 10 files changed, 59 insertions(+), 36 deletions(-) diff --git a/apps/sample-gui/MediaTool.cpp b/apps/sample-gui/MediaTool.cpp index 5127f62..55a9ff5 100644 --- a/apps/sample-gui/MediaTool.cpp +++ b/apps/sample-gui/MediaTool.cpp @@ -29,18 +29,22 @@ void MediaTool::initializeViews() auto textEditor = TextEditorView::Create(); auto path = mMainApplication->getCommandLineArgs()->getLaunchPath(); path /= "out.txt"; + textEditor->setName("TextEditor"); textEditor->GetController()->SetSavePath(path); textEditor->GetController()->SetLoadPath(path); textEditor->Initialize(); tabbedPanel->addPanel(std::move(textEditor), "Text Editor"); auto audioEditor = AudioEditorView::Create(); - tabbedPanel->addPanel(std::move(audioEditor), "Audio Editor"); + audioEditor->setName("audioEditor"); + tabbedPanel->addPanel(std::move(audioEditor), "audio Editor"); auto imageEditor = ImageEditorView::Create(); + imageEditor->setName("imageEditor"); tabbedPanel->addPanel(std::move(imageEditor), "Image Editor"); auto webClient = WebClientView::Create(); + webClient->setName("webClient"); tabbedPanel->addPanel(std::move(webClient), "Web Client"); auto topBar = TopBar::Create(); @@ -51,20 +55,5 @@ void MediaTool::initializeViews() horizontal_spacer->addWidgetWithScale(std::move(tabbedPanel), 20); horizontal_spacer->addWidgetWithScale(std::move(statusBar), 1); - /* - auto button = Button::Create(); - button->setLabel("Click!"); - button->setBounds(100, 200); - button->setBackgroundColor(Color(255, 0, 255, 1)); - - auto background_widget = Widget::Create(); - background_widget->setName("BackgroundWidget"); - background_widget->setBackgroundColor(Color(0, 255, 255, 1)); - - auto horizontal_spacer = HorizontalSpacer::Create(); - horizontal_spacer->addWidgetWithScale(std::move(button), 1); - horizontal_spacer->addWidgetWithScale(std::move(background_widget), 1); - */ - mainWindow->setWidget(std::move(horizontal_spacer)); } diff --git a/apps/sample-gui/audio_editor/AudioEditorView.cpp b/apps/sample-gui/audio_editor/AudioEditorView.cpp index b207d83..f7d6442 100644 --- a/apps/sample-gui/audio_editor/AudioEditorView.cpp +++ b/apps/sample-gui/audio_editor/AudioEditorView.cpp @@ -7,7 +7,7 @@ AudioEditorView::AudioEditorView() { auto label = Label::Create(); - label->setLabel("Audio Editor"); + label->setLabel("audio Editor"); label->setBackgroundColor(Color(200, 189, 160)); label->setMargin(1); addWidget(std::move(label)); diff --git a/src/ui_elements/widgets/Button.cpp b/src/ui_elements/widgets/Button.cpp index ac9bcb8..8db6b47 100644 --- a/src/ui_elements/widgets/Button.cpp +++ b/src/ui_elements/widgets/Button.cpp @@ -78,6 +78,11 @@ void Button::updateLabel(const PaintEvent* event) mRootNode->addChild(mTextNode.get()); } + if (mTransformDirty) + { + mTextNode->setLocation(middle); + } + if (mMaterialDirty) { mTextNode->setFillColor(mBackgroundColor); @@ -88,4 +93,9 @@ void Button::updateLabel(const PaintEvent* event) mTextNode->setContent(mLabel); mContentDirty = false; } + + if (mVisibilityDirty) + { + mTextNode->setIsVisible(mVisible); + } } diff --git a/src/ui_elements/widgets/Label.cpp b/src/ui_elements/widgets/Label.cpp index d0b566e..f29b99d 100644 --- a/src/ui_elements/widgets/Label.cpp +++ b/src/ui_elements/widgets/Label.cpp @@ -8,7 +8,7 @@ Label::Label() : Widget(), mLabel() { - + mName = "Label"; } std::unique_ptr