Follow-up of d54548367a
-> Reintroduce GLCanvas3D::m_old_size to avoid unneeded calls to render()
This commit is contained in:
parent
ef9004cee4
commit
2bd3e018b1
3 changed files with 25 additions and 1 deletions
|
@ -4527,6 +4527,14 @@ void GLCanvas3D::_resize(unsigned int w, unsigned int h)
|
||||||
if (m_canvas == nullptr && m_context == nullptr)
|
if (m_canvas == nullptr && m_context == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if ENABLE_SCROLLABLE_LEGEND
|
||||||
|
const std::array<unsigned int, 2> new_size = { w, h };
|
||||||
|
if (m_old_size == new_size)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_old_size = new_size;
|
||||||
|
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||||
|
|
||||||
auto *imgui = wxGetApp().imgui();
|
auto *imgui = wxGetApp().imgui();
|
||||||
imgui->set_display_size(static_cast<float>(w), static_cast<float>(h));
|
imgui->set_display_size(static_cast<float>(w), static_cast<float>(h));
|
||||||
const float font_size = 1.5f * wxGetApp().em_unit();
|
const float font_size = 1.5f * wxGetApp().em_unit();
|
||||||
|
|
|
@ -425,6 +425,10 @@ private:
|
||||||
Model* m_model;
|
Model* m_model;
|
||||||
BackgroundSlicingProcess *m_process;
|
BackgroundSlicingProcess *m_process;
|
||||||
|
|
||||||
|
#if ENABLE_SCROLLABLE_LEGEND
|
||||||
|
std::array<unsigned int, 2> m_old_size{ 0, 0 };
|
||||||
|
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||||
|
|
||||||
// Screen is only refreshed from the OnIdle handler if it is dirty.
|
// Screen is only refreshed from the OnIdle handler if it is dirty.
|
||||||
bool m_dirty;
|
bool m_dirty;
|
||||||
bool m_initialized;
|
bool m_initialized;
|
||||||
|
@ -733,6 +737,10 @@ public:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_SCROLLABLE_LEGEND
|
||||||
|
void reset_old_size() { m_old_size = { 0, 0 }; }
|
||||||
|
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _is_shown_on_screen() const;
|
bool _is_shown_on_screen() const;
|
||||||
|
|
||||||
|
|
|
@ -3437,6 +3437,10 @@ void Plater::priv::set_current_panel(wxPanel* panel)
|
||||||
|
|
||||||
// sets the canvas as dirty to force a render at the 1st idle event (wxWidgets IsShownOnScreen() is buggy and cannot be used reliably)
|
// sets the canvas as dirty to force a render at the 1st idle event (wxWidgets IsShownOnScreen() is buggy and cannot be used reliably)
|
||||||
view3D->set_as_dirty();
|
view3D->set_as_dirty();
|
||||||
|
#if ENABLE_SCROLLABLE_LEGEND
|
||||||
|
// reset cached size to force a resize on next call to render() to keep imgui in synch with canvas size
|
||||||
|
view3D->get_canvas3d()->reset_old_size();
|
||||||
|
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||||
view_toolbar.select_item("3D");
|
view_toolbar.select_item("3D");
|
||||||
if (notification_manager != nullptr)
|
if (notification_manager != nullptr)
|
||||||
notification_manager->set_in_preview(false);
|
notification_manager->set_in_preview(false);
|
||||||
|
@ -3457,6 +3461,10 @@ void Plater::priv::set_current_panel(wxPanel* panel)
|
||||||
preview->reload_print(true);
|
preview->reload_print(true);
|
||||||
|
|
||||||
preview->set_as_dirty();
|
preview->set_as_dirty();
|
||||||
|
#if ENABLE_SCROLLABLE_LEGEND
|
||||||
|
// reset cached size to force a resize on next call to render() to keep imgui in synch with canvas size
|
||||||
|
preview->get_canvas3d()->reset_old_size();
|
||||||
|
#endif // ENABLE_SCROLLABLE_LEGEND
|
||||||
view_toolbar.select_item("Preview");
|
view_toolbar.select_item("Preview");
|
||||||
if (notification_manager != nullptr)
|
if (notification_manager != nullptr)
|
||||||
notification_manager->set_in_preview(true);
|
notification_manager->set_in_preview(true);
|
||||||
|
|
Loading…
Reference in a new issue