ENH:big_bed_image_popup automatic hide
jira: STUDIO-11327 Change-Id: I44a43d67ff909768f5e652a687883742ece14737
This commit is contained in:
parent
f076d95d88
commit
dbaec237c4
|
@ -43,6 +43,7 @@ ImageDPIFrame::ImageDPIFrame()
|
||||||
SetSizer(m_sizer_main);
|
SetSizer(m_sizer_main);
|
||||||
Layout();
|
Layout();
|
||||||
Fit();
|
Fit();
|
||||||
|
init_timer();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageDPIFrame::~ImageDPIFrame() {
|
ImageDPIFrame::~ImageDPIFrame() {
|
||||||
|
@ -65,16 +66,39 @@ void ImageDPIFrame::on_dpi_changed(const wxRect &suggested_rect)
|
||||||
//m_bitmap->Rescale();
|
//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() {
|
void ImageDPIFrame::on_show() {
|
||||||
if (IsShown()) {
|
if (IsShown()) {
|
||||||
on_hide();
|
on_hide();
|
||||||
}
|
}
|
||||||
Show();
|
if (m_refresh_timer) {
|
||||||
Raise();
|
m_timer_count = 0;
|
||||||
|
m_refresh_timer->Start(ANIMATION_REFRESH_INTERVAL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageDPIFrame::on_hide()
|
void ImageDPIFrame::on_hide()
|
||||||
{
|
{
|
||||||
|
if (m_refresh_timer) {
|
||||||
|
m_refresh_timer->Stop();
|
||||||
|
}
|
||||||
if (IsShown()) {
|
if (IsShown()) {
|
||||||
Hide();
|
Hide();
|
||||||
if (wxGetApp().mainframe != nullptr) {
|
if (wxGetApp().mainframe != nullptr) {
|
||||||
|
|
|
@ -19,10 +19,16 @@ public:
|
||||||
void set_bitmap(const wxBitmap& bit_map);
|
void set_bitmap(const wxBitmap& bit_map);
|
||||||
int get_image_px() { return m_image_px; }
|
int get_image_px() { return m_image_px; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void init_timer();
|
||||||
|
void on_timer(wxTimerEvent &event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxStaticBitmap *m_bitmap = nullptr;
|
wxStaticBitmap *m_bitmap = nullptr;
|
||||||
wxBoxSizer *m_sizer_main{nullptr};
|
wxBoxSizer *m_sizer_main{nullptr};
|
||||||
int m_image_px;
|
int m_image_px;
|
||||||
|
wxTimer * m_refresh_timer{nullptr};
|
||||||
|
float m_timer_count = 0;
|
||||||
};
|
};
|
||||||
}} // namespace Slic3r::GUI
|
}} // namespace Slic3r::GUI
|
||||||
#endif // _STEP_MESH_DIALOG_H_
|
#endif // _STEP_MESH_DIALOG_H_
|
||||||
|
|
|
@ -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 = 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->Bind(wxEVT_LEFT_DOWN, [this](auto &evt) {
|
||||||
p->image_printer_bed->Unbind(wxEVT_LEAVE_WINDOW, &Sidebar::on_leave_image_printer_bed, this);
|
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);
|
p->combo_printer_bed->wxEvtHandler::ProcessEvent(evt);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1621,6 +1624,11 @@ Sidebar::Sidebar(Plater *parent)
|
||||||
}
|
}
|
||||||
e.Skip(); // fix bug:Event spreads to sidebar
|
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);
|
p->image_printer_bed->Bind(wxEVT_ENTER_WINDOW, &Sidebar::on_enter_image_printer_bed, this);
|
||||||
|
|
||||||
wxBoxSizer *bed_type_vsizer = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *bed_type_vsizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
@ -1952,10 +1960,10 @@ Sidebar::Sidebar(Plater *parent)
|
||||||
Sidebar::~Sidebar() {}
|
Sidebar::~Sidebar() {}
|
||||||
|
|
||||||
void Sidebar::on_enter_image_printer_bed(wxMouseEvent &evt) {
|
void Sidebar::on_enter_image_printer_bed(wxMouseEvent &evt) {
|
||||||
p->image_printer_bed->Unbind(wxEVT_LEAVE_WINDOW, &Sidebar::on_leave_image_printer_bed, this);
|
p->image_printer_bed->Bind(wxEVT_LEAVE_WINDOW, &Sidebar::on_leave_image_printer_bed, this);
|
||||||
auto pos = p->image_printer_bed->GetScreenPosition();
|
auto pos = p->panel_printer_bed->GetScreenPosition();
|
||||||
auto rect = p->image_printer_bed->GetRect();
|
auto rect = p->panel_printer_bed->GetRect();
|
||||||
wxPoint temp_pos(pos.x + rect.GetWidth(), pos.y);
|
wxPoint temp_pos(pos.x + rect.GetWidth() + FromDIP(3), pos.y);
|
||||||
if (p->big_bed_image_popup == nullptr) {
|
if (p->big_bed_image_popup == nullptr) {
|
||||||
p->big_bed_image_popup = new ImageDPIFrame();
|
p->big_bed_image_popup = new ImageDPIFrame();
|
||||||
auto image_path = get_cur_select_bed_image();
|
auto image_path = get_cur_select_bed_image();
|
||||||
|
@ -1967,8 +1975,13 @@ void Sidebar::on_enter_image_printer_bed(wxMouseEvent &evt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sidebar::on_leave_image_printer_bed(wxMouseEvent &evt) {
|
void Sidebar::on_leave_image_printer_bed(wxMouseEvent &evt) {
|
||||||
|
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();
|
p->big_bed_image_popup->on_hide();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
void Sidebar::on_change_color_mode(bool is_dark) {
|
void Sidebar::on_change_color_mode(bool is_dark) {
|
||||||
const ModelObjectPtrs &mos = wxGetApp().model().objects;
|
const ModelObjectPtrs &mos = wxGetApp().model().objects;
|
||||||
for (int i = 0; i < mos.size(); i++) {
|
for (int i = 0; i < mos.size(); i++) {
|
||||||
|
|
Loading…
Reference in New Issue