mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Fix preview legend window size (#3363)
Fix issue that the legend window expands to all available horizontal space if scrollbar is displayed
This commit is contained in:
		
							parent
							
								
									1d8cdf04d2
								
							
						
					
					
						commit
						a8ade1554f
					
				
					 1 changed files with 3 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -4504,16 +4504,17 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
 | 
			
		|||
        return ret;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    auto calculate_offsets = [max_width, window_padding](const std::vector<std::pair<std::string, std::vector<::string>>>& title_columns, float extra_size = 0.0f) {
 | 
			
		||||
    auto calculate_offsets = [&imgui, max_width, window_padding](const std::vector<std::pair<std::string, std::vector<::string>>>& title_columns, float extra_size = 0.0f) {
 | 
			
		||||
            const ImGuiStyle& style = ImGui::GetStyle();
 | 
			
		||||
            std::vector<float> offsets;
 | 
			
		||||
            offsets.push_back(max_width(title_columns[0].second, title_columns[0].first, extra_size) + 3.0f * style.ItemSpacing.x);
 | 
			
		||||
            for (size_t i = 1; i < title_columns.size() - 1; i++)
 | 
			
		||||
                offsets.push_back(offsets.back() + max_width(title_columns[i].second, title_columns[i].first) + style.ItemSpacing.x);
 | 
			
		||||
            if (title_columns.back().first == _u8L("Display")) {
 | 
			
		||||
                const auto preferred_offset = ImGui::GetWindowWidth() - ImGui::CalcTextSize(_u8L("Display").c_str()).x - ImGui::GetFrameHeight() / 2 - 2 * window_padding;
 | 
			
		||||
                const auto preferred_offset = ImGui::GetWindowWidth() - ImGui::CalcTextSize(_u8L("Display").c_str()).x - ImGui::GetFrameHeight() / 2 - 2 * window_padding - ImGui::GetStyle().ScrollbarSize;
 | 
			
		||||
                if (preferred_offset > offsets.back()) {
 | 
			
		||||
                    offsets.back() = preferred_offset;
 | 
			
		||||
                    imgui.set_requires_extra_frame();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue