mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 18:45:55 +08:00
Fix not rendered style image. e.g. can't load font
This commit is contained in:
parent
f35065b77f
commit
133ce45aeb
@ -1078,16 +1078,20 @@ void GLGizmoEmboss::draw_style_list() {
|
||||
const FontItem & fi = item.font_item;
|
||||
const std::string &actual_style_name = fi.name;
|
||||
ImGui::PushID(actual_style_name.c_str());
|
||||
std::string name_truncated =
|
||||
ImGuiWrapper::trunc(actual_style_name, max_width);
|
||||
|
||||
bool is_selected = (&fi == &actual_font_item);
|
||||
ImGuiSelectableFlags_ flags =
|
||||
ImGuiSelectableFlags_AllowItemOverlap; // allow click buttons
|
||||
|
||||
ImVec2 select_size(0,0); // 0,0 --> calculate in draw
|
||||
std::string selectable_name = "##style_select"; // ## --> no visible
|
||||
if (item.image.has_value()) {
|
||||
const FontManager::StyleImage &img = *item.image;
|
||||
ImVec2 select_size(0.f, std::max(img.tex_size.y, m_gui_cfg->min_style_image_height));
|
||||
if (ImGui::Selectable("##style_select", is_selected, flags, select_size)) {
|
||||
select_size = ImVec2(0.f, std::max(img.tex_size.y, m_gui_cfg->min_style_image_height));
|
||||
} else {
|
||||
selectable_name = ImGuiWrapper::trunc(actual_style_name, max_width);
|
||||
}
|
||||
|
||||
// allow click delete button
|
||||
ImGuiSelectableFlags_ flags = ImGuiSelectableFlags_AllowItemOverlap;
|
||||
if (ImGui::Selectable(selectable_name.c_str(), is_selected, flags, select_size)) {
|
||||
if (m_font_manager.load_font(index)) {
|
||||
process();
|
||||
select_stored_font_item();
|
||||
@ -1107,8 +1111,11 @@ void GLGizmoEmboss::draw_style_list() {
|
||||
}
|
||||
|
||||
// draw style name
|
||||
if (item.image.has_value()) {
|
||||
const FontManager::StyleImage &img = *item.image;
|
||||
ImGui::SameLine();
|
||||
ImGui::Image(img.texture_id, img.tex_size, img.uv0, img.uv1);
|
||||
}
|
||||
|
||||
// delete button
|
||||
ImGui::SameLine(m_gui_cfg->delete_pos_x);
|
||||
|
@ -466,6 +466,7 @@ void FontManager::init_style_images(int max_width) {
|
||||
int offset_y = 0;
|
||||
int width = 0;
|
||||
for (Item &item : m_font_list) {
|
||||
if (!item.image.has_value()) continue;
|
||||
StyleImage &image = *item.image;
|
||||
image.offset.y() = offset_y;
|
||||
offset_y += image.tex_size.y+1;
|
||||
@ -474,6 +475,7 @@ void FontManager::init_style_images(int max_width) {
|
||||
}
|
||||
int height = offset_y;
|
||||
for (Item &item : m_font_list) {
|
||||
if (!item.image.has_value()) continue;
|
||||
StyleImage &image = *item.image;
|
||||
const Point &o = image.offset;
|
||||
const ImVec2 &s = image.tex_size;
|
||||
@ -497,10 +499,13 @@ void FontManager::init_style_images(int max_width) {
|
||||
|
||||
// set up texture id
|
||||
void *texture_id = (void *)(intptr_t) tex_id;
|
||||
for (Item &item : m_font_list) item.image->texture_id = texture_id;
|
||||
for (Item &item : m_font_list)
|
||||
if (item.image.has_value())
|
||||
item.image->texture_id = texture_id;
|
||||
|
||||
// upload sub textures
|
||||
for (Item &item : m_font_list) {
|
||||
if (!item.image.has_value()) continue;
|
||||
StyleImage &image = *item.image;
|
||||
sla::Resolution resolution(image.tex_size.x, image.tex_size.y);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user