mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 00:26:01 +08:00
Fix search in font list
This commit is contained in:
parent
d5686a0ecc
commit
4b31db5e66
@ -1080,7 +1080,6 @@ EmbossStyles GLGizmoEmboss::create_default_styles()
|
||||
|
||||
void GLGizmoEmboss::set_default_text(){ m_text = _u8L("Embossed text"); }
|
||||
|
||||
#include "imgui/imgui_internal.h" // to unfocus input --> ClearActiveID
|
||||
void GLGizmoEmboss::set_volume_by_selection()
|
||||
{
|
||||
ModelVolume *vol = priv::get_selected_volume(m_parent.get_selection());
|
||||
@ -1094,47 +1093,12 @@ void GLGizmoEmboss::set_volume_by_selection()
|
||||
// Do not use focused input value when switch volume(it must swith value)
|
||||
if (m_volume != nullptr &&
|
||||
m_volume != vol) // when update volume it changed id BUT not pointer
|
||||
ImGui::ClearActiveID();
|
||||
ImGuiWrapper::left_inputs();
|
||||
|
||||
// is select embossed volume?
|
||||
set_volume(vol);
|
||||
}
|
||||
|
||||
// Need internals to get window
|
||||
void priv::change_window_position(std::optional<ImVec2>& output_window_offset, bool try_to_fix) {
|
||||
const char* name = "Emboss";
|
||||
ImGuiWindow *window = ImGui::FindWindowByName(name);
|
||||
// is window just created
|
||||
if (window == NULL)
|
||||
return;
|
||||
|
||||
// position of window on screen
|
||||
ImVec2 position = window->Pos;
|
||||
ImVec2 size = window->SizeFull;
|
||||
|
||||
// screen size
|
||||
ImVec2 screen = ImGui::GetMainViewport()->Size;
|
||||
|
||||
if (position.x < 0) {
|
||||
if (position.y < 0)
|
||||
output_window_offset = ImVec2(0, 0);
|
||||
else
|
||||
output_window_offset = ImVec2(0, position.y);
|
||||
} else if (position.y < 0) {
|
||||
output_window_offset = ImVec2(position.x, 0);
|
||||
} else if (screen.x < (position.x + size.x)) {
|
||||
if (screen.y < (position.y + size.y))
|
||||
output_window_offset = ImVec2(screen.x - size.x, screen.y - size.y);
|
||||
else
|
||||
output_window_offset = ImVec2(screen.x - size.x, position.y);
|
||||
} else if (screen.y < (position.y + size.y)) {
|
||||
output_window_offset = ImVec2(position.x, screen.y - size.y);
|
||||
}
|
||||
|
||||
if (!try_to_fix && output_window_offset.has_value())
|
||||
output_window_offset = ImVec2(-1, -1); // Cannot
|
||||
}
|
||||
|
||||
bool GLGizmoEmboss::set_volume(ModelVolume *volume)
|
||||
{
|
||||
if (volume == nullptr) {
|
||||
@ -2152,6 +2116,9 @@ void GLGizmoEmboss::draw_font_list()
|
||||
face.cancel->store(true);
|
||||
glsafe(::glDeleteTextures(1, &m_face_names.texture_id));
|
||||
m_face_names.texture_id = 0;
|
||||
|
||||
// Remove value from search input
|
||||
ImGuiWrapper::left_inputs();
|
||||
}
|
||||
|
||||
// delete unloadable face name when try to use
|
||||
@ -3923,5 +3890,41 @@ void priv::find_closest_volume(const Selection &selection,
|
||||
}
|
||||
}
|
||||
|
||||
// Need internals to get window
|
||||
#include "imgui/imgui_internal.h"
|
||||
void priv::change_window_position(std::optional<ImVec2>& output_window_offset, bool try_to_fix) {
|
||||
const char* name = "Emboss";
|
||||
ImGuiWindow *window = ImGui::FindWindowByName(name);
|
||||
// is window just created
|
||||
if (window == NULL)
|
||||
return;
|
||||
|
||||
// position of window on screen
|
||||
ImVec2 position = window->Pos;
|
||||
ImVec2 size = window->SizeFull;
|
||||
|
||||
// screen size
|
||||
ImVec2 screen = ImGui::GetMainViewport()->Size;
|
||||
|
||||
if (position.x < 0) {
|
||||
if (position.y < 0)
|
||||
output_window_offset = ImVec2(0, 0);
|
||||
else
|
||||
output_window_offset = ImVec2(0, position.y);
|
||||
} else if (position.y < 0) {
|
||||
output_window_offset = ImVec2(position.x, 0);
|
||||
} else if (screen.x < (position.x + size.x)) {
|
||||
if (screen.y < (position.y + size.y))
|
||||
output_window_offset = ImVec2(screen.x - size.x, screen.y - size.y);
|
||||
else
|
||||
output_window_offset = ImVec2(screen.x - size.x, position.y);
|
||||
} else if (screen.y < (position.y + size.y)) {
|
||||
output_window_offset = ImVec2(position.x, screen.y - size.y);
|
||||
}
|
||||
|
||||
if (!try_to_fix && output_window_offset.has_value())
|
||||
output_window_offset = ImVec2(-1, -1); // Cannot
|
||||
}
|
||||
|
||||
// any existing icon filename to not influence GUI
|
||||
const std::string GLGizmoEmboss::M_ICON_FILENAME = "cut.svg";
|
||||
|
@ -1360,6 +1360,10 @@ bool ImGuiWrapper::slider_optional_int(const char *label,
|
||||
} else return false;
|
||||
}
|
||||
|
||||
void ImGuiWrapper::left_inputs() {
|
||||
ImGui::ClearActiveID();
|
||||
}
|
||||
|
||||
std::string ImGuiWrapper::trunc(const std::string &text,
|
||||
float width,
|
||||
const char * tail)
|
||||
|
@ -146,6 +146,12 @@ public:
|
||||
// Extended function ImGuiWrapper::slider_float to work with std::optional<int>, when value == def_val than optional release its value
|
||||
bool slider_optional_int(const char* label, std::optional<int> &v, int v_min, int v_max, const char* format = "%.3f", float power = 1.0f, bool clamp = true, const wxString& tooltip = {}, bool show_edit_btn = true, int def_val = 0);
|
||||
|
||||
/// <summary>
|
||||
/// Use ImGui internals to unactivate (lose focus) in input.
|
||||
/// When input is activ it can't change value by application.
|
||||
/// </summary>
|
||||
static void left_inputs();
|
||||
|
||||
/// <summary>
|
||||
/// Truncate text by ImGui draw function to specific width
|
||||
/// NOTE 1: ImGui must be initialized
|
||||
|
Loading…
x
Reference in New Issue
Block a user