From 02dd1b5f7d5cca8a9aafde182409261dc06f5cc3 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Wed, 25 Aug 2021 16:31:23 +0200 Subject: [PATCH] rendering highlight arrow from svg --- resources/icons/toolbar_arrow.png | Bin 3996 -> 0 bytes resources/icons/toolbar_arrow.svg | 94 +++++----------------- src/slic3r/GUI/GLCanvas3D.cpp | 8 +- src/slic3r/GUI/GLToolbar.cpp | 24 +++--- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 5 +- 5 files changed, 36 insertions(+), 95 deletions(-) delete mode 100644 resources/icons/toolbar_arrow.png diff --git a/resources/icons/toolbar_arrow.png b/resources/icons/toolbar_arrow.png deleted file mode 100644 index a370442ff0e933b85d436f3abac584b2e5ac3f37..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3996 zcmeHK_cI&-)4qrn9EskEe$hM8+i6j94yQ&ZN{F5l5vPR^33Ac7aD;G3^p+e)ln}ig z=afW?UZcLg-@gCheP?#(+1+_|W@mqRb~e%6R3AviP6Yq}fQAOTkZTMF0B(>|l3zy{ zm4}npa3ct!uMNNqa;{w`q@G$PS^z*zD)qTD*>!#^z`!O50HE#sKfm$A|C8Hwku6vc z7Hr|~5gg_m=ne=A3zK;K#3#trIlx`QKhQI0OO^ea{nJoa3mWdYnRhF|u8ZwQSb^Az zda&S)G#G>=dPLhUUVDv9ycUht)FFw^Xo-c@-{p)0O*U?7uDvw`;AMbh@f`G&XmPbw zt&-qE9aJrixsz{yC?tCdnE^1gH-_W=58H=0m1@xM4-S5x0T(x;ZoWa!N1PqCHMFE5 zq#_Sx&5mG%P?15zhxb)uBGMva|5`PaBHDc&k8ez*#TGl&nI{{^bySIhiXtLnc07%y zC-yWWR^(xNw1EiA{auFii@6I(PYtXt40>5m8ncUAgXtt)Dcb28&>jS*z%b;YPeEOe z*GhVTFdZt0{*LCwY-4TUA*+4@ec#{=MV!^)IfajbCO9A}(knkF#q_6XQ*<<*p}PwXzHA>u1a6AC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wVU|X;ab~K3G&TNQITJ-qEkyf2`)}I- z8`j8HS&TU*#ZKn!9s8vk2uv(q;7PA0cqc}e}5b~E!C+u%q znU@S$Ax1BLOpff|^MHIeHKwaG4~L+7LX46&7JzTC>#2)es0!+v*QZ=6J*Jq*MI)B? z>}^F^o32QR46c(Xf6I}hI89OqU)Rl&+h(g!)xUm)6w*GY>-ooGU>LoCzkYrJhI*#D z7;Ps+6=7j~FS^c&1a3MjoIcZN)f7O|jt_g$#yOV-zq{hGqIm2NpZ&ZT54ob~>jBv( LTMD)O|Nj2~#I)V2 diff --git a/resources/icons/toolbar_arrow.svg b/resources/icons/toolbar_arrow.svg index 998646a24..b49645190 100644 --- a/resources/icons/toolbar_arrow.svg +++ b/resources/icons/toolbar_arrow.svg @@ -1,76 +1,22 @@ - -image/svg+xml - \ No newline at end of file diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 227e5ae4e..1dd9f1d23 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4438,13 +4438,7 @@ bool GLCanvas3D::_init_main_toolbar() } // init arrow BackgroundTexture::Metadata arrow_data; - arrow_data.filename = "toolbar_arrow.png"; -// arrow_data.filename = "toolbar_arrow.svg"; - //arrow_data.left = 16; - //arrow_data.top = 16; - //arrow_data.right = 16; - //arrow_data.bottom = 16; - + arrow_data.filename = "toolbar_arrow.svg"; arrow_data.left = 0; arrow_data.top = 0; arrow_data.right = 0; diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index 243031847..515b6ed3a 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -193,10 +193,9 @@ bool GLToolbar::init_arrow(const BackgroundTexture::Metadata& arrow_texture) std::string path = resources_dir() + "/icons/"; bool res = false; - if (!arrow_texture.filename.empty()) - res = m_arrow_texture.texture.load_from_file(path + arrow_texture.filename, false, GLTexture::SingleThreaded, false); -// res = m_arrow_texture.texture.load_from_svg_file(path + arrow_texture.filename, false, true, false, 100); - + if (!arrow_texture.filename.empty()) { + res = m_arrow_texture.texture.load_from_svg_file(path + arrow_texture.filename, false, false, false, 1000); + } if (res) m_arrow_texture.metadata = arrow_texture; @@ -1176,19 +1175,22 @@ void GLToolbar::render_arrow(const GLCanvas3D& parent, GLToolbarItem* highlighte float right = left + scaled_icons_size; unsigned int tex_id = m_arrow_texture.texture.get_id(); + // width and height of icon arrow is pointing to float tex_width = (float)m_icons_texture.get_width(); float tex_height = (float)m_icons_texture.get_height(); + // arrow width and height + float arr_tex_width = (float)m_arrow_texture.texture.get_width(); + float arr_tex_height = (float)m_arrow_texture.texture.get_height(); + if ((tex_id != 0) && (arr_tex_width > 0) && (arr_tex_height > 0)) { + float inv_tex_width = (arr_tex_width != 0.0f) ? 1.0f / arr_tex_width : 0.0f; + float inv_tex_height = (arr_tex_height != 0.0f) ? 1.0f / arr_tex_height : 0.0f; - if ((tex_id != 0) && (tex_width > 0) && (tex_height > 0)) { - float inv_tex_width = (tex_width != 0.0f) ? 1.0f / tex_width : 0.0f; - float inv_tex_height = (tex_height != 0.0f) ? 1.0f / tex_height : 0.0f; - - float internal_left = left + border - scaled_icons_size / 2; // add half scaled_icons_size for huge arrow - float internal_right = right - border + scaled_icons_size / 2; + float internal_left = left + border - scaled_icons_size * 1.5f; // add scaled_icons_size for huge arrow + float internal_right = right - border + scaled_icons_size * 1.5f; float internal_top = top - border; // bottom is not moving and should be calculated from arrow texture sides ratio float arrow_sides_ratio = (float)m_arrow_texture.texture.get_height() / (float)m_arrow_texture.texture.get_width(); - float internal_bottom = internal_top - (internal_right - internal_left) * arrow_sides_ratio; + float internal_bottom = internal_top - (internal_right - internal_left) * arrow_sides_ratio ; float internal_left_uv = (float)m_arrow_texture.metadata.left * inv_tex_width; float internal_right_uv = 1.0f - (float)m_arrow_texture.metadata.right * inv_tex_width; diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 5617b5ed8..6d9a03977 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -132,8 +132,7 @@ bool GLGizmosManager::init_arrow(const BackgroundTexture::Metadata& arrow_textur bool res = false; if (!arrow_texture.filename.empty()) - res = m_arrow_texture.texture.load_from_file(path + arrow_texture.filename, false, GLTexture::SingleThreaded, false); -// res = m_arrow_texture.texture.load_from_svg_file(path + arrow_texture.filename, false, true, false, 100); + res = m_arrow_texture.texture.load_from_svg_file(path + arrow_texture.filename, false, false, false, 1000); if (res) m_arrow_texture.metadata = arrow_texture; @@ -1019,7 +1018,7 @@ void GLGizmosManager::render_arrow(const GLCanvas3D& parent, EType highlighted_t float arrow_sides_ratio = (float)m_arrow_texture.texture.get_height() / (float)m_arrow_texture.texture.get_width(); - GLTexture::render_sub_texture(tex_id, zoomed_top_x + zoomed_icons_size * 1.2f, zoomed_top_x + zoomed_icons_size * 1.2f + zoomed_icons_size * arrow_sides_ratio, zoomed_top_y - zoomed_icons_size, zoomed_top_y, { { internal_left_uv, internal_bottom_uv }, { internal_left_uv, internal_top_uv }, { internal_right_uv, internal_top_uv }, { internal_right_uv, internal_bottom_uv } }); + GLTexture::render_sub_texture(tex_id, zoomed_top_x + zoomed_icons_size * 1.2f, zoomed_top_x + zoomed_icons_size * 1.2f + zoomed_icons_size * 2.2f * arrow_sides_ratio, zoomed_top_y - zoomed_icons_size * 1.6f , zoomed_top_y + zoomed_icons_size * 0.6f, { { internal_left_uv, internal_bottom_uv }, { internal_left_uv, internal_top_uv }, { internal_right_uv, internal_top_uv }, { internal_right_uv, internal_bottom_uv } }); break; } zoomed_top_y -= zoomed_stride_y;