diff --git a/Base/res/graphics/wizard-banner-simple.png b/Base/res/graphics/wizard-banner-simple.png new file mode 100644 index 0000000000..e24465cbd7 Binary files /dev/null and b/Base/res/graphics/wizard-banner-simple.png differ diff --git a/Userland/Demos/WidgetGallery/DemoWizardPage1.gml b/Userland/Demos/WidgetGallery/DemoWizardPage1.gml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Userland/Demos/WidgetGallery/DemoWizardPage2.gml b/Userland/Demos/WidgetGallery/DemoWizardPage2.gml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Userland/Libraries/LibGUI/CMakeLists.txt b/Userland/Libraries/LibGUI/CMakeLists.txt index 4bbaa8ff28..766cb73694 100644 --- a/Userland/Libraries/LibGUI/CMakeLists.txt +++ b/Userland/Libraries/LibGUI/CMakeLists.txt @@ -97,6 +97,10 @@ set(SOURCES Widget.cpp Window.cpp WindowServerConnection.cpp + Wizards/WizardDialog.cpp + Wizards/AbstractWizardPage.cpp + Wizards/CoverWizardPage.cpp + Wizards/WizardPage.cpp ) set(GENERATED_SOURCES diff --git a/Userland/Libraries/LibGUI/Wizards/AbstractWizardPage.cpp b/Userland/Libraries/LibGUI/Wizards/AbstractWizardPage.cpp new file mode 100644 index 0000000000..0b5389315d --- /dev/null +++ b/Userland/Libraries/LibGUI/Wizards/AbstractWizardPage.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021, Nick Vella + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +namespace GUI { + +AbstractWizardPage::AbstractWizardPage() +{ +} + +AbstractWizardPage::~AbstractWizardPage() +{ +} + +RefPtr AbstractWizardPage::next_page() +{ + if (on_next_page) + return on_next_page(); + return nullptr; +} + +bool AbstractWizardPage::can_go_next() +{ + return !!on_next_page; +} + +void AbstractWizardPage::page_enter() +{ + if (on_page_enter) + return on_page_enter(); +} + +void AbstractWizardPage::page_leave() +{ + if (on_page_leave) + return on_page_leave(); +} + +} diff --git a/Userland/Libraries/LibGUI/Wizards/AbstractWizardPage.h b/Userland/Libraries/LibGUI/Wizards/AbstractWizardPage.h new file mode 100644 index 0000000000..4cd6b7f073 --- /dev/null +++ b/Userland/Libraries/LibGUI/Wizards/AbstractWizardPage.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021, Nick Vella + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include +#include + +namespace GUI { + +class AbstractWizardPage : public Widget { + C_OBJECT_ABSTRACT(AbstractWizardPage); + +public: + virtual ~AbstractWizardPage() override; + + Function()> on_next_page; + virtual RefPtr next_page(); + virtual bool can_go_next(); + + Function on_page_enter; + virtual void page_enter(); + + Function on_page_leave; + virtual void page_leave(); + + bool is_final_page() const { return m_is_final_page; } + void set_is_final_page(bool val) { m_is_final_page = val; } + +protected: + AbstractWizardPage(); + +private: + bool m_is_final_page { false }; +}; + +} diff --git a/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.cpp b/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.cpp new file mode 100644 index 0000000000..ecdac2e7f4 --- /dev/null +++ b/Userland/Libraries/LibGUI/Wizards/CoverWizardPage.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2021, Nick Vella + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include + +namespace GUI { + +CoverWizardPage::CoverWizardPage() + : AbstractWizardPage() +{ + set_fill_with_background_color(true); + set_background_role(Gfx::ColorRole::Base); + set_layout(); + m_banner_image_widget = add(); + m_banner_image_widget->set_fixed_size(160, 315); + m_banner_image_widget->load_from_file("/res/graphics/wizard-banner-simple.png"); + + m_content_widget = add(); + m_content_widget->set_layout(); + m_content_widget->layout()->set_margins({ 20, 20, 20, 20 }); + + m_header_label = m_content_widget->add