ENH:big_bed_image_popup automatic hide

jira: STUDIO-11327
Change-Id: I44a43d67ff909768f5e652a687883742ece14737
This commit is contained in:
zhou.xu 2025-04-03 14:36:54 +08:00 committed by lane.wei
parent f076d95d88
commit dbaec237c4
3 changed files with 50 additions and 7 deletions

View File

@ -43,6 +43,7 @@ ImageDPIFrame::ImageDPIFrame()
SetSizer(m_sizer_main);
Layout();
Fit();
init_timer();
}
ImageDPIFrame::~ImageDPIFrame() {
@ -65,16 +66,39 @@ void ImageDPIFrame::on_dpi_changed(const wxRect &suggested_rect)
//m_bitmap->Rescale();
}
void ImageDPIFrame::init_timer()
{
m_refresh_timer = new wxTimer();
m_refresh_timer->SetOwner(this);
Bind(wxEVT_TIMER, &ImageDPIFrame::on_timer, this);
}
void ImageDPIFrame::on_timer(wxTimerEvent &event)
{
if (!IsShown()) {//after 1s to show Frame
if (m_timer_count >= 50) {
Show();
Raise();
}
m_timer_count++;
}
}
void ImageDPIFrame::on_show() {
if (IsShown()) {
on_hide();
}
Show();
Raise();
if (m_refresh_timer) {
m_timer_count = 0;
m_refresh_timer->Start(ANIMATION_REFRESH_INTERVAL);
}
}
void ImageDPIFrame::on_hide()
{
if (m_refresh_timer) {
m_refresh_timer->Stop();
}
if (IsShown()) {
Hide();
if (wxGetApp().mainframe != nullptr) {

View File

@ -19,10 +19,16 @@ public:
void set_bitmap(const wxBitmap& bit_map);
int get_image_px() { return m_image_px; }
private:
void init_timer();
void on_timer(wxTimerEvent &event);
private:
wxStaticBitmap *m_bitmap = nullptr;
wxBoxSizer *m_sizer_main{nullptr};
int m_image_px;
wxTimer * m_refresh_timer{nullptr};
float m_timer_count = 0;
};
}} // namespace Slic3r::GUI
#endif // _STEP_MESH_DIALOG_H_

View File

@ -1604,6 +1604,9 @@ Sidebar::Sidebar(Plater *parent)
p->image_printer_bed = new wxStaticBitmap(p->panel_printer_bed, wxID_ANY, bitmap_bed.bmp(), wxDefaultPosition, wxDefaultSize, 0);
p->image_printer_bed->Bind(wxEVT_LEFT_DOWN, [this](auto &evt) {
p->image_printer_bed->Unbind(wxEVT_LEAVE_WINDOW, &Sidebar::on_leave_image_printer_bed, this);
if (p->big_bed_image_popup) {
p->big_bed_image_popup->on_hide();
}
p->combo_printer_bed->wxEvtHandler::ProcessEvent(evt);
});
@ -1621,6 +1624,11 @@ Sidebar::Sidebar(Plater *parent)
}
e.Skip(); // fix bug:Event spreads to sidebar
});
p->combo_printer_bed->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent &evt) {
if (p->big_bed_image_popup && p->big_bed_image_popup->IsShown()) {
p->big_bed_image_popup->on_hide();
}
});
p->image_printer_bed->Bind(wxEVT_ENTER_WINDOW, &Sidebar::on_enter_image_printer_bed, this);
wxBoxSizer *bed_type_vsizer = new wxBoxSizer(wxVERTICAL);
@ -1952,10 +1960,10 @@ Sidebar::Sidebar(Plater *parent)
Sidebar::~Sidebar() {}
void Sidebar::on_enter_image_printer_bed(wxMouseEvent &evt) {
p->image_printer_bed->Unbind(wxEVT_LEAVE_WINDOW, &Sidebar::on_leave_image_printer_bed, this);
auto pos = p->image_printer_bed->GetScreenPosition();
auto rect = p->image_printer_bed->GetRect();
wxPoint temp_pos(pos.x + rect.GetWidth(), pos.y);
p->image_printer_bed->Bind(wxEVT_LEAVE_WINDOW, &Sidebar::on_leave_image_printer_bed, this);
auto pos = p->panel_printer_bed->GetScreenPosition();
auto rect = p->panel_printer_bed->GetRect();
wxPoint temp_pos(pos.x + rect.GetWidth() + FromDIP(3), pos.y);
if (p->big_bed_image_popup == nullptr) {
p->big_bed_image_popup = new ImageDPIFrame();
auto image_path = get_cur_select_bed_image();
@ -1967,7 +1975,12 @@ void Sidebar::on_enter_image_printer_bed(wxMouseEvent &evt) {
}
void Sidebar::on_leave_image_printer_bed(wxMouseEvent &evt) {
p->big_bed_image_popup->on_hide();
auto pos_x = evt.GetX();
auto pos_y = evt.GetY();
auto rect = p->image_printer_bed->GetRect();
if (pos_x < 0 || pos_y < 0 || pos_x >= rect.GetWidth() && p->big_bed_image_popup) {
p->big_bed_image_popup->on_hide();
}
}
void Sidebar::on_change_color_mode(bool is_dark) {
const ModelObjectPtrs &mos = wxGetApp().model().objects;