Files
OrcaSlicer/src/slic3r/GUI/FilamentGroupPopup.hpp
T
HanifKoh a671bf605d Dismiss the Slice-Plate Popup on Every Path Into the Filament Grouping Dialog (#16359)
#16284 closed the Slice-plate hover popup only when the Slice button opened
the filament grouping dialog. The dialog also opens from the plate's filament
grouping icon, the preview legend, slicing notification links and the send
dialog, and a popup still shown on those paths keeps the mouse capture on
macOS and starves the modal dialog of clicks. Dismiss it in
FilamentMapDialog::ShowModal() instead, so every path is covered.

The popup could also stay up on its own on macOS: an enter event stopped its
close timer, and when the timer fired with the cursor inside it returned
without re-arming, so without a later leave event the popup never closed. On
macOS the timer now keeps running while the popup is shown and closes it once
the cursor is outside. The popup also stops and frees its timer when destroyed.
2026-10-11 15:48:49 +08:00

93 lines
2.5 KiB
C++

#ifndef FILAMENT_GROUP_HOVER_HPP
#define FILAMENT_GROUP_HOVER_HPP
#include <vector>
#include <wx/bitmap.h>
#include <wx/bmpbuttn.h>
#include <wx/event.h>
#include <wx/sizer.h>
#include <wx/timer.h>
#include "libslic3r/PrintConfig.hpp"
#include "Widgets/PopupWindow.hpp"
#include "Widgets/Label.hpp"
#include "Widgets/SwitchButton.hpp"
#include "Widgets/StaticBox.hpp"
namespace Slic3r { namespace GUI {
class PartPlate;
class Plater;
bool play_dual_extruder_slice_video();
bool play_dual_extruder_print_tpu_video();
bool open_filament_group_wiki();
class FilamentGroupPopup : public PopupWindow
{
public:
FilamentGroupPopup(wxWindow *parent);
~FilamentGroupPopup() override;
void tryPopup(Plater* plater,PartPlate* plate, bool slice_all);
void tryClose();
void Dismiss() override;
FilamentMapMode GetSelectedMode() const { return m_mode; }
private:
void OnPaint(wxPaintEvent&event);
void StartTimer();
void ResetTimer();
void OnRadioBtn(int idx);
void OnLeaveWindow(wxMouseEvent &);
void OnEnterWindow(wxMouseEvent &);
void OnTimer(wxTimerEvent &event);
void CreateBmps();
void Init();
void UpdateButtonStatus(int hover_idx = -1);
void DrawRoundedCorner(int radius);
void MakeSmartFilamentSection(wxSizer *top_sizer, int horizontal_margin, int vertical_padding);
void UpdateSmartFilamentSection();
void OnSmartFilamentToggle(wxCommandEvent &event);
private:
FilamentMapMode GetFilamentMapMode() const;
void SetFilamentMapMode(const FilamentMapMode mode);
private:
enum ButtonType { btForFlush, btForMatch, btManual, btCount };
const std::vector<FilamentMapMode> mode_list = {fmmAutoForFlush, fmmAutoForMatch, fmmManual};
bool m_connected{ false };
bool m_active{ false };
bool m_sync_plate{ false };
bool m_slice_all{ false };
FilamentMapMode m_mode;
wxTimer *m_timer;
std::vector<wxBitmapButton*> radio_btns;
std::vector<Label *> button_labels;
std::vector<Label *> button_desps;
std::vector<Label *> detail_infos;
wxBitmap checked_bmp;
wxBitmap unchecked_bmp;
wxBitmap disabled_bmp;
wxBitmap checked_hover_bmp;
wxBitmap unchecked_hover_bmp;
wxBitmap global_tag_bmp;
StaticBox *m_smart_filament_panel{nullptr};
wxSizerItem *m_smart_filament_spacer{nullptr};
SwitchButton *m_smart_filament_switch{nullptr};
PartPlate* partplate_ref{ nullptr };
Plater* plater_ref{ nullptr };
};
}} // namespace Slic3r::GUI
#endif