mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-04 14:20:58 +00:00
* Save device url in all cases and load printer url after hot-reload finishes * Recreate web view from scratch as only URL fix seems not robust enough * Add the same robust browser recreation for WebViewDialog It should eliminate possible issue with blank Home and other pages in the same way as Printer page * Remove redundant fallback leftover * Fix webview reset state and replay Project info on page reload The first-show webview reset now runs only on Windows, reloads the last printer URL and resets the Project page's ready state. The Project tab replays its 3MF info whenever the page reloads, so it no longer goes blank after a theme switch or a slow first load. The Device tab no longer loads an extra time on first open, and the Home tab no longer navigates twice. NeedsRecreateOnShow() logs is_recreating_gui so one language switch shows whether the reset ever fires. * Build plugin pages on first show A language switch rebuilt every plugin page's browser while the main window was being recreated, which left plugin tabs blank on Windows. Plugin pages are now lazy pages, never prebuilt, and are removed left to right so removing pages never builds one only to destroy it. A plugin page's script now starts when its tab is first opened; messages posted before that are dropped. --------- Co-authored-by: SoftFever <softfeverever@gmail.com> Co-authored-by: Noisyfox <timemanager.rick@gmail.com> Co-authored-by: SoftFever <103989404+SoftFever@users.noreply.github.com>
91 lines
2.2 KiB
C++
91 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include <slic3r/GUI/LazyPage.hpp>
|
|
#include <slic3r/GUI/WebPanel.hpp>
|
|
#include <slic3r/plugin/PythonPluginInterface.hpp>
|
|
#include <slic3r/plugin/pluginTypes/pages/PagesPluginCapability.hpp>
|
|
|
|
#include <atomic>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <wx/bitmap.h>
|
|
#include <wx/string.h>
|
|
#include <wx/webview.h>
|
|
|
|
class Notebook;
|
|
|
|
namespace Slic3r {
|
|
|
|
class PluginPage : public GUI::WebPanel
|
|
{
|
|
public:
|
|
PluginPage(wxWindow* parent, std::shared_ptr<PagesPluginCapability> capability);
|
|
~PluginPage() override;
|
|
|
|
PluginPage() = delete;
|
|
|
|
void detach_capability();
|
|
void push_message(const std::string& message);
|
|
|
|
protected:
|
|
std::optional<std::string> page_html() override;
|
|
bool on_page_message(const std::string& kind, const nlohmann::json& data) override;
|
|
|
|
private:
|
|
void on_new_window(wxWebViewEvent& event);
|
|
|
|
std::shared_ptr<PagesPluginCapability> m_cap;
|
|
std::shared_ptr<std::atomic<PluginPage*>> m_lifetime;
|
|
};
|
|
|
|
class PluginPages
|
|
{
|
|
public:
|
|
PluginPages() = default;
|
|
~PluginPages();
|
|
|
|
PluginPages(const PluginPages&) = delete;
|
|
PluginPages& operator=(const PluginPages&) = delete;
|
|
|
|
void initialize(Notebook* parent);
|
|
void shutdown();
|
|
|
|
void on_cap_register(const PluginCapabilityId& id);
|
|
void on_cap_deregister(const PluginCapabilityId& id);
|
|
void on_plugin_register(const std::string& plugin_key);
|
|
void on_plugin_deregister(const std::string& plugin_key);
|
|
|
|
void set_visible_page_count(int count);
|
|
|
|
void relayout();
|
|
|
|
private:
|
|
std::shared_ptr<PagesPluginCapability> get_pages_cap(const PluginCapabilityId& id, bool is_enabled) const;
|
|
bool create_page(const PluginCapabilityId& id);
|
|
void remove_page(const PluginCapabilityId& id);
|
|
|
|
void show_overflow_menu();
|
|
static wxString page_tab_id(const PluginCapabilityId& id);
|
|
|
|
struct Page
|
|
{
|
|
GUI::LazyPage<PluginPage>* page{nullptr};
|
|
wxBitmap icon;
|
|
};
|
|
|
|
std::map<PluginCapabilityId, Page> m_pages;
|
|
std::vector<PluginCapabilityId> m_order;
|
|
Notebook* m_parent{nullptr};
|
|
|
|
int m_visible_page_count{0};
|
|
|
|
std::optional<PluginCapabilityId> m_swapped_in_id;
|
|
wxWindow* m_overflow_button{nullptr};
|
|
};
|
|
|
|
} // namespace Slic3r
|