Manage Emboss text styles Cache actual state of style. More...
#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/Utils/EmbossStyleManager.hpp>
Classes | |
| struct | StyleImage |
| Describe image in GPU to show settings of style. More... | |
| struct | Style |
| All connected with one style keep temporary data and caches for style. More... | |
| struct | StyleCache |
| Cache data from style to reduce amount of: 1) loading font from file 2) Create atlas of symbols for imgui 3) Keep loaded(and modified by style) glyphs from font. More... | |
| struct | StyleImagesData |
| Keep data needed to create Font Style Images in Job. More... | |
Public Types | |
| using | Styles = std::vector<Style> |
Public Member Functions | |||||
| StyleManager (const ImWchar *language_glyph_range, const std::function< EmbossStyles()> &create_default_styles) | |||||
| |||||
| ~StyleManager () | |||||
| Release imgui font and style images from GPU. | |||||
| void | init (AppConfig *app_config) | ||||
| Load font style list from config Also select actual activ font. | |||||
| bool | store_styles_to_app_config (bool use_modification=true, bool store_active_index=true) | ||||
| Write font list into AppConfig. | |||||
| void | add_style (const std::string &name) | ||||
| Append actual style to style list. | |||||
| void | swap (size_t i1, size_t i2) | ||||
| Change order of style item in m_styles. Fix selected font index when (i1 || i2) == m_font_selected. | |||||
| void | discard_style_changes () | ||||
| Discard changes in activ style When no activ style use last used OR first loadable. | |||||
| void | erase (size_t index) | ||||
| Remove style from m_styles. Fix selected font index when index is under m_font_selected. | |||||
| void | rename (const std::string &name) | ||||
| Rename actual selected font item. | |||||
| void | load_valid_style () | ||||
| load some valid style | |||||
| bool | load_style (size_t font_index) | ||||
| Change active font When font not loaded roll back activ font. | |||||
| bool | load_style (const Style &style) | ||||
| bool | load_style (const Style &style, const wxFont &font) | ||||
| void | clear_glyphs_cache () | ||||
| void | clear_imgui_font () | ||||
| const Style * | get_stored_style () const | ||||
| const Style & | get_style () const | ||||
| Style & | get_style () | ||||
| size_t | get_style_index () const | ||||
| std::string & | get_truncated_name () | ||||
| const ImFontAtlas & | get_atlas () const | ||||
| const FontProp & | get_font_prop () const | ||||
| FontProp & | get_font_prop () | ||||
| const wxFont & | get_wx_font () const | ||||
| const wxFont & | get_stored_wx_font () const | ||||
| Slic3r::Emboss::FontFileWithCache & | get_font_file_with_cache () | ||||
| bool | has_collections () const | ||||
| bool | exist_stored_style () const | ||||
| bool | is_font_changed () const | ||||
| check whether current style differ to selected | |||||
| bool | is_unique_style_name (const std::string &name) const | ||||
| bool | set_wx_font (const wxFont &wx_font) | ||||
| Setter on wx_font when changed. | |||||
| bool | set_wx_font (const wxFont &wx_font, std::unique_ptr< Slic3r::Emboss::FontFile > font_file) | ||||
| Faster way of set wx_font when font file is known(do not load font file twice) When you not sure that wx_font is made by font_file use only set_wx_font(wx_font). | |||||
| ImFont * | get_imgui_font () | ||||
| ImFont * | create_imgui_font (const std::string &text, double scale) | ||||
| void | init_trunc_names (float max_width) | ||||
| void | init_style_images (const Vec2i32 &max_size, const std::string &text) | ||||
| Initialization texture with rendered font style. | |||||
| void | free_style_images () | ||||
| const std::vector< Style > & | get_styles () const | ||||
| bool | is_active_font () | ||||
Static Public Member Functions | |
| static float | get_imgui_font_size (const FontProp &prop, const Slic3r::Emboss::FontFile &file, double scale) |
Static Public Attributes | |
| static float | min_imgui_font_size = 18.f |
| static float | max_imgui_font_size = 60.f |
Private Attributes | |
| std::function< EmbossStyles()> | m_create_default_styles |
| const ImWchar * | m_imgui_init_glyph_range |
| struct Slic3r::GUI::Emboss::StyleManager::StyleCache | m_style_cache |
| Styles | m_styles |
| AppConfig * | m_app_config = nullptr |
| size_t | m_last_style_index = std::numeric_limits<size_t>::max() |
| std::shared_ptr< StyleImagesData::StyleImages > | m_temp_style_images = nullptr |
| bool | m_exist_style_images = false |
Friends | |
| class | CreateFontStyleImagesJob |
Manage Emboss text styles Cache actual state of style.
| struct Slic3r::GUI::Emboss::StyleManager::StyleImage |
Describe image in GPU to show settings of style.
| Class Members | ||
|---|---|---|
| BoundingBox | bounding_box | |
| Point | offset = Point(0, 0) | |
| ImVec2 | tex_size | |
| void * | texture_id = nullptr | |
| ImVec2 | uv0 | |
| ImVec2 | uv1 | |
| struct Slic3r::GUI::Emboss::StyleManager::StyleCache |
Cache data from style to reduce amount of: 1) loading font from file 2) Create atlas of symbols for imgui 3) Keep loaded(and modified by style) glyphs from font.
| Class Members | ||
|---|---|---|
| ImFontAtlas | atlas = {} | |
| FontFileWithCache | font_file = {} | |
| ImVector< ImWchar > | ranges = {} | |
| wxFont | stored_wx_font = {} | |
| Style | style = {} | |
| size_t | style_index = std::numeric_limits<size_t>::max() | |
| string | truncated_name | |
| wxFont | wx_font = {} | |
| struct Slic3r::GUI::Emboss::StyleManager::StyleImagesData |
| using Slic3r::GUI::Emboss::StyleManager::Styles = std::vector<Style> |
| StyleManager::StyleManager | ( | const ImWchar * | language_glyph_range, |
| const std::function< EmbossStyles()> & | create_default_styles ) |
| language_glyph_range | Character to load for imgui when initialize imgui font |
| create_default_styles | Function to create default styles |
References m_create_default_styles, and m_imgui_init_glyph_range.
| StyleManager::~StyleManager | ( | ) |
Release imgui font and style images from GPU.
References clear_imgui_font(), and free_style_images().
| void StyleManager::add_style | ( | const std::string & | name | ) |
Append actual style to style list.
| name | New name for style |
References m_style_cache, m_styles, and style.
| void StyleManager::clear_glyphs_cache | ( | ) |
References Slic3r::Emboss::FontFileWithCache::cache, Slic3r::Emboss::FontFileWithCache::has_value(), and m_style_cache.
| void StyleManager::clear_imgui_font | ( | ) |
References m_style_cache.
Referenced by ~StyleManager(), and set_wx_font().
| ImFont * StyleManager::create_imgui_font | ( | const std::string & | text, |
| double | scale ) |
References Slic3r::GUI::OpenGLManager::are_compressed_textures_supported(), Slic3r::FontProp::char_gap, Slic3r::Emboss::FontFile::data, Slic3r::Emboss::get_font_info(), get_imgui_font_size(), GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_LINEAR, GL_RGBA, GL_TEXTURE_2D, GL_TEXTURE_BINDING_2D, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_UNPACK_ROW_LENGTH, GL_UNSIGNED_BYTE, glBindTexture, glGenTextures, glGetIntegerv, glPixelStorei, glsafe, glTexImage2D, glTexParameteri, Slic3r::FontProp::line_gap, m_imgui_init_glyph_range, m_style_cache, max_imgui_font_size, min_imgui_font_size, scale(), and Slic3r::Emboss::FontFile::Info::unit_per_em.
| void StyleManager::discard_style_changes | ( | ) |
Discard changes in activ style When no activ style use last used OR first loadable.
References exist_stored_style(), load_style(), load_valid_style(), m_last_style_index, and m_style_cache.
| void StyleManager::erase | ( | size_t | index | ) |
Remove style from m_styles. Fix selected font index when index is under m_font_selected.
| index | Index of style to be removed |
References exist_stored_style(), m_style_cache, and m_styles.
|
inline |
References m_style_cache.
Referenced by discard_style_changes(), erase(), is_font_changed(), rename(), store_styles_to_app_config(), and swap().
| void StyleManager::free_style_images | ( | ) |
References glDeleteTextures, glsafe, m_exist_style_images, and m_styles.
Referenced by ~StyleManager().
|
inline |
References m_style_cache.
|
inline |
References m_style_cache.
Referenced by anonymous_namespace{GLGizmoEmboss.cpp}::can_write(), anonymous_namespace{GLGizmoEmboss.cpp}::create_emboss_data_base(), and Slic3r::GUI::TextLinesModel::init().
|
inline |
References get_style(), and Slic3r::EmbossStyle::prop.
|
inline |
References get_style(), and Slic3r::EmbossStyle::prop.
Referenced by anonymous_namespace{GLGizmoEmboss.cpp}::can_write(), and Slic3r::GUI::TextLinesModel::init().
| ImFont * StyleManager::get_imgui_font | ( | ) |
References is_active_font(), and m_style_cache.
|
static |
References Slic3r::Emboss::FontFile::Info::ascent, Slic3r::Emboss::FontFile::Info::descent, Slic3r::Emboss::get_font_info(), Slic3r::Emboss::FontFile::Info::linegap, scale(), Slic3r::FontProp::size_in_mm, and Slic3r::Emboss::FontFile::Info::unit_per_em.
Referenced by create_imgui_font(), and Slic3r::GUI::GLGizmoEmboss::draw_text_input().
| const StyleManager::Style * StyleManager::get_stored_style | ( | ) | const |
References m_style_cache, and m_styles.
Referenced by is_font_changed().
|
inline |
References m_style_cache.
Referenced by is_font_changed().
|
inline |
References m_style_cache.
|
inline |
References m_style_cache.
Referenced by anonymous_namespace{GLGizmoEmboss.cpp}::create_emboss_data_base(), get_font_prop(), get_font_prop(), and is_font_changed().
|
inline |
References m_style_cache.
| const StyleManager::Styles & StyleManager::get_styles | ( | ) | const |
|
inline |
References m_style_cache.
|
inline |
References m_style_cache.
Referenced by anonymous_namespace{GLGizmoEmboss.cpp}::create_emboss_data_base(), and is_font_changed().
|
inline |
References m_style_cache.
| void StyleManager::init | ( | AppConfig * | app_config | ) |
Load font style list from config Also select actual activ font.
| app_config | Application configuration loaded from file "PrusaSlicer.ini"
|
References load_style(), load_valid_style(), m_app_config, m_create_default_styles, m_styles, and style.
| void StyleManager::init_style_images | ( | const Vec2i32 & | max_size, |
| const std::string & | text ) |
Initialization texture with rendered font style.
| max_size | Maximal width and height of one style texture |
| text | Text to render by style |
References Slic3r::GUI::WxFontUtils::create_font_file(), Slic3r::GUI::get_dpi_for_window(), Slic3r::GUI::GizmoObjectManipulation::in_to_mm, Slic3r::GUI::WxFontUtils::load_wxFont(), m_exist_style_images, m_styles, m_temp_style_images, Slic3r::GUI::queue_job(), and style.
| void StyleManager::init_trunc_names | ( | float | max_width | ) |
References Slic3r::GUI::ImGuiWrapper::escape_double_hash(), m_styles, and Slic3r::GUI::ImGuiWrapper::trunc().
| bool StyleManager::is_active_font | ( | ) |
References m_style_cache.
Referenced by anonymous_namespace{GLGizmoEmboss.cpp}::create_emboss_data_base(), get_imgui_font(), and Slic3r::GUI::TextLinesModel::init().
| bool StyleManager::is_font_changed | ( | ) | const |
check whether current style differ to selected
References Slic3r::FontProp::boldness, exist_stored_style(), get_stored_style(), get_stored_wx_font(), get_style(), get_wx_font(), Slic3r::GUI::WxFontUtils::is_bold(), Slic3r::Emboss::is_italic(), Slic3r::GUI::WxFontUtils::is_italic(), Slic3r::EmbossStyle::prop, and Slic3r::FontProp::skew.
| bool StyleManager::is_unique_style_name | ( | const std::string & | name | ) | const |
| bool StyleManager::load_style | ( | const Style & | style | ) |
References Slic3r::Emboss::create_font_file(), Slic3r::EmbossStyle::file_path, Slic3r::GUI::WxFontUtils::get_current_type(), load_style(), Slic3r::GUI::WxFontUtils::load_wxFont(), m_style_cache, and style.
| bool StyleManager::load_style | ( | const Style & | style, |
| const wxFont & | font ) |
References m_style_cache, set_wx_font(), and style.
| bool StyleManager::load_style | ( | size_t | font_index | ) |
Change active font When font not loaded roll back activ font.
| font_index | New font index(from m_styles range) |
References load_style(), m_last_style_index, m_style_cache, and m_styles.
Referenced by anonymous_namespace{GLGizmoEmboss.cpp}::can_write(), discard_style_changes(), init(), load_style(), load_style(), load_valid_style(), and Slic3r::GUI::GLGizmoEmboss::re_emboss().
| void StyleManager::load_valid_style | ( | ) |
load some valid style
References load_style(), m_create_default_styles, m_styles, and style.
Referenced by anonymous_namespace{GLGizmoEmboss.cpp}::create_emboss_data_base(), discard_style_changes(), and init().
| void StyleManager::rename | ( | const std::string & | name | ) |
Rename actual selected font item.
| name | New name |
References exist_stored_style(), m_style_cache, m_styles, Slic3r::EmbossStyle::name, and Slic3r::GUI::Emboss::StyleManager::Style::truncated_name.
| bool StyleManager::set_wx_font | ( | const wxFont & | wx_font | ) |
Setter on wx_font when changed.
| wx_font | new wx font |
References Slic3r::GUI::WxFontUtils::create_font_file(), and set_wx_font().
Referenced by load_style(), and set_wx_font().
| bool StyleManager::set_wx_font | ( | const wxFont & | wx_font, |
| std::unique_ptr< Slic3r::Emboss::FontFile > | font_file ) |
Faster way of set wx_font when font file is known(do not load font file twice) When you not sure that wx_font is made by font_file use only set_wx_font(wx_font).
| wx_font | Must be source of font file |
| font_file | font file created by WxFontUtils::create_font_file(wx_font) |
References clear_imgui_font(), Slic3r::GUI::WxFontUtils::get_current_type(), m_style_cache, Slic3r::GUI::WxFontUtils::store_wxFont(), style, and Slic3r::GUI::WxFontUtils::update_property().
| bool StyleManager::store_styles_to_app_config | ( | bool | use_modification = true, |
| bool | store_active_index = true ) |
Write font list into AppConfig.
| item_to_store | Configuration |
| use_modification | When true cache state will be used for store |
| use_modification | When true store activ index into configuration |
References exist_stored_style(), m_app_config, m_last_style_index, m_style_cache, m_styles, and style.
| void StyleManager::swap | ( | size_t | i1, |
| size_t | i2 ) |
Change order of style item in m_styles. Fix selected font index when (i1 || i2) == m_font_selected.
| i1 | First index to m_styles |
| i2 | Second index to m_styles |
References exist_stored_style(), m_style_cache, and m_styles.
|
friend |
References CreateFontStyleImagesJob, and style.
Referenced by CreateFontStyleImagesJob.
Referenced by init(), and store_styles_to_app_config().
|
private |
Referenced by StyleManager(), init(), and load_valid_style().
|
private |
Referenced by free_style_images(), and init_style_images().
|
private |
Referenced by StyleManager(), and create_imgui_font().
|
private |
Referenced by discard_style_changes(), load_style(), and store_styles_to_app_config().
|
private |
Referenced by add_style(), clear_glyphs_cache(), clear_imgui_font(), create_imgui_font(), discard_style_changes(), erase(), exist_stored_style(), get_atlas(), get_font_file_with_cache(), get_imgui_font(), get_stored_style(), get_stored_wx_font(), get_style(), get_style(), get_style_index(), get_truncated_name(), get_wx_font(), has_collections(), is_active_font(), load_style(), load_style(), load_style(), rename(), set_wx_font(), store_styles_to_app_config(), and swap().
|
private |
|
private |
Referenced by init_style_images().
|
static |
Referenced by create_imgui_font(), and Slic3r::GUI::GLGizmoEmboss::draw_text_input().
|
static |
Referenced by create_imgui_font(), and Slic3r::GUI::GLGizmoEmboss::draw_text_input().