Tech ENABLE_PREVIEW_LAYOUT - Fixed legend width when moving the application to another monitor
This commit is contained in:
parent
d458de601b
commit
1a95169466
@ -758,6 +758,9 @@ void GCodeViewer::reset()
|
|||||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
m_statistics.reset_all();
|
m_statistics.reset_all();
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
|
#if ENABLE_PREVIEW_LAYOUT
|
||||||
|
m_legend_resizer.reset();
|
||||||
|
#endif // ENABLE_PREVIEW_LAYOUT
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeViewer::render()
|
void GCodeViewer::render()
|
||||||
@ -3513,8 +3516,11 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||||||
bool view_type_changed = false;
|
bool view_type_changed = false;
|
||||||
int old_view_type = static_cast<int>(get_view_type());
|
int old_view_type = static_cast<int>(get_view_type());
|
||||||
int view_type = old_view_type;
|
int view_type = old_view_type;
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
|
||||||
ImGui::PushItemWidth(ImGui::GetWindowWidth() - style.ItemSpacing.x - 2.0f * style.FramePadding.x);
|
ImGui::SetNextItemWidth(m_legend_resizer.dirty ? 0.0f : -1.0f);
|
||||||
|
if (m_legend_resizer.last_width > ImGui::GetWindowWidth())
|
||||||
|
m_legend_resizer.dirty = false;
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_FrameBg, { 0.1f, 0.1f, 0.1f, 0.8f });
|
ImGui::PushStyleColor(ImGuiCol_FrameBg, { 0.1f, 0.1f, 0.1f, 0.8f });
|
||||||
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, { 0.2f, 0.2f, 0.2f, 0.8f });
|
ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, { 0.2f, 0.2f, 0.2f, 0.8f });
|
||||||
imgui.combo("", { _u8L("Feature type"),
|
imgui.combo("", { _u8L("Feature type"),
|
||||||
@ -4182,6 +4188,10 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||||||
const float mid_x = 0.5f * (pos.x + pos.x + size);
|
const float mid_x = 0.5f * (pos.x + pos.x + size);
|
||||||
window.DrawList->AddRectFilled({ mid_x - 0.09375f * size, p1.y - 0.25f * size }, { mid_x + 0.09375f * size, pos.y + margin }, color);
|
window.DrawList->AddRectFilled({ mid_x - 0.09375f * size, p1.y - 0.25f * size }, { mid_x + 0.09375f * size, pos.y + margin }, color);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_legend_resizer.last_width = ImGui::GetCurrentWindow()->DC.CursorPosPrevLine.x + ImGui::GetStyle().WindowPadding.x;
|
||||||
|
if (m_legend_resizer.last_width < ImGui::GetWindowWidth())
|
||||||
|
m_legend_resizer.dirty = true;
|
||||||
#endif // ENABLE_PREVIEW_LAYOUT
|
#endif // ENABLE_PREVIEW_LAYOUT
|
||||||
|
|
||||||
legend_height = ImGui::GetCurrentWindow()->Size.y;
|
legend_height = ImGui::GetCurrentWindow()->Size.y;
|
||||||
|
@ -793,6 +793,19 @@ private:
|
|||||||
Shells m_shells;
|
Shells m_shells;
|
||||||
EViewType m_view_type{ EViewType::FeatureType };
|
EViewType m_view_type{ EViewType::FeatureType };
|
||||||
bool m_legend_enabled{ true };
|
bool m_legend_enabled{ true };
|
||||||
|
#if ENABLE_PREVIEW_LAYOUT
|
||||||
|
struct LegendResizer
|
||||||
|
{
|
||||||
|
bool dirty{ true };
|
||||||
|
float last_width{ 0.0f };
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
dirty = true;
|
||||||
|
last_width = 0.0f;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
LegendResizer m_legend_resizer;
|
||||||
|
#endif // ENABLE_PREVIEW_LAYOUT
|
||||||
PrintEstimatedStatistics m_print_statistics;
|
PrintEstimatedStatistics m_print_statistics;
|
||||||
PrintEstimatedStatistics::ETimeMode m_time_estimate_mode{ PrintEstimatedStatistics::ETimeMode::Normal };
|
PrintEstimatedStatistics::ETimeMode m_time_estimate_mode{ PrintEstimatedStatistics::ETimeMode::Normal };
|
||||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
@ -858,6 +871,10 @@ public:
|
|||||||
std::vector<CustomGCode::Item>& get_custom_gcode_per_print_z() { return m_custom_gcode_per_print_z; }
|
std::vector<CustomGCode::Item>& get_custom_gcode_per_print_z() { return m_custom_gcode_per_print_z; }
|
||||||
size_t get_extruders_count() { return m_extruders_count; }
|
size_t get_extruders_count() { return m_extruders_count; }
|
||||||
|
|
||||||
|
#if ENABLE_PREVIEW_LAYOUT
|
||||||
|
void invalidate_legend() { m_legend_resizer.reset(); }
|
||||||
|
#endif // ENABLE_PREVIEW_LAYOUT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void load_toolpaths(const GCodeProcessor::Result& gcode_result);
|
void load_toolpaths(const GCodeProcessor::Result& gcode_result);
|
||||||
void load_shells(const Print& print, bool initialized);
|
void load_shells(const Print& print, bool initialized);
|
||||||
|
@ -3741,6 +3741,9 @@ void GLCanvas3D::set_cursor(ECursorType type)
|
|||||||
|
|
||||||
void GLCanvas3D::msw_rescale()
|
void GLCanvas3D::msw_rescale()
|
||||||
{
|
{
|
||||||
|
#if ENABLE_PREVIEW_LAYOUT
|
||||||
|
m_gcode_viewer.invalidate_legend();
|
||||||
|
#endif // ENABLE_PREVIEW_LAYOUT
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::update_tooltip_for_settings_item_in_main_toolbar()
|
void GLCanvas3D::update_tooltip_for_settings_item_in_main_toolbar()
|
||||||
|
Loading…
Reference in New Issue
Block a user