Redesign GUI of emboss
This commit is contained in:
parent
83372764ad
commit
770a5c5501
57
resources/icons/make_bold.svg
Normal file
57
resources/icons/make_bold.svg
Normal file
@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.0"
|
||||
id="Layer_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 16 16"
|
||||
enable-background="new 0 0 16 16"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="make_bold.svg"
|
||||
inkscape:version="1.0.2 (e86c870879, 2021-01-15, custom)"><metadata
|
||||
id="metadata12"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs10" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1137"
|
||||
id="namedview8"
|
||||
showgrid="false"
|
||||
inkscape:zoom="21.831922"
|
||||
inkscape:cx="2.9625479"
|
||||
inkscape:cy="3.8740341"
|
||||
inkscape:window-x="1912"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Layer_1"
|
||||
inkscape:document-rotation="0" />
|
||||
|
||||
<g
|
||||
id="g837"><path
|
||||
id="path905"
|
||||
style="font-size:19.6818px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ed6b21;fill-opacity:1;stroke-width:1"
|
||||
sodipodi:type="inkscape:offset"
|
||||
inkscape:radius="0.45459658"
|
||||
inkscape:original="M 2.6035156 0.84570312 L 2.6035156 15.154297 L 7.6777344 15.154297 C 8.670794 15.154297 9.4882228 15.06611 10.128906 14.886719 C 10.775997 14.707327 11.368076 14.405273 11.90625 13.982422 C 12.361135 13.630046 12.7231 13.1813 12.992188 12.636719 C 13.261275 12.092137 13.396484 11.465065 13.396484 10.753906 C 13.396484 9.7608469 13.117942 8.9400592 12.560547 8.2929688 C 12.003152 7.6394714 11.24087 7.2142369 10.273438 7.015625 L 10.273438 6.9375 C 10.850053 6.6491924 11.310281 6.2690278 11.65625 5.7949219 C 12.002219 5.3144092 12.175781 4.7338122 12.175781 4.0546875 C 12.175781 3.4524449 12.057366 2.9370705 11.820312 2.5078125 C 11.58326 2.0721476 11.201142 1.7169002 10.675781 1.4414062 C 10.201675 1.1979465 9.7064537 1.0378196 9.1875 0.9609375 C 8.6685463 0.88405547 7.8861111 0.84570312 6.8417969 0.84570312 L 2.6035156 0.84570312 z M 4.5058594 2.46875 L 6.7753906 2.46875 C 7.4096674 2.46875 7.9398826 2.4922615 8.3691406 2.5371094 C 8.7983987 2.5755504 9.1637225 2.6805311 9.4648438 2.8535156 C 9.7211172 3.0008729 9.9081142 3.1926346 10.023438 3.4296875 C 10.13876 3.6667404 10.195312 3.9587184 10.195312 4.3046875 C 10.195312 4.7211321 10.132043 5.0830969 10.003906 5.390625 C 9.8821764 5.6917463 9.6702619 5.9386543 9.3691406 6.1308594 C 9.0680193 6.3230648 8.7410479 6.451557 8.3886719 6.515625 C 8.0362959 6.5732863 7.5626326 6.6015625 6.9667969 6.6015625 L 4.5058594 6.6015625 L 4.5058594 2.46875 z M 4.5058594 8.2070312 L 7.4960938 8.2070312 C 8.1239637 8.2070313 8.6541789 8.2319485 9.0898438 8.2832031 C 9.5319154 8.328051 9.9073154 8.431626 10.214844 8.5917969 C 10.669729 8.8288499 10.983265 9.1155159 11.15625 9.4550781 C 11.329234 9.7946405 11.416016 10.253463 11.416016 10.830078 C 11.416016 11.336218 11.332593 11.74997 11.166016 12.070312 C 10.999438 12.390654 10.737689 12.675915 10.378906 12.925781 C 10.039344 13.156427 9.604033 13.316555 9.0722656 13.40625 C 8.5404982 13.489539 7.8582794 13.53125 7.0253906 13.53125 L 4.5058594 13.53125 L 4.5058594 8.2070312 z "
|
||||
d="M 2.6035156,0.390625 A 0.45464204,0.45464204 0 0 0 2.1484375,0.84570312 V 15.154297 a 0.45464204,0.45464204 0 0 0 0.4550781,0.455078 h 5.0742188 c 1.0192082,0 1.8724488,-0.08943 2.5722656,-0.285156 0.704041,-0.19518 1.353249,-0.525333 1.935547,-0.982422 l 0.002,-0.002 c 0.509285,-0.395061 0.916438,-0.901991 1.212891,-1.501953 0.303691,-0.614615 0.451172,-1.315206 0.451171,-2.083985 0,-1.0770667 -0.313909,-2.0217764 -0.945312,-2.7558591 l -0.002,-0.00195 C 12.461534,7.4777218 11.86388,7.1351112 11.203125,6.875 11.514504,6.637151 11.796619,6.3733249 12.023438,6.0625 a 0.45464204,0.45464204 0 0 0 0.002,-0.00195 c 0.405303,-0.5629213 0.605468,-1.2492814 0.605468,-2.0058594 0,-0.6618322 -0.131587,-1.259609 -0.412109,-1.7675781 v 0.00391 C 11.93326,1.7663287 11.474136,1.347098 10.886719,1.0390625 a 0.45464204,0.45464204 0 0 0 -0.0039,-0.00195 C 10.366329,0.77188829 9.821904,0.59586664 9.2539062,0.51171875 8.6911072,0.42834112 7.8972411,0.390625 6.8417969,0.390625 Z m 2.3574219,2.5332031 h 1.8144531 c 0.6230428,0 1.1397643,0.021919 1.546875,0.064453 a 0.45464204,0.45464204 0 0 0 0.00586,0.00195 c 0.3788452,0.033926 0.6778569,0.124364 0.9101562,0.2578125 0.1913715,0.1100386 0.3040086,0.2309187 0.3769532,0.3808593 0.076659,0.1575785 0.125,0.379351 0.125,0.6757813 0,0.3704011 -0.056389,0.670489 -0.15625,0.9101563 a 0.45464204,0.45464204 0 0 0 -0.00195,0.00586 C 9.4966472,5.4319168 9.3588253,5.5987966 9.125,5.7480469 8.8745265,5.9079238 8.6070974,6.0121766 8.3144531,6.0664062 c -9.002e-4,1.474e-4 -0.003,-1.469e-4 -0.00391,0 -0.3116061,0.050728 -0.7639761,0.080078 -1.34375,0.080078 H 4.9609375 Z m 0,5.7382813 h 2.5351563 c 0.6158427,10e-8 1.1308781,0.024014 1.5410156,0.072266 a 0.45464204,0.45464204 0 0 0 0.00781,0.00195 c 0.3978583,0.040363 0.7146715,0.1305664 0.9589841,0.2578125 0.397607,0.2072036 0.628939,0.4341652 0.748047,0.6679688 0.125714,0.2467732 0.208984,0.6369656 0.208985,1.1679686 0,0.456188 -0.0779,0.797942 -0.199219,1.03125 -0.126867,0.243974 -0.330997,0.472211 -0.638672,0.6875 -0.2710781,0.184129 -0.6425631,0.3265 -1.1269532,0.408203 -0.4954847,0.07724 -1.1554071,0.119141 -1.9707032,0.119141 H 4.9609375 Z" /><path
|
||||
id="path902"
|
||||
style="font-size:19.6818px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#808080;fill-opacity:1;stroke-width:1"
|
||||
sodipodi:type="inkscape:offset"
|
||||
inkscape:radius="-0.27482691"
|
||||
inkscape:original="M 2.6035156 0.84570312 L 2.6035156 15.154297 L 7.6777344 15.154297 C 8.670794 15.154297 9.4882228 15.06611 10.128906 14.886719 C 10.775997 14.707327 11.368076 14.405273 11.90625 13.982422 C 12.361135 13.630046 12.7231 13.1813 12.992188 12.636719 C 13.261275 12.092137 13.396484 11.465065 13.396484 10.753906 C 13.396484 9.7608469 13.117942 8.9400592 12.560547 8.2929688 C 12.003152 7.6394714 11.24087 7.2142369 10.273438 7.015625 L 10.273438 6.9375 C 10.850053 6.6491924 11.310281 6.2690278 11.65625 5.7949219 C 12.002219 5.3144092 12.175781 4.7338122 12.175781 4.0546875 C 12.175781 3.4524449 12.057366 2.9370705 11.820312 2.5078125 C 11.58326 2.0721476 11.201142 1.7169002 10.675781 1.4414062 C 10.201675 1.1979465 9.7064537 1.0378196 9.1875 0.9609375 C 8.6685463 0.88405547 7.8861111 0.84570312 6.8417969 0.84570312 L 2.6035156 0.84570312 z M 4.5058594 2.46875 L 6.7753906 2.46875 C 7.4096674 2.46875 7.9398826 2.4922615 8.3691406 2.5371094 C 8.7983987 2.5755504 9.1637225 2.6805311 9.4648438 2.8535156 C 9.7211172 3.0008729 9.9081142 3.1926346 10.023438 3.4296875 C 10.13876 3.6667404 10.195312 3.9587184 10.195312 4.3046875 C 10.195312 4.7211321 10.132043 5.0830969 10.003906 5.390625 C 9.8821764 5.6917463 9.6702619 5.9386543 9.3691406 6.1308594 C 9.0680193 6.3230648 8.7410479 6.451557 8.3886719 6.515625 C 8.0362959 6.5732863 7.5626326 6.6015625 6.9667969 6.6015625 L 4.5058594 6.6015625 L 4.5058594 2.46875 z M 4.5058594 8.2070312 L 7.4960938 8.2070312 C 8.1239637 8.2070313 8.6541789 8.2319485 9.0898438 8.2832031 C 9.5319154 8.328051 9.9073154 8.431626 10.214844 8.5917969 C 10.669729 8.8288499 10.983265 9.1155159 11.15625 9.4550781 C 11.329234 9.7946405 11.416016 10.253463 11.416016 10.830078 C 11.416016 11.336218 11.332593 11.74997 11.166016 12.070312 C 10.999438 12.390654 10.737689 12.675915 10.378906 12.925781 C 10.039344 13.156427 9.604033 13.316555 9.0722656 13.40625 C 8.5404982 13.489539 7.8582794 13.53125 7.0253906 13.53125 L 4.5058594 13.53125 L 4.5058594 8.2070312 z "
|
||||
d="M 2.8789062,1.1210938 V 14.878906 h 4.7988282 c 0.9767892,0 1.7721974,-0.08653 2.3769536,-0.255859 a 0.2748544,0.2748544 0 0 1 0,-0.002 c 0.612147,-0.169705 1.17047,-0.453836 1.68164,-0.855469 a 0.2748544,0.2748544 0 0 1 0.002,0 c 0.421383,-0.326424 0.755523,-0.739416 1.007813,-1.25 0.248167,-0.502244 0.375,-1.085394 0.375,-1.761719 0,-0.9416683 -0.257589,-1.686926 -0.769532,-2.2812498 a 0.2748544,0.2748544 0 0 1 0,-0.00195 C 11.836252,7.8665458 11.138343,7.4739468 10.21875,7.2851562 A 0.2748544,0.2748544 0 0 1 9.9980469,7.015625 V 6.9375 A 0.2748544,0.2748544 0 0 1 10.150391,6.6914062 C 10.692415,6.420394 11.114897,6.0710997 11.433594,5.6347656 v -0.00195 c 0.309421,-0.4304071 0.466797,-0.9465219 0.466797,-1.578125 0,-0.5662177 -0.109537,-1.0323894 -0.320313,-1.4140625 a 0.2748544,0.2748544 0 0 1 -0.002,-0.00195 C 11.370578,2.2572318 11.037782,1.941225 10.550781,1.6855469 h -0.002 C 10.100864,1.4557345 9.6351721,1.3048201 9.1464844,1.2324219 8.6540374,1.1594668 7.8793824,1.1210938 6.8417969,1.1210938 Z m 1.6269532,1.0722656 h 2.2695312 c 0.6395284,0 1.177097,0.024285 1.6191406,0.070312 0.4597353,0.04117 0.8643036,0.1546764 1.2070313,0.3515625 0.2955099,0.1699183 0.5289775,0.4036426 0.6699215,0.6933594 0.138696,0.2850992 0.199219,0.6201759 0.199219,0.9960937 0,0.4442803 -0.06766,0.8428528 -0.212891,1.1914063 C 10.113991,5.8508703 9.8588815,6.145428 9.5175781,6.3632812 9.1872264,6.5741444 8.8240657,6.714872 8.4375,6.7851562 a 0.2748544,0.2748544 0 0 1 -0.00391,0.00195 C 8.0566143,6.8487967 7.5713274,6.8769531 6.9667969,6.8769531 H 4.5058594 A 0.2748544,0.2748544 0 0 1 4.2304688,6.6015625 V 2.46875 A 0.2748544,0.2748544 0 0 1 4.5058594,2.1933594 Z m 0,5.7382812 h 2.9902344 c 0.6351409,1e-7 1.1739024,0.025055 1.625,0.078125 0.4670616,0.047792 0.8759822,0.1583488 1.2207032,0.3378906 0.489513,0.2550985 0.853037,0.5789232 1.058594,0.9824219 0.201561,0.3956582 0.291015,0.8958099 0.291015,1.4999999 0,0.536338 -0.08731,0.994229 -0.28125,1.367188 -0.190134,0.365642 -0.487159,0.683022 -0.875,0.953125 a 0.2748544,0.2748544 0 0 1 -0.002,0.002 c -0.380964,0.258768 -0.8556061,0.430864 -1.4160155,0.52539 a 0.2748544,0.2748544 0 0 1 -0.00195,0 C 8.5618237,13.764413 7.867455,13.806641 7.0253906,13.806641 H 4.5058594 A 0.2748544,0.2748544 0 0 1 4.2304688,13.53125 V 8.2070312 A 0.2748544,0.2748544 0 0 1 4.5058594,7.9316406 Z" /></g></svg>
|
After Width: | Height: | Size: 10 KiB |
59
resources/icons/make_italic.svg
Normal file
59
resources/icons/make_italic.svg
Normal file
@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.0"
|
||||
id="Layer_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 16 16"
|
||||
enable-background="new 0 0 16 16"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="make_italic.svg"
|
||||
inkscape:version="1.0.2 (e86c870879, 2021-01-15, custom)"><metadata
|
||||
id="metadata12"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs10" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1137"
|
||||
id="namedview8"
|
||||
showgrid="false"
|
||||
inkscape:zoom="15.4375"
|
||||
inkscape:cx="0.67826831"
|
||||
inkscape:cy="4.6692471"
|
||||
inkscape:window-x="1912"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Layer_1"
|
||||
inkscape:document-rotation="0" />
|
||||
|
||||
<g
|
||||
id="g854"><g
|
||||
aria-label="I"
|
||||
id="text839"
|
||||
style="font-size:19.57px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#808080;fill-opacity:1;stroke-width:1"><path
|
||||
d="M 10.809365,15.114192 H 5.1906348 V 13.661731 H 7.0539892 V 2.3382694 H 5.1906348 V 0.88580844 H 10.809365 V 2.3382694 H 8.9460107 V 13.661731 h 1.8633543 z"
|
||||
style="stroke-width:1"
|
||||
id="path833" /></g><g
|
||||
aria-label="I"
|
||||
id="text843"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:19.57px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif Italic';letter-spacing:0px;word-spacing:0px;fill:#ed6b21;fill-opacity:1;stroke-width:1"
|
||||
transform="translate(1.511197,0.1335218)"><path
|
||||
d="M 9.3172795,14.98067 H 3.6794378 L 3.9947747,13.514127 H 5.8581291 L 8.5146037,2.2107322 H 6.6512492 L 6.9665861,0.75228641 H 12.604428 L 12.289091,2.2107322 H 10.425736 L 7.7692619,13.514127 h 1.8633545 z"
|
||||
style="stroke-width:1"
|
||||
id="path855"
|
||||
sodipodi:nodetypes="ccccccccccccc" /></g></g></svg>
|
After Width: | Height: | Size: 2.5 KiB |
56
resources/icons/make_unbold.svg
Normal file
56
resources/icons/make_unbold.svg
Normal file
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.0"
|
||||
id="Layer_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 16 16"
|
||||
enable-background="new 0 0 16 16"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="make_unbold.svg"
|
||||
inkscape:version="1.0.2 (e86c870879, 2021-01-15, custom)"><metadata
|
||||
id="metadata12"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs10" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1536"
|
||||
inkscape:window-height="801"
|
||||
id="namedview8"
|
||||
showgrid="false"
|
||||
inkscape:zoom="21.831922"
|
||||
inkscape:cx="2.9625479"
|
||||
inkscape:cy="9.2332946"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="121"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Layer_1" />
|
||||
|
||||
<g
|
||||
id="g919"><path
|
||||
id="path905"
|
||||
style="font-size:19.6818px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#808080;fill-opacity:1;stroke-width:1"
|
||||
sodipodi:type="inkscape:offset"
|
||||
inkscape:radius="0.45459658"
|
||||
inkscape:original="M 2.6035156 0.84570312 L 2.6035156 15.154297 L 7.6777344 15.154297 C 8.670794 15.154297 9.4882228 15.06611 10.128906 14.886719 C 10.775997 14.707327 11.368076 14.405273 11.90625 13.982422 C 12.361135 13.630046 12.7231 13.1813 12.992188 12.636719 C 13.261275 12.092137 13.396484 11.465065 13.396484 10.753906 C 13.396484 9.7608469 13.117942 8.9400592 12.560547 8.2929688 C 12.003152 7.6394714 11.24087 7.2142369 10.273438 7.015625 L 10.273438 6.9375 C 10.850053 6.6491924 11.310281 6.2690278 11.65625 5.7949219 C 12.002219 5.3144092 12.175781 4.7338122 12.175781 4.0546875 C 12.175781 3.4524449 12.057366 2.9370705 11.820312 2.5078125 C 11.58326 2.0721476 11.201142 1.7169002 10.675781 1.4414062 C 10.201675 1.1979465 9.7064537 1.0378196 9.1875 0.9609375 C 8.6685463 0.88405547 7.8861111 0.84570312 6.8417969 0.84570312 L 2.6035156 0.84570312 z M 4.5058594 2.46875 L 6.7753906 2.46875 C 7.4096674 2.46875 7.9398826 2.4922615 8.3691406 2.5371094 C 8.7983987 2.5755504 9.1637225 2.6805311 9.4648438 2.8535156 C 9.7211172 3.0008729 9.9081142 3.1926346 10.023438 3.4296875 C 10.13876 3.6667404 10.195312 3.9587184 10.195312 4.3046875 C 10.195312 4.7211321 10.132043 5.0830969 10.003906 5.390625 C 9.8821764 5.6917463 9.6702619 5.9386543 9.3691406 6.1308594 C 9.0680193 6.3230648 8.7410479 6.451557 8.3886719 6.515625 C 8.0362959 6.5732863 7.5626326 6.6015625 6.9667969 6.6015625 L 4.5058594 6.6015625 L 4.5058594 2.46875 z M 4.5058594 8.2070312 L 7.4960938 8.2070312 C 8.1239637 8.2070313 8.6541789 8.2319485 9.0898438 8.2832031 C 9.5319154 8.328051 9.9073154 8.431626 10.214844 8.5917969 C 10.669729 8.8288499 10.983265 9.1155159 11.15625 9.4550781 C 11.329234 9.7946405 11.416016 10.253463 11.416016 10.830078 C 11.416016 11.336218 11.332593 11.74997 11.166016 12.070312 C 10.999438 12.390654 10.737689 12.675915 10.378906 12.925781 C 10.039344 13.156427 9.604033 13.316555 9.0722656 13.40625 C 8.5404982 13.489539 7.8582794 13.53125 7.0253906 13.53125 L 4.5058594 13.53125 L 4.5058594 8.2070312 z "
|
||||
d="M 2.6035156,0.390625 A 0.45464204,0.45464204 0 0 0 2.1484375,0.84570312 V 15.154297 a 0.45464204,0.45464204 0 0 0 0.4550781,0.455078 h 5.0742188 c 1.0192082,0 1.8724488,-0.08943 2.5722656,-0.285156 0.704041,-0.19518 1.353249,-0.525333 1.935547,-0.982422 l 0.002,-0.002 c 0.509285,-0.395061 0.916438,-0.901991 1.212891,-1.501953 0.303691,-0.614615 0.451172,-1.315206 0.451171,-2.083985 0,-1.0770667 -0.313909,-2.0217764 -0.945312,-2.7558591 l -0.002,-0.00195 C 12.461534,7.4777218 11.86388,7.1351112 11.203125,6.875 11.514504,6.637151 11.796619,6.3733249 12.023438,6.0625 a 0.45464204,0.45464204 0 0 0 0.002,-0.00195 c 0.405303,-0.5629213 0.605468,-1.2492814 0.605468,-2.0058594 0,-0.6618322 -0.131587,-1.259609 -0.412109,-1.7675781 v 0.00391 C 11.93326,1.7663287 11.474136,1.347098 10.886719,1.0390625 a 0.45464204,0.45464204 0 0 0 -0.0039,-0.00195 C 10.366329,0.77188829 9.821904,0.59586664 9.2539062,0.51171875 8.6911072,0.42834112 7.8972411,0.390625 6.8417969,0.390625 Z m 2.3574219,2.5332031 h 1.8144531 c 0.6230428,0 1.1397643,0.021919 1.546875,0.064453 a 0.45464204,0.45464204 0 0 0 0.00586,0.00195 c 0.3788452,0.033926 0.6778569,0.124364 0.9101562,0.2578125 0.1913715,0.1100386 0.3040086,0.2309187 0.3769532,0.3808593 0.076659,0.1575785 0.125,0.379351 0.125,0.6757813 0,0.3704011 -0.056389,0.670489 -0.15625,0.9101563 a 0.45464204,0.45464204 0 0 0 -0.00195,0.00586 C 9.4966472,5.4319168 9.3588253,5.5987966 9.125,5.7480469 8.8745265,5.9079238 8.6070974,6.0121766 8.3144531,6.0664062 c -9.002e-4,1.474e-4 -0.003,-1.469e-4 -0.00391,0 -0.3116061,0.050728 -0.7639761,0.080078 -1.34375,0.080078 H 4.9609375 Z m 0,5.7382813 h 2.5351563 c 0.6158427,10e-8 1.1308781,0.024014 1.5410156,0.072266 a 0.45464204,0.45464204 0 0 0 0.00781,0.00195 c 0.3978583,0.040363 0.7146715,0.1305664 0.9589841,0.2578125 0.397607,0.2072036 0.628939,0.4341652 0.748047,0.6679688 0.125714,0.2467732 0.208984,0.6369656 0.208985,1.1679686 0,0.456188 -0.0779,0.797942 -0.199219,1.03125 -0.126867,0.243974 -0.330997,0.472211 -0.638672,0.6875 -0.2710781,0.184129 -0.6425631,0.3265 -1.1269532,0.408203 -0.4954847,0.07724 -1.1554071,0.119141 -1.9707032,0.119141 H 4.9609375 Z" /><path
|
||||
id="path902"
|
||||
style="font-size:19.6818px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ed6b21;fill-opacity:1;stroke-width:1"
|
||||
sodipodi:type="inkscape:offset"
|
||||
inkscape:radius="-0.27482691"
|
||||
inkscape:original="M 2.6035156 0.84570312 L 2.6035156 15.154297 L 7.6777344 15.154297 C 8.670794 15.154297 9.4882228 15.06611 10.128906 14.886719 C 10.775997 14.707327 11.368076 14.405273 11.90625 13.982422 C 12.361135 13.630046 12.7231 13.1813 12.992188 12.636719 C 13.261275 12.092137 13.396484 11.465065 13.396484 10.753906 C 13.396484 9.7608469 13.117942 8.9400592 12.560547 8.2929688 C 12.003152 7.6394714 11.24087 7.2142369 10.273438 7.015625 L 10.273438 6.9375 C 10.850053 6.6491924 11.310281 6.2690278 11.65625 5.7949219 C 12.002219 5.3144092 12.175781 4.7338122 12.175781 4.0546875 C 12.175781 3.4524449 12.057366 2.9370705 11.820312 2.5078125 C 11.58326 2.0721476 11.201142 1.7169002 10.675781 1.4414062 C 10.201675 1.1979465 9.7064537 1.0378196 9.1875 0.9609375 C 8.6685463 0.88405547 7.8861111 0.84570312 6.8417969 0.84570312 L 2.6035156 0.84570312 z M 4.5058594 2.46875 L 6.7753906 2.46875 C 7.4096674 2.46875 7.9398826 2.4922615 8.3691406 2.5371094 C 8.7983987 2.5755504 9.1637225 2.6805311 9.4648438 2.8535156 C 9.7211172 3.0008729 9.9081142 3.1926346 10.023438 3.4296875 C 10.13876 3.6667404 10.195312 3.9587184 10.195312 4.3046875 C 10.195312 4.7211321 10.132043 5.0830969 10.003906 5.390625 C 9.8821764 5.6917463 9.6702619 5.9386543 9.3691406 6.1308594 C 9.0680193 6.3230648 8.7410479 6.451557 8.3886719 6.515625 C 8.0362959 6.5732863 7.5626326 6.6015625 6.9667969 6.6015625 L 4.5058594 6.6015625 L 4.5058594 2.46875 z M 4.5058594 8.2070312 L 7.4960938 8.2070312 C 8.1239637 8.2070313 8.6541789 8.2319485 9.0898438 8.2832031 C 9.5319154 8.328051 9.9073154 8.431626 10.214844 8.5917969 C 10.669729 8.8288499 10.983265 9.1155159 11.15625 9.4550781 C 11.329234 9.7946405 11.416016 10.253463 11.416016 10.830078 C 11.416016 11.336218 11.332593 11.74997 11.166016 12.070312 C 10.999438 12.390654 10.737689 12.675915 10.378906 12.925781 C 10.039344 13.156427 9.604033 13.316555 9.0722656 13.40625 C 8.5404982 13.489539 7.8582794 13.53125 7.0253906 13.53125 L 4.5058594 13.53125 L 4.5058594 8.2070312 z "
|
||||
d="M 2.8789062,1.1210938 V 14.878906 h 4.7988282 c 0.9767892,0 1.7721974,-0.08653 2.3769536,-0.255859 a 0.2748544,0.2748544 0 0 1 0,-0.002 c 0.612147,-0.169705 1.17047,-0.453836 1.68164,-0.855469 a 0.2748544,0.2748544 0 0 1 0.002,0 c 0.421383,-0.326424 0.755523,-0.739416 1.007813,-1.25 0.248167,-0.502244 0.375,-1.085394 0.375,-1.761719 0,-0.9416683 -0.257589,-1.686926 -0.769532,-2.2812498 a 0.2748544,0.2748544 0 0 1 0,-0.00195 C 11.836252,7.8665458 11.138343,7.4739468 10.21875,7.2851562 A 0.2748544,0.2748544 0 0 1 9.9980469,7.015625 V 6.9375 A 0.2748544,0.2748544 0 0 1 10.150391,6.6914062 C 10.692415,6.420394 11.114897,6.0710997 11.433594,5.6347656 v -0.00195 c 0.309421,-0.4304071 0.466797,-0.9465219 0.466797,-1.578125 0,-0.5662177 -0.109537,-1.0323894 -0.320313,-1.4140625 a 0.2748544,0.2748544 0 0 1 -0.002,-0.00195 C 11.370578,2.2572318 11.037782,1.941225 10.550781,1.6855469 h -0.002 C 10.100864,1.4557345 9.6351721,1.3048201 9.1464844,1.2324219 8.6540374,1.1594668 7.8793824,1.1210938 6.8417969,1.1210938 Z m 1.6269532,1.0722656 h 2.2695312 c 0.6395284,0 1.177097,0.024285 1.6191406,0.070312 0.4597353,0.04117 0.8643036,0.1546764 1.2070313,0.3515625 0.2955099,0.1699183 0.5289775,0.4036426 0.6699215,0.6933594 0.138696,0.2850992 0.199219,0.6201759 0.199219,0.9960937 0,0.4442803 -0.06766,0.8428528 -0.212891,1.1914063 C 10.113991,5.8508703 9.8588815,6.145428 9.5175781,6.3632812 9.1872264,6.5741444 8.8240657,6.714872 8.4375,6.7851562 a 0.2748544,0.2748544 0 0 1 -0.00391,0.00195 C 8.0566143,6.8487967 7.5713274,6.8769531 6.9667969,6.8769531 H 4.5058594 A 0.2748544,0.2748544 0 0 1 4.2304688,6.6015625 V 2.46875 A 0.2748544,0.2748544 0 0 1 4.5058594,2.1933594 Z m 0,5.7382812 h 2.9902344 c 0.6351409,1e-7 1.1739024,0.025055 1.625,0.078125 0.4670616,0.047792 0.8759822,0.1583488 1.2207032,0.3378906 0.489513,0.2550985 0.853037,0.5789232 1.058594,0.9824219 0.201561,0.3956582 0.291015,0.8958099 0.291015,1.4999999 0,0.536338 -0.08731,0.994229 -0.28125,1.367188 -0.190134,0.365642 -0.487159,0.683022 -0.875,0.953125 a 0.2748544,0.2748544 0 0 1 -0.002,0.002 c -0.380964,0.258768 -0.8556061,0.430864 -1.4160155,0.52539 a 0.2748544,0.2748544 0 0 1 -0.00195,0 C 8.5618237,13.764413 7.867455,13.806641 7.0253906,13.806641 H 4.5058594 A 0.2748544,0.2748544 0 0 1 4.2304688,13.53125 V 8.2070312 A 0.2748544,0.2748544 0 0 1 4.5058594,7.9316406 Z" /></g></svg>
|
After Width: | Height: | Size: 10 KiB |
59
resources/icons/make_unitalic.svg
Normal file
59
resources/icons/make_unitalic.svg
Normal file
@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.0"
|
||||
id="Layer_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 16 16"
|
||||
enable-background="new 0 0 16 16"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="make_unitalic.svg"
|
||||
inkscape:version="1.0.2 (e86c870879, 2021-01-15, custom)"><metadata
|
||||
id="metadata12"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs10" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1137"
|
||||
id="namedview8"
|
||||
showgrid="false"
|
||||
inkscape:zoom="21.831922"
|
||||
inkscape:cx="4.887467"
|
||||
inkscape:cy="9.9983351"
|
||||
inkscape:window-x="1912"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Layer_1"
|
||||
inkscape:document-rotation="0" />
|
||||
|
||||
<g
|
||||
id="g840"><g
|
||||
aria-label="I"
|
||||
id="text843"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:19.57px;line-height:1.25;font-family:sans-serif;-inkscape-font-specification:'sans-serif Italic';letter-spacing:0px;word-spacing:0px;fill:#808080;fill-opacity:1;stroke-width:1"
|
||||
transform="translate(1.511197,0.1335218)"><path
|
||||
d="M 9.3172795,14.98067 H 3.6794378 L 3.9947747,13.514127 H 5.8581291 L 8.5146037,2.2107322 H 6.6512492 L 6.9665861,0.75228641 H 12.604428 L 12.289091,2.2107322 H 10.425736 L 7.7692619,13.514127 h 1.8633545 z"
|
||||
style="stroke-width:1;fill:#808080;fill-opacity:1"
|
||||
id="path855"
|
||||
sodipodi:nodetypes="ccccccccccccc" /></g><g
|
||||
aria-label="I"
|
||||
id="text839"
|
||||
style="font-size:19.57px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ed6b21;fill-opacity:1;stroke-width:1"><path
|
||||
d="M 10.809365,15.114192 H 5.1906348 V 13.661731 H 7.0539892 V 2.3382694 H 5.1906348 V 0.88580844 H 10.809365 V 2.3382694 H 8.9460107 V 13.661731 h 1.8633543 z"
|
||||
style="fill:#ed6b21;fill-opacity:1;stroke-width:1"
|
||||
id="path833" /></g></g></svg>
|
After Width: | Height: | Size: 2.6 KiB |
@ -1,4 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24px" height="24px">
|
||||
<path fill="#808080" d="M 13.261719 14.867188 L 15.742188 17.347656 C 15.363281 18.070313 15.324219 18.789063 15.722656 19.1875 L 20.25 23.714844 C 20.820313 24.285156 22.0625 23.972656 23.015625 23.015625 C 23.972656 22.058594 24.285156 20.820313 23.714844 20.25 L 19.191406 15.722656 C 18.789063 15.324219 18.070313 15.363281 17.347656 15.738281 L 14.867188 13.261719 Z M 8.5 0 C 3.804688 0 0 3.804688 0 8.5 C 0 13.195313 3.804688 17 8.5 17 C 13.195313 17 17 13.195313 17 8.5 C 17 3.804688 13.195313 0 8.5 0 Z M 8.5 15 C 4.910156 15 2 12.089844 2 8.5 C 2 4.910156 4.910156 2 8.5 2 C 12.089844 2 15 4.910156 15 8.5 C 15 12.089844 12.089844 15 8.5 15 Z"/>
|
||||
<path fill="#ED6B21" d="M 13.261719 14.867188 L 19.191406 15.722656 C 18.789063 15.324219 18.070313 15.363281 17.347656 15.738281 M 8.5 0 C 3.804688 0 0 3.804688 0 8.5 C 0 13.195313 3.804688 17 8.5 17 C 13.195313 17 17 13.195313 17 8.5 C 17 3.804688 13.195313 0 8.5 0 Z M 8.5 15 C 4.910156 15 2 12.089844 2 8.5 C 2 4.910156 4.910156 2 8.5 2 C 12.089844 2 15 4.910156 15 8.5 C 15 12.089844 12.089844 15 8.5 15 Z"/>
|
||||
<path fill="#ED6B21" d="M 8.5,0 C 3.804688,0 0,3.804688 0,8.5 0,13.195313 3.804688,17 8.5,17 13.195313,17 17,13.195313 17,8.5 17,3.804688 13.195313,0 8.5,0 Z m 0,15 C 4.910156,15 2,12.089844 2,8.5 2,4.910156 4.910156,2 8.5,2 12.089844,2 15,4.910156 15,8.5 15,12.089844 12.089844,15 8.5,15 Z"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.0 KiB |
@ -36,6 +36,11 @@
|
||||
|
||||
// uncomment for easier debug
|
||||
//#define ALLOW_DEBUG_MODE
|
||||
#ifdef ALLOW_DEBUG_MODE
|
||||
#define ALLOW_ADD_FONT_BY_FILE
|
||||
#endif // ALLOW_DEBUG_MODE
|
||||
#define ALLOW_ADD_FONT_BY_OS_SELECTOR
|
||||
|
||||
|
||||
using namespace Slic3r;
|
||||
using namespace Slic3r::GUI;
|
||||
@ -66,12 +71,9 @@ void GLGizmoEmboss::set_fine_position()
|
||||
const Camera &camera = wxGetApp().plater()->get_camera();
|
||||
Polygon hull = CameraUtils::create_hull2d(camera, *volume);
|
||||
|
||||
// TODO: fix width - showing scroll in first draw of advanced.
|
||||
ImVec2 windows_size = m_gui_cfg->draw_advanced ?
|
||||
m_gui_cfg->minimal_window_size_with_advance :
|
||||
m_gui_cfg->minimal_window_size;
|
||||
const ImVec2 &windows_size = get_minimal_window_size();
|
||||
ImVec2 offset = ImGuiWrapper::suggest_location(windows_size, hull);
|
||||
m_gui_cfg->offset = offset;
|
||||
m_set_window_offset = offset;
|
||||
return;
|
||||
|
||||
Polygon rect({Point(offset.x, offset.y),
|
||||
@ -214,7 +216,6 @@ bool GLGizmoEmboss::on_mouse_for_translate(const wxMouseEvent &mouse_event)
|
||||
ModelVolume *mv = m_volume;
|
||||
wxGetApp().plater()->CallAfter([trmat, mv]() {
|
||||
mv->set_transformation(trmat);
|
||||
mv->set_new_unique_id();
|
||||
});
|
||||
|
||||
m_parent.toggle_model_objects_visibility(true);
|
||||
@ -252,6 +253,7 @@ std::string GLGizmoEmboss::on_get_name() const { return _u8L("Emboss"); }
|
||||
void GLGizmoEmboss::on_render() {
|
||||
// no volume selected
|
||||
if (m_volume == nullptr) return;
|
||||
if (m_parent.get_selection().is_empty()) return;
|
||||
|
||||
if (m_temp_transformation.has_value()) {
|
||||
// draw text volume on temporary position
|
||||
@ -289,12 +291,9 @@ void GLGizmoEmboss::on_render_input_window(float x, float y, float bottom_limit)
|
||||
initialize();
|
||||
check_selection();
|
||||
|
||||
ImVec2 min_window_size = m_gui_cfg->draw_advanced ?
|
||||
m_gui_cfg->minimal_window_size_with_advance :
|
||||
m_gui_cfg->minimal_window_size;
|
||||
// TODO: fix width - showing scroll in first draw of advanced.
|
||||
const ImVec2 &min_window_size = get_minimal_window_size();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, min_window_size);
|
||||
// ImGui::SetNextWindowSize(ImVec2(0, min_window_size.y),
|
||||
// ImGuiCond_::ImGuiCond_Always);
|
||||
|
||||
#ifdef ALLOW_DEBUG_MODE
|
||||
// draw suggested position of window
|
||||
@ -302,19 +301,21 @@ void GLGizmoEmboss::on_render_input_window(float x, float y, float bottom_limit)
|
||||
#endif // ALLOW_DEBUG_MODE
|
||||
|
||||
// check if is set window offset
|
||||
if (m_gui_cfg->offset.has_value()) {
|
||||
ImGui::SetNextWindowPos(*m_gui_cfg->offset, ImGuiCond_Always);
|
||||
// clear request on offset
|
||||
m_gui_cfg->offset = {};
|
||||
if (m_set_window_offset.has_value()) {
|
||||
ImGui::SetNextWindowPos(*m_set_window_offset, ImGuiCond_Always);
|
||||
m_set_window_offset.reset();
|
||||
}
|
||||
|
||||
int flag = // ImGuiWindowFlags_AlwaysAutoResize |
|
||||
// ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoCollapse;
|
||||
m_imgui->begin(on_get_name(), flag);
|
||||
ImGuiWindowFlags flag = //ImGuiWindowFlags_AlwaysAutoResize
|
||||
//ImGuiWindowFlags_NoResize
|
||||
ImGuiWindowFlags_NoCollapse
|
||||
;
|
||||
bool is_open = true;
|
||||
ImGui::Begin(on_get_name().c_str(), &is_open, flag);
|
||||
draw_window();
|
||||
m_imgui->end();
|
||||
ImGui::End();
|
||||
|
||||
if (!is_open) close();
|
||||
ImGui::PopStyleVar(); // WindowMinSize
|
||||
}
|
||||
|
||||
@ -388,43 +389,63 @@ void GLGizmoEmboss::initialize()
|
||||
{
|
||||
if (m_is_initialized) return;
|
||||
m_is_initialized = true;
|
||||
m_gui_cfg.emplace(GuiCfg());
|
||||
float space = ImGui::GetTextLineHeightWithSpacing() -
|
||||
ImGui::GetTextLineHeight();
|
||||
m_gui_cfg->max_font_name_width = ImGui::CalcTextSize("Maximal font name").x;
|
||||
m_gui_cfg->icon_width = ImGui::GetTextLineHeight();
|
||||
float icon_width_with_spacing = m_gui_cfg->icon_width + space;
|
||||
|
||||
float scroll_width = icon_width_with_spacing; // fix
|
||||
m_gui_cfg->combo_font_width = m_gui_cfg->max_font_name_width + space
|
||||
+ 3 * icon_width_with_spacing
|
||||
GuiCfg cfg; // initialize by default values;
|
||||
|
||||
float line_height = ImGui::GetTextLineHeight();
|
||||
float line_height_with_spacing = ImGui::GetTextLineHeightWithSpacing();
|
||||
float space = line_height_with_spacing - line_height;
|
||||
|
||||
cfg.max_font_name_width = ImGui::CalcTextSize("Maximal font name").x;
|
||||
cfg.icon_width = line_height;
|
||||
float icon_width_with_spacing = cfg.icon_width + space;
|
||||
float scroll_width = icon_width_with_spacing; // TODO: fix it
|
||||
cfg.combo_font_width = cfg.max_font_name_width + space
|
||||
+ icon_width_with_spacing
|
||||
+ scroll_width;
|
||||
|
||||
m_gui_cfg->duplicate_pos_x = m_gui_cfg->max_font_name_width + space;
|
||||
m_gui_cfg->rename_pos_x = m_gui_cfg->duplicate_pos_x +
|
||||
icon_width_with_spacing;
|
||||
m_gui_cfg->delete_pos_x = m_gui_cfg->rename_pos_x +
|
||||
icon_width_with_spacing;
|
||||
|
||||
m_gui_cfg->text_size = ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() *
|
||||
m_gui_cfg->count_line_of_text);
|
||||
|
||||
cfg.delete_pos_x = cfg.max_font_name_width + space;
|
||||
int count_line_of_text = 3;
|
||||
cfg.text_size = ImVec2(-FLT_MIN, line_height_with_spacing * count_line_of_text);
|
||||
ImVec2 letter_m_size = ImGui::CalcTextSize("M");
|
||||
|
||||
m_gui_cfg->advanced_input_width = letter_m_size.x * 6;
|
||||
int count_letter_M_in_input = 6;
|
||||
cfg.advanced_input_width = letter_m_size.x * count_letter_M_in_input;
|
||||
GuiCfg::Translations &tr = cfg.translations;
|
||||
tr.font = _u8L("Font");
|
||||
tr.size = _u8L("Height");
|
||||
tr.depth = _u8L("Depth");
|
||||
cfg.style_edit_text_width =
|
||||
3 * space + ImGui::GetTreeNodeToLabelSpacing() +
|
||||
std::max(ImGui::CalcTextSize(tr.font.c_str()).x,
|
||||
std::max(ImGui::CalcTextSize(tr.size.c_str()).x,
|
||||
ImGui::CalcTextSize(tr.depth.c_str()).x));
|
||||
|
||||
// calculate window size
|
||||
const ImGuiStyle &style = ImGui::GetStyle();
|
||||
float input_height = letter_m_size.y + style.FramePadding.y * 2.f;
|
||||
float window_width = m_gui_cfg->combo_font_width + style.WindowPadding.x * 2.f;
|
||||
float window_height = input_height * 4.f + // header + combo font + advance + button
|
||||
style.ItemSpacing.y * 3.f +
|
||||
m_gui_cfg->text_size.y +
|
||||
style.WindowPadding.y * 2.f;
|
||||
m_gui_cfg->minimal_window_size = ImVec2(window_width, window_height);
|
||||
float advance_height = (input_height + style.ItemSpacing.y) * 6.f;
|
||||
m_gui_cfg->minimal_window_size_with_advance =
|
||||
ImVec2(window_width, window_height + advance_height);
|
||||
float window_title = line_height + 2*style.FramePadding.y;// 21
|
||||
float input_height = line_height_with_spacing + 2*style.FramePadding.y; // 25
|
||||
float tree_header = line_height_with_spacing; // 19
|
||||
float window_height =
|
||||
window_title + // window title
|
||||
cfg.text_size.y + // text field
|
||||
input_height * 3 + // type Radios + style selector + close button
|
||||
tree_header + // Edit style
|
||||
2 * style.WindowPadding.y;
|
||||
float window_width = cfg.combo_font_width + style.WindowPadding.x * 2;
|
||||
cfg.minimal_window_size = ImVec2(window_width, window_height);
|
||||
|
||||
// 94
|
||||
float addition_edit_height = input_height * 3 + tree_header;
|
||||
cfg.minimal_window_size_with_edit = ImVec2(cfg.minimal_window_size.x,
|
||||
cfg.minimal_window_size.y +
|
||||
addition_edit_height);
|
||||
|
||||
// 104
|
||||
float advance_height = input_height * 4;
|
||||
cfg.minimal_window_size_with_advance =
|
||||
ImVec2(cfg.minimal_window_size_with_edit.x,
|
||||
cfg.minimal_window_size_with_edit.y + advance_height);
|
||||
|
||||
m_gui_cfg.emplace(cfg);
|
||||
|
||||
// TODO: What to do when icon was NOT loaded? Generate them?
|
||||
bool success = init_icons();
|
||||
@ -584,20 +605,20 @@ void GLGizmoEmboss::draw_window()
|
||||
#endif // ALLOW_DEBUG_MODE
|
||||
bool exist_font_file = m_font_manager.get_font_file() != nullptr;
|
||||
if (!exist_font_file) {
|
||||
ImGui::Text("%s",_u8L("Warning: No font is selected. Select correct one.").c_str());
|
||||
m_imgui->text_colored(
|
||||
ImGuiWrapper::COL_ORANGE_LIGHT,
|
||||
_L("Warning: No font is selected. Select correct one."));
|
||||
}
|
||||
draw_font_list();
|
||||
draw_text_input();
|
||||
|
||||
bool &advanced = m_gui_cfg->draw_advanced;
|
||||
if (ImGui::Checkbox(_u8L("Advance").c_str(), &advanced)) {
|
||||
ImVec2 window_size =
|
||||
advanced ?
|
||||
ImVec2(0, m_gui_cfg->minimal_window_size_with_advance.y) :
|
||||
m_gui_cfg->minimal_window_size;
|
||||
ImGui::SetWindowSize(window_size, ImGuiCond_Always);
|
||||
}
|
||||
if (advanced) draw_advanced();
|
||||
draw_model_type();
|
||||
draw_style_list();
|
||||
if (ImGui::TreeNode(_u8L("Edit style").c_str())) {
|
||||
draw_style_edit();
|
||||
ImGui::TreePop();
|
||||
if (!m_is_edit_style)
|
||||
set_minimal_window_size(true, m_is_advanced_edit_style);
|
||||
} else if (m_is_edit_style)
|
||||
set_minimal_window_size(false, m_is_advanced_edit_style);
|
||||
|
||||
if (ImGui::Button(_u8L("Close").c_str())) close();
|
||||
|
||||
@ -618,8 +639,196 @@ void GLGizmoEmboss::draw_window()
|
||||
m_imgui->disabled_end();
|
||||
}
|
||||
|
||||
void GLGizmoEmboss::draw_text_input()
|
||||
{
|
||||
static const ImGuiInputTextFlags flags =
|
||||
ImGuiInputTextFlags_AllowTabInput | ImGuiInputTextFlags_AutoSelectAll;
|
||||
|
||||
ImFont *imgui_font = m_font_manager.get_imgui_font();
|
||||
bool exist_font = imgui_font != nullptr && imgui_font->IsLoaded();
|
||||
if (exist_font) ImGui::PushFont(imgui_font);
|
||||
|
||||
bool exist_change = false;
|
||||
float window_height = ImGui::GetWindowHeight();
|
||||
float minimal_height = get_minimal_window_size().y;
|
||||
float extra_height = window_height - minimal_height;
|
||||
ImVec2 text_size(m_gui_cfg->text_size.x,
|
||||
m_gui_cfg->text_size.y + extra_height);
|
||||
if (ImGui::InputTextMultiline("##Text", &m_text, text_size, flags)) {
|
||||
process();
|
||||
exist_change = true;
|
||||
}
|
||||
|
||||
if (exist_font) ImGui::PopFont();
|
||||
|
||||
// show warning about incorrectness view of font
|
||||
// TODO: add char gap and line gap
|
||||
std::string warning;
|
||||
const FontProp& prop = m_font_manager.get_font_prop();
|
||||
if (prop.skew.has_value())
|
||||
warning = prop.boldness.has_value() ?
|
||||
_u8L("Italic & Bold is NOT shown") :
|
||||
_u8L("Italic is NOT shown");
|
||||
else if (prop.boldness.has_value())
|
||||
warning = _u8L("Boldness is NOT shown");
|
||||
|
||||
if (!warning.empty()) {
|
||||
ImVec2 cursor = ImGui::GetCursorPos();
|
||||
float width = ImGui::GetContentRegionAvailWidth();
|
||||
ImVec2 size = ImGui::CalcTextSize(warning.c_str());
|
||||
ImVec2 padding = ImGui::GetStyle().FramePadding;
|
||||
ImGui::SetCursorPos(ImVec2(width - size.x + padding.x,
|
||||
cursor.y - size.y - padding.y));
|
||||
m_imgui->text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, warning);
|
||||
ImGui::SetCursorPos(cursor);
|
||||
}
|
||||
|
||||
// Extend font ranges
|
||||
// imgui_font has to be unused
|
||||
if (exist_change) m_font_manager.get_imgui_font(m_text);
|
||||
}
|
||||
|
||||
void GLGizmoEmboss::draw_font_list()
|
||||
{
|
||||
if (ImGui::BeginCombo("##font_selector", "Actual selected font")) {
|
||||
std::vector<int> fonts = {1, 3, 5, 8};
|
||||
for (const auto &item : fonts) {
|
||||
size_t index = &item - &fonts.front();
|
||||
ImGui::PushID(index);
|
||||
|
||||
bool is_selected = false;
|
||||
ImGuiSelectableFlags_ flags =
|
||||
ImGuiSelectableFlags_AllowItemOverlap; // allow click buttons
|
||||
if (ImGui::Selectable(("font name" + std::to_string(item)).c_str(),
|
||||
is_selected)) {
|
||||
// Select font
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
#ifdef ALLOW_ADD_FONT_BY_FILE
|
||||
ImGui::SameLine();
|
||||
// select font file by file browser
|
||||
if (draw_button(IconType::open_file)) {
|
||||
choose_true_type_file();
|
||||
} else if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", _u8L("add file with font(.ttf, .ttc)").c_str());
|
||||
#endif // ALLOW_ADD_FONT_BY_FILE
|
||||
|
||||
#ifdef ALLOW_ADD_FONT_BY_OS_SELECTOR
|
||||
ImGui::SameLine();
|
||||
if (draw_button(IconType::system_selector)) {
|
||||
choose_font_by_wxdialog();
|
||||
} else if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", _u8L("Open dialog for choose from fonts.").c_str());
|
||||
#endif // ALLOW_ADD_FONT_BY_OS_SELECTOR
|
||||
|
||||
}
|
||||
|
||||
void GLGizmoEmboss::draw_model_type()
|
||||
{
|
||||
std::optional<ModelVolumeType> new_type;
|
||||
ModelVolumeType modifier = ModelVolumeType::PARAMETER_MODIFIER;
|
||||
ModelVolumeType negative = ModelVolumeType::NEGATIVE_VOLUME;
|
||||
ModelVolumeType part = ModelVolumeType::MODEL_PART;
|
||||
ModelVolumeType type = (m_volume != nullptr) ? m_volume->type() :
|
||||
ModelVolumeType::INVALID;
|
||||
bool is_last_solid_part = false;
|
||||
if (type == part) {
|
||||
is_last_solid_part = true;
|
||||
for (const ModelVolume* vol : m_volume->get_object()->volumes) {
|
||||
if (vol == m_volume) continue;
|
||||
if (vol->type() == part) {
|
||||
is_last_solid_part = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ImGui::RadioButton("modifier", type == modifier) && !is_last_solid_part)
|
||||
new_type = modifier;
|
||||
if(is_last_solid_part && ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", _u8L("You can't change a type of the last solid part of the object.").c_str());
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton("negative", type == negative) && !is_last_solid_part)
|
||||
new_type = negative;
|
||||
if(is_last_solid_part && ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", _u8L("You can't change a type of the last solid part of the object.").c_str());
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton("part", type == part))
|
||||
new_type = part;
|
||||
|
||||
ImGui::SameLine();
|
||||
m_imgui->disabled_begin(true);
|
||||
ImGui::RadioButton("baked in", false);
|
||||
m_imgui->disabled_end();
|
||||
|
||||
if (m_volume != nullptr && new_type.has_value() && !is_last_solid_part) {
|
||||
GUI_App &app = wxGetApp();
|
||||
Plater * plater = app.plater();
|
||||
plater->take_snapshot(_L("Change Part Type"));
|
||||
m_volume->set_type(*new_type);
|
||||
|
||||
// inspiration in ObjectList::change_part_type()
|
||||
// how to view correct side panel with objects
|
||||
ObjectList *obj_list = app.obj_list();
|
||||
ModelVolume * volume = m_volume;
|
||||
wxDataViewItemArray sel = obj_list->reorder_volumes_and_get_selection(
|
||||
obj_list->get_selected_obj_idx(),
|
||||
[volume](const ModelVolume *vol) { return vol == volume; });
|
||||
if (!sel.IsEmpty()) obj_list->select_item(sel.front());
|
||||
|
||||
// TODO: fix way of view - color after change from volume to negative
|
||||
}
|
||||
}
|
||||
|
||||
void GLGizmoEmboss::draw_rename_style(const std::optional<size_t>& rename_index)
|
||||
{
|
||||
// rename modal window popup
|
||||
const char * rename_popup_id = "Rename_font";
|
||||
static FontItem * rename_item;
|
||||
static std::string new_name;
|
||||
if (rename_index.has_value() && !ImGui::IsPopupOpen(rename_popup_id)) {
|
||||
ImGui::OpenPopup(rename_popup_id);
|
||||
rename_item = &m_font_manager.get_font(*rename_index).font_item;
|
||||
new_name = rename_item->name; // initialize with original copy
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupModal(rename_popup_id, 0,
|
||||
ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
const std::string &original_font_name = rename_item->name;
|
||||
std::string text_in_popup =
|
||||
GUI::format(_u8L("Change font name (%1%): "), original_font_name);
|
||||
text_in_popup += "\n" +
|
||||
_u8L("NOTE: Name has to be unique in font list.");
|
||||
ImGui::Text("%s", text_in_popup.c_str());
|
||||
ImGui::SetNextItemWidth(m_gui_cfg->combo_font_width);
|
||||
|
||||
bool is_unique = true;
|
||||
for (const auto &item : m_font_manager.get_fonts()) {
|
||||
const FontItem &fi = item.font_item;
|
||||
if (&fi == rename_item)
|
||||
continue; // could be same as original name
|
||||
if (fi.name == new_name) is_unique = false;
|
||||
}
|
||||
bool allow_change = is_unique && !new_name.empty();
|
||||
|
||||
ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue;
|
||||
if ((ImGui::InputText("##font name", &new_name, flags) &&
|
||||
allow_change) ||
|
||||
m_imgui->button(_L("ok"), ImVec2(0.f, 0.f), allow_change)) {
|
||||
rename_item->name = new_name;
|
||||
ImGui::CloseCurrentPopup();
|
||||
store_font_list_to_app_config();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
void GLGizmoEmboss::draw_style_list() {
|
||||
const float & max_width = m_gui_cfg->max_font_name_width;
|
||||
std::optional<size_t> rename_index, delete_index, duplicate_index;
|
||||
|
||||
@ -627,69 +836,72 @@ void GLGizmoEmboss::draw_font_list()
|
||||
const std::string ¤t_name = actual_font_item.name;
|
||||
std::string trunc_name = ImGuiWrapper::trunc(current_name, max_width);
|
||||
const auto &fonts = m_font_manager.get_fonts();
|
||||
ImGui::SetNextItemWidth(m_gui_cfg->combo_font_width);
|
||||
if (ImGui::BeginCombo("##font_selector", trunc_name.c_str())) {
|
||||
// first line
|
||||
if (ImGui::Button(_u8L("Choose font").c_str())) {
|
||||
choose_font_by_wxdialog();
|
||||
store_font_list_to_app_config();
|
||||
ImGui::CloseCurrentPopup();
|
||||
} else if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s",
|
||||
_u8L("Choose from installed font inside dialog.").c_str());
|
||||
|
||||
#ifdef ALLOW_DEBUG_MODE
|
||||
ImGui::Text("%s", _u8L("Style").c_str());
|
||||
ImGui::SameLine();
|
||||
// select font file by file browser
|
||||
if (ImGui::Button(_u8L("Add File").c_str())) {
|
||||
choose_true_type_file();
|
||||
store_font_list_to_app_config();
|
||||
ImGui::CloseCurrentPopup();
|
||||
} else if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s",_u8L("add file with font(.ttf, .ttc)").c_str());
|
||||
#endif // ALLOW_DEBUG_MODE
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::SetNextItemWidth(m_gui_cfg->combo_font_width);
|
||||
if (ImGui::BeginCombo("##style_selector", trunc_name.c_str())) {
|
||||
for (const auto &item : fonts) {
|
||||
size_t index = &item - &fonts.front();
|
||||
const FontItem & fi = item.font_item;
|
||||
ImGui::PushID(fi.name.c_str());
|
||||
std::string name = ImGuiWrapper::trunc(fi.name, max_width);
|
||||
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
|
||||
if (ImGui::Selectable(name.c_str(), is_selected, flags) ) {
|
||||
ImGuiSelectableFlags_ flags =
|
||||
ImGuiSelectableFlags_AllowItemOverlap; // allow click buttons
|
||||
if (ImGui::Selectable(name_truncated.c_str(), is_selected,
|
||||
flags)) {
|
||||
if (m_font_manager.load_font(index)) process();
|
||||
} else if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", fi.name.c_str());
|
||||
ImGui::SetTooltip("%s", actual_style_name.c_str());
|
||||
|
||||
// reorder items
|
||||
if (ImGui::IsItemActive() && !ImGui::IsItemHovered()) {
|
||||
int other_index = index + (ImGui::GetMouseDragDelta(0).y < 0.f ? -1 : 1);
|
||||
int other_index = index +
|
||||
(ImGui::GetMouseDragDelta(0).y < 0.f ? -1 :
|
||||
1);
|
||||
if (other_index >= 0 && other_index < fonts.size()) {
|
||||
std::swap(m_font_manager.get_font(index),
|
||||
m_font_manager.get_font(other_index));
|
||||
// fix selected index
|
||||
if (is_selected)
|
||||
m_font_manager.select(other_index);
|
||||
else if (&fonts[other_index].font_item == &actual_font_item)
|
||||
else if (&fonts[other_index].font_item ==
|
||||
&actual_font_item)
|
||||
m_font_manager.select(index);
|
||||
ImGui::ResetMouseDragDelta();
|
||||
}
|
||||
}
|
||||
|
||||
// draw buttons rename / duplicate / delete
|
||||
ImGui::SameLine(m_gui_cfg->rename_pos_x);
|
||||
if (draw_button(IconType::rename)) rename_index = index;
|
||||
ImGui::SameLine(m_gui_cfg->duplicate_pos_x);
|
||||
if (draw_button(IconType::duplicate)) duplicate_index = index;
|
||||
ImGui::SameLine(m_gui_cfg->delete_pos_x);
|
||||
if (draw_button(IconType::erase, is_selected)) delete_index = index;
|
||||
if (draw_button(IconType::erase, is_selected) && !is_selected)
|
||||
delete_index = index;
|
||||
if (ImGui::IsItemHovered()) {
|
||||
std::string tooltip = (is_selected)?
|
||||
GUI::format(_L("Active style \"%1%\" can't be deleted."), actual_style_name) :
|
||||
GUI::format(_L("Delete \"%1%\" style."), actual_style_name);
|
||||
ImGui::SetTooltip("%s", tooltip.c_str());
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
if (draw_button(IconType::rename))
|
||||
rename_index = &m_font_manager.get_font() - &fonts.front();
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", _u8L("Rename actual style.").c_str());
|
||||
|
||||
ImGui::SameLine();
|
||||
if (draw_button(IconType::duplicate))
|
||||
duplicate_index = &m_font_manager.get_font() - &fonts.front();
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", _u8L("Duplicate style.").c_str());
|
||||
|
||||
// duplicate font item
|
||||
if (duplicate_index.has_value()) {
|
||||
m_font_manager.duplicate(*duplicate_index);
|
||||
@ -702,68 +914,155 @@ void GLGizmoEmboss::draw_font_list()
|
||||
store_font_list_to_app_config();
|
||||
}
|
||||
|
||||
// rename modal window popup
|
||||
const char *rename_popup_id = "Rename_font";
|
||||
static FontItem* rename_item;
|
||||
static std::string new_name;
|
||||
if (rename_index.has_value() && !ImGui::IsPopupOpen(rename_popup_id)) {
|
||||
ImGui::OpenPopup(rename_popup_id);
|
||||
rename_item = &m_font_manager.get_font(*rename_index).font_item;
|
||||
new_name = rename_item->name; // initialize with original copy
|
||||
}
|
||||
draw_rename_style(rename_index);
|
||||
|
||||
if (ImGui::BeginPopupModal(rename_popup_id, 0, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||
const std::string &original_font_name = rename_item->name;
|
||||
std::string text_in_popup = GUI::format(_u8L("Change font name (%1%): "), original_font_name);
|
||||
text_in_popup += "\n" + _u8L("NOTE: Name has to be unique in font list.");
|
||||
ImGui::Text("%s", text_in_popup.c_str());
|
||||
ImGui::SetNextItemWidth(m_gui_cfg->combo_font_width);
|
||||
// TODO: Is style changed against stored one
|
||||
bool is_changed = false;
|
||||
|
||||
bool is_unique = true;
|
||||
for (const auto &item : m_font_manager.get_fonts()) {
|
||||
const FontItem &fi = item.font_item;
|
||||
if (&fi == rename_item) continue; // could be same as original name
|
||||
if (fi.name == new_name) is_unique = false;
|
||||
ImGui::SameLine();
|
||||
if (draw_button(IconType::save, !is_changed)) {
|
||||
// TODO: make save style
|
||||
}
|
||||
bool allow_change = is_unique && !new_name.empty();
|
||||
if (ImGui::IsItemHovered())
|
||||
if (is_changed)
|
||||
ImGui::SetTooltip("%s", _u8L("Save current settings to selected style").c_str());
|
||||
else
|
||||
ImGui::SetTooltip("%s", _u8L("No changes to save into style").c_str());
|
||||
|
||||
ImGuiInputTextFlags flags = ImGuiInputTextFlags_EnterReturnsTrue;
|
||||
if ((ImGui::InputText("##font name", &new_name, flags) && allow_change) ||
|
||||
m_imgui->button(_L("ok"), ImVec2(0.f, 0.f), allow_change)) {
|
||||
rename_item->name = new_name;
|
||||
ImGui::CloseCurrentPopup();
|
||||
store_font_list_to_app_config();
|
||||
if (is_changed) {
|
||||
ImGui::SameLine();
|
||||
if (draw_button(IconType::undo)) {
|
||||
// TODO: make undo changes in style
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", _u8L("Reload original value of selected style").c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void GLGizmoEmboss::draw_text_input()
|
||||
bool GLGizmoEmboss::italic_button()
|
||||
{
|
||||
static const ImGuiInputTextFlags flags =
|
||||
ImGuiInputTextFlags_AllowTabInput | ImGuiInputTextFlags_AutoSelectAll;
|
||||
FontManager::Item& item = m_font_manager.get_font();
|
||||
std::optional<wxFont> &wx_font = item.wx_font;
|
||||
if (!wx_font.has_value()) {
|
||||
draw_icon(IconType::italic, IconState::disabled);
|
||||
return false;
|
||||
}
|
||||
|
||||
ImFont *imgui_font = m_font_manager.get_imgui_font();
|
||||
bool exist_font = imgui_font != nullptr && imgui_font->IsLoaded();
|
||||
if (exist_font) ImGui::PushFont(imgui_font);
|
||||
std::optional<float> &skew = item.font_item.prop.skew;
|
||||
bool is_font_italic = skew.has_value() || WxFontUtils::is_italic(*wx_font);
|
||||
if (is_font_italic) {
|
||||
if (draw_button(IconType::unitalic)) {
|
||||
skew.reset();
|
||||
wx_font->SetStyle(wxFontStyle::wxFONTSTYLE_NORMAL);
|
||||
return true;
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", _u8L("Unset italic").c_str());
|
||||
} else {
|
||||
if (draw_button(IconType::italic)) {
|
||||
std::shared_ptr<Emboss::FontFile> &font_file = item.font_file;
|
||||
bool is_set = WxFontUtils::set_italic(*wx_font, font_file);
|
||||
// add skew when wxFont can't set it
|
||||
if (!is_set) skew = 0.2f;
|
||||
return true;
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", _u8L("Set italic").c_str());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GLGizmoEmboss::bold_button() {
|
||||
FontManager::Item & item = m_font_manager.get_font();
|
||||
std::optional<wxFont> &wx_font = item.wx_font;
|
||||
if (!wx_font.has_value()) {
|
||||
draw_icon(IconType::bold, IconState::disabled);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<float> &boldness = item.font_item.prop.boldness;
|
||||
bool is_font_bold = boldness.has_value() || WxFontUtils::is_bold(*wx_font);
|
||||
if (is_font_bold) {
|
||||
if (draw_button(IconType::unbold)) {
|
||||
boldness.reset();
|
||||
wx_font->SetWeight(wxFontWeight::wxFONTWEIGHT_NORMAL);
|
||||
return true;
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", _u8L("Unset bold").c_str());
|
||||
} else {
|
||||
if (draw_button(IconType::bold)) {
|
||||
std::shared_ptr<Emboss::FontFile> &font_file = item.font_file;
|
||||
bool is_set = WxFontUtils::set_bold(*wx_font, font_file);
|
||||
// add boldness when wxFont can't set it
|
||||
if (!is_set) boldness = 20.f;
|
||||
return true;
|
||||
}
|
||||
if (ImGui::IsItemHovered())
|
||||
ImGui::SetTooltip("%s", _u8L("Set bold").c_str());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GLGizmoEmboss::draw_style_edit() {
|
||||
const GuiCfg::Translations &tr = m_gui_cfg->translations;
|
||||
ImGui::Text("%s", tr.font.c_str());
|
||||
ImGui::SameLine(m_gui_cfg->style_edit_text_width);
|
||||
ImGui::SetNextItemWidth(m_gui_cfg->combo_font_width);
|
||||
draw_font_list();
|
||||
ImGui::SameLine();
|
||||
bool exist_change = false;
|
||||
float window_height = ImGui::GetWindowHeight();
|
||||
float minimal_height = m_gui_cfg->draw_advanced ?
|
||||
m_gui_cfg->minimal_window_size_with_advance.y :
|
||||
m_gui_cfg->minimal_window_size.y;
|
||||
float extra_height = window_height - minimal_height;
|
||||
ImVec2 text_size(m_gui_cfg->text_size.x,
|
||||
m_gui_cfg->text_size.y + extra_height);
|
||||
if (ImGui::InputTextMultiline("##Text", &m_text, text_size, flags)) {
|
||||
process();
|
||||
exist_change |= italic_button();
|
||||
ImGui::SameLine();
|
||||
exist_change |= bold_button();
|
||||
|
||||
FontManager::Item &item = m_font_manager.get_font();
|
||||
FontItem & fi = item.font_item;
|
||||
std::optional<wxFont> &wx_font = item.wx_font;
|
||||
|
||||
// TODO: should not be there
|
||||
// when actual font not loaded try to load
|
||||
if (!wx_font.has_value() && fi.type == WxFontUtils::get_actual_type())
|
||||
wx_font = WxFontUtils::load_wxFont(fi.path);
|
||||
|
||||
FontProp &font_prop = fi.prop;
|
||||
|
||||
ImGui::Text("%s", tr.size.c_str());
|
||||
ImGui::SameLine(m_gui_cfg->style_edit_text_width);
|
||||
ImGui::SetNextItemWidth(m_gui_cfg->combo_font_width);
|
||||
if (ImGui::InputFloat("##line height", &font_prop.size_in_mm, 0.1f, 1.f, "%.1f mm")) {
|
||||
if (font_prop.size_in_mm < 0.1) font_prop.size_in_mm = 10;
|
||||
// store font size into path
|
||||
if (fi.type == WxFontUtils::get_actual_type()) {
|
||||
if (wx_font.has_value()) {
|
||||
wx_font->SetPointSize(font_prop.size_in_mm);
|
||||
fi.path = WxFontUtils::store_wxFont(*wx_font);
|
||||
}
|
||||
}
|
||||
m_font_manager.load_imgui_font(m_text);
|
||||
exist_change = true;
|
||||
}
|
||||
if (exist_change) {
|
||||
std::shared_ptr<Emboss::FontFile> &font_file = item.font_file;
|
||||
font_file->cache.clear();
|
||||
store_font_item_to_app_config();
|
||||
process();
|
||||
}
|
||||
|
||||
if (exist_font) ImGui::PopFont();
|
||||
ImGui::Text("%s", tr.depth.c_str());
|
||||
ImGui::SameLine(m_gui_cfg->style_edit_text_width);
|
||||
ImGui::SetNextItemWidth(m_gui_cfg->combo_font_width);
|
||||
if (ImGui::InputFloat("##size in Z", &font_prop.emboss, 0.1f, 0.25, "%.2f mm")) {
|
||||
process();
|
||||
}
|
||||
|
||||
// imgui_font has to be unused
|
||||
if (exist_change) m_font_manager.check_imgui_font_range(m_text);
|
||||
if (ImGui::TreeNode(_u8L("advanced").c_str())) {
|
||||
draw_advanced();
|
||||
ImGui::TreePop();
|
||||
if (!m_is_advanced_edit_style)
|
||||
set_minimal_window_size(true, true);
|
||||
} else if (m_is_advanced_edit_style)
|
||||
set_minimal_window_size(true, false);
|
||||
}
|
||||
|
||||
void GLGizmoEmboss::draw_advanced()
|
||||
@ -778,30 +1077,10 @@ void GLGizmoEmboss::draw_advanced()
|
||||
FontProp &font_prop = fi.prop;
|
||||
bool exist_change = false;
|
||||
|
||||
ImGui::SetNextItemWidth(m_gui_cfg->advanced_input_width);
|
||||
if (ImGui::InputFloat(_u8L("Size[in mm]").c_str(),
|
||||
&font_prop.size_in_mm)) {
|
||||
if (font_prop.size_in_mm < 0.1) font_prop.size_in_mm = 10;
|
||||
// store font size into path
|
||||
if (fi.type == WxFontUtils::get_actual_type()) {
|
||||
std::optional<wxFont> wx_font = WxFontUtils::load_wxFont(fi.path);
|
||||
if (wx_font.has_value()) {
|
||||
wx_font->SetPointSize(font_prop.size_in_mm);
|
||||
fi.path = WxFontUtils::store_wxFont(*wx_font);
|
||||
}
|
||||
}
|
||||
m_font_manager.load_imgui_font();
|
||||
font_file->cache.clear();
|
||||
exist_change = true;
|
||||
}
|
||||
|
||||
ImGui::SetNextItemWidth(m_gui_cfg->advanced_input_width);
|
||||
if (ImGui::InputFloat(_u8L("Emboss[in mm]").c_str(), &font_prop.emboss))
|
||||
exist_change = true;
|
||||
|
||||
ImGui::SetNextItemWidth(2 * m_gui_cfg->advanced_input_width);
|
||||
if (ImGuiWrapper::input_optional_int(_u8L("CharGap[in font points]").c_str(), font_prop.char_gap)) {
|
||||
font_file->cache.clear();
|
||||
m_font_manager.load_imgui_font(m_text);
|
||||
exist_change = true;
|
||||
}
|
||||
|
||||
@ -816,7 +1095,7 @@ void GLGizmoEmboss::draw_advanced()
|
||||
}
|
||||
|
||||
ImGui::SetNextItemWidth(2 * m_gui_cfg->advanced_input_width);
|
||||
if (m_imgui->slider_optional_float(_u8L("Skew ratio").c_str(), font_prop.skew, -1.f, 1.f, "%.2f", 1.f, false, _L("italic strength"))){
|
||||
if (m_imgui->slider_optional_float(_u8L("Italic [Skew ratio]").c_str(), font_prop.skew, -1.f, 1.f, "%.2f", 1.f, false, _L("italic strength"))){
|
||||
font_file->cache.clear();
|
||||
exist_change = true;
|
||||
}
|
||||
@ -845,7 +1124,8 @@ void GLGizmoEmboss::draw_advanced()
|
||||
process();
|
||||
}
|
||||
|
||||
|
||||
auto& atlas = m_font_manager.m_imgui_font_atlas;
|
||||
ImGui::Image(atlas.TexID, ImVec2(atlas.TexWidth, atlas.TexHeight));
|
||||
#ifdef ALLOW_DEBUG_MODE
|
||||
ImGui::Text("family = %s", (font_prop.family.has_value() ?
|
||||
font_prop.family->c_str() :
|
||||
@ -862,12 +1142,33 @@ void GLGizmoEmboss::draw_advanced()
|
||||
|
||||
std::string descriptor = fi.path;
|
||||
ImGui::Text("descriptor = %s", descriptor.c_str());
|
||||
ImGui::Image(m_imgui_font_atlas.TexID,
|
||||
ImVec2(m_imgui_font_atlas.TexWidth,
|
||||
m_imgui_font_atlas.TexHeight));
|
||||
#endif // ALLOW_DEBUG_MODE
|
||||
}
|
||||
|
||||
void GLGizmoEmboss::set_minimal_window_size(bool is_edit_style,
|
||||
bool is_advance_edit_style)
|
||||
{
|
||||
ImVec2 window_size = ImGui::GetWindowSize();
|
||||
const ImVec2& min_win_size_prev = get_minimal_window_size();
|
||||
ImVec2 diff(window_size.x - min_win_size_prev.x,
|
||||
window_size.y - min_win_size_prev.y);
|
||||
float diff_y = ImGui::GetWindowSize().y - get_minimal_window_size().y;
|
||||
m_is_edit_style = is_edit_style;
|
||||
m_is_advanced_edit_style = is_advance_edit_style;
|
||||
const ImVec2 &min_win_size = get_minimal_window_size();
|
||||
ImGui::SetWindowSize(ImVec2(0.f, min_win_size.y + diff.y),
|
||||
ImGuiCond_Always);
|
||||
}
|
||||
|
||||
const ImVec2 &GLGizmoEmboss::get_minimal_window_size() const
|
||||
{
|
||||
return (m_is_edit_style) ?
|
||||
((m_is_advanced_edit_style) ?
|
||||
m_gui_cfg->minimal_window_size_with_advance :
|
||||
m_gui_cfg->minimal_window_size_with_edit) :
|
||||
m_gui_cfg->minimal_window_size;
|
||||
}
|
||||
|
||||
bool GLGizmoEmboss::choose_font_by_wxdialog()
|
||||
{
|
||||
wxFontData data;
|
||||
@ -885,9 +1186,9 @@ bool GLGizmoEmboss::choose_font_by_wxdialog()
|
||||
if (font_dialog.ShowModal() != wxID_OK) return false;
|
||||
|
||||
data = font_dialog.GetFontData();
|
||||
wxFont font = data.GetChosenFont();
|
||||
wxFont wx_font = data.GetChosenFont();
|
||||
size_t font_index = m_font_manager.get_fonts().size();
|
||||
FontItem font_item = WxFontUtils::get_font_item(font);
|
||||
FontItem font_item = WxFontUtils::get_font_item(wx_font);
|
||||
m_font_manager.add_font(font_item);
|
||||
|
||||
// Check that deserialization NOT influence font
|
||||
@ -897,7 +1198,7 @@ bool GLGizmoEmboss::choose_font_by_wxdialog()
|
||||
|
||||
// Try load and use new added font
|
||||
if ((use_deserialized_font && !m_font_manager.load_font(font_index)) ||
|
||||
(!use_deserialized_font && !m_font_manager.load_font(font_index, font)) ||
|
||||
(!use_deserialized_font && !m_font_manager.load_font(font_index, wx_font)) ||
|
||||
!process()) {
|
||||
m_font_manager.erase(font_index);
|
||||
wxString message = GUI::format_wxstr(
|
||||
@ -910,8 +1211,7 @@ bool GLGizmoEmboss::choose_font_by_wxdialog()
|
||||
}
|
||||
|
||||
// fix dynamic creation of italic font
|
||||
wxFontStyle wx_style = font.GetStyle();
|
||||
if ((wx_style == wxFONTSTYLE_ITALIC || wx_style == wxFONTSTYLE_SLANT) &&
|
||||
if (WxFontUtils::is_italic(wx_font) &&
|
||||
!Emboss::is_italic(*m_font_manager.get_font_file())) {
|
||||
m_font_manager.get_font_item().prop.skew = 0.2;
|
||||
}
|
||||
@ -1089,12 +1389,23 @@ std::string GLGizmoEmboss::create_volume_name()
|
||||
|
||||
bool GLGizmoEmboss::init_icons()
|
||||
{
|
||||
std::string path = resources_dir() + "/icons/";
|
||||
|
||||
// icon order has to match the enum IconType
|
||||
std::vector<std::string> filenames = {path + "wrench.svg",
|
||||
path + "delete.svg",
|
||||
path + "add_copies.svg"};
|
||||
std::vector<std::string> filenames{
|
||||
"edit_button.svg",
|
||||
"delete.svg",
|
||||
"add_copies.svg",
|
||||
"save.svg",
|
||||
"undo.svg",
|
||||
"make_italic.svg",
|
||||
"make_unitalic.svg",
|
||||
"make_bold.svg",
|
||||
"make_unbold.svg",
|
||||
"search.svg",
|
||||
"open.svg"
|
||||
};
|
||||
assert(filenames.size() == static_cast<size_t>(IconType::_count));
|
||||
std::string path = resources_dir() + "/icons/";
|
||||
for (std::string &filename : filenames) filename = path + filename;
|
||||
|
||||
// state order has to match the enum IconState
|
||||
std::vector<std::pair<int, bool>> states;
|
||||
@ -1114,6 +1425,10 @@ bool GLGizmoEmboss::init_icons()
|
||||
|
||||
void GLGizmoEmboss::draw_icon(IconType icon, IconState state)
|
||||
{
|
||||
// canot draw count
|
||||
assert(icon != IconType::_count);
|
||||
if (icon == IconType::_count) return;
|
||||
|
||||
unsigned int icons_texture_id = m_icons_texture.get_id();
|
||||
int tex_width = m_icons_texture.get_width();
|
||||
int tex_height = m_icons_texture.get_height();
|
||||
@ -1122,9 +1437,8 @@ void GLGizmoEmboss::draw_icon(IconType icon, IconState state)
|
||||
if ((icons_texture_id == 0) || (tex_width <= 1) || (tex_height <= 1))
|
||||
return;
|
||||
ImTextureID tex_id = (void *) (intptr_t) (GLuint) icons_texture_id;
|
||||
// ImVec2 image_size(tex_width, tex_height);
|
||||
|
||||
size_t count_icons = 3; // wrench | delete | copy
|
||||
size_t count_icons = static_cast<size_t>(IconType::_count);
|
||||
size_t count_states = 3; // activable | hovered | disabled
|
||||
ImVec2 icon_size(tex_width / count_states, tex_height / count_icons);
|
||||
|
||||
@ -1132,7 +1446,6 @@ void GLGizmoEmboss::draw_icon(IconType icon, IconState state)
|
||||
static_cast<unsigned>(icon) * icon_size.y);
|
||||
|
||||
ImVec2 uv0(start.x / tex_width, start.y / tex_height);
|
||||
|
||||
ImVec2 uv1((start.x + icon_size.x) / tex_width,
|
||||
(start.y + icon_size.y) / tex_height);
|
||||
|
||||
@ -1141,42 +1454,17 @@ void GLGizmoEmboss::draw_icon(IconType icon, IconState state)
|
||||
|
||||
bool GLGizmoEmboss::draw_button(IconType icon, bool disable)
|
||||
{
|
||||
float line_spacing = ImGui::GetTextLineHeightWithSpacing() -
|
||||
ImGui::GetTextLineHeight();
|
||||
float cursor_pos_y = ImGui::GetCursorPosY();
|
||||
ImGui::SetCursorPosY(cursor_pos_y - line_spacing / 2);
|
||||
ScopeGuard sg([cursor_pos_y]() {
|
||||
ImGui::SetCursorPosY(cursor_pos_y);
|
||||
ImGui::NewLine();
|
||||
});
|
||||
|
||||
if (disable) {
|
||||
draw_icon(icon, IconState::disabled);
|
||||
if (ImGui::IsItemHovered() && icon == IconType::erase)
|
||||
ImGui::SetTooltip("%s",_u8L("Active font can't be removed").c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
float cursor_x = ImGui::GetCursorPosX();
|
||||
|
||||
draw_icon(icon, IconState::activable);
|
||||
if (ImGui::IsItemClicked()) return true;
|
||||
|
||||
if (ImGui::IsItemHovered()) {
|
||||
std::string tooltip;
|
||||
switch (icon) {
|
||||
case IconType::rename: tooltip = _u8L("rename"); break;
|
||||
case IconType::erase: tooltip = _u8L("delete"); break;
|
||||
case IconType::duplicate:tooltip = _u8L("duplicate"); break;
|
||||
default: break;
|
||||
}
|
||||
if (!tooltip.empty())
|
||||
ImGui::SetTooltip("%s", tooltip.c_str());
|
||||
|
||||
// redraw image over previous
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(cursor_x);
|
||||
|
||||
ImGui::SameLine(cursor_x);
|
||||
draw_icon(icon, IconState::hovered);
|
||||
}
|
||||
return false;
|
||||
|
@ -100,9 +100,18 @@ private:
|
||||
bool process();
|
||||
void close();
|
||||
void draw_window();
|
||||
void draw_font_list();
|
||||
void draw_text_input();
|
||||
void draw_model_type();
|
||||
void draw_style_list();
|
||||
void draw_rename_style(const std::optional<size_t>& rename_index);
|
||||
void draw_font_list();
|
||||
void draw_style_edit();
|
||||
bool italic_button();
|
||||
bool bold_button();
|
||||
void draw_advanced();
|
||||
|
||||
void set_minimal_window_size(bool is_edit_style, bool is_advance_edit_style);
|
||||
const ImVec2 &get_minimal_window_size() const;
|
||||
// process mouse event
|
||||
bool on_mouse_for_rotation(const wxMouseEvent &mouse_event);
|
||||
bool on_mouse_for_translate(const wxMouseEvent &mouse_event);
|
||||
@ -128,26 +137,35 @@ private:
|
||||
struct GuiCfg
|
||||
{
|
||||
size_t max_count_char_in_volume_name = 20;
|
||||
int count_line_of_text = 6;
|
||||
bool draw_advanced = false;
|
||||
|
||||
// setted only when wanted to use - not all the time
|
||||
std::optional<ImVec2> offset;
|
||||
|
||||
// Zero means it is calculated in init function
|
||||
ImVec2 minimal_window_size = ImVec2(0, 0);
|
||||
ImVec2 minimal_window_size_with_edit = ImVec2(0, 0);
|
||||
ImVec2 minimal_window_size_with_advance = ImVec2(0, 0);
|
||||
float advanced_input_width = 0.f;
|
||||
float combo_font_width = 0.f;
|
||||
float rename_pos_x = 0.f;
|
||||
float delete_pos_x = 0.f;
|
||||
float duplicate_pos_x = 0.f;
|
||||
float max_font_name_width = 0.f;
|
||||
float icon_width = 0.f;
|
||||
|
||||
float style_edit_text_width = 0.f;
|
||||
|
||||
ImVec2 text_size;
|
||||
|
||||
// Only translations needed for calc GUI size
|
||||
struct Translations
|
||||
{
|
||||
std::string font;
|
||||
std::string size;
|
||||
std::string depth;
|
||||
};
|
||||
Translations translations;
|
||||
GuiCfg() = default;
|
||||
};
|
||||
std::optional<GuiCfg> m_gui_cfg;
|
||||
std::optional<const GuiCfg> m_gui_cfg;
|
||||
// setted only when wanted to use - not all the time
|
||||
std::optional<ImVec2> m_set_window_offset;
|
||||
bool m_is_edit_style = false;
|
||||
bool m_is_advanced_edit_style = false;
|
||||
|
||||
FontManager m_font_manager;
|
||||
|
||||
@ -175,7 +193,20 @@ private:
|
||||
// drawing icons
|
||||
GLTexture m_icons_texture;
|
||||
bool init_icons();
|
||||
enum class IconType: unsigned { rename = 0, erase /*1*/, duplicate /*2*/};
|
||||
enum class IconType : unsigned {
|
||||
rename = 0,
|
||||
erase,
|
||||
duplicate,
|
||||
save,
|
||||
undo,
|
||||
italic,
|
||||
unitalic,
|
||||
bold,
|
||||
unbold,
|
||||
system_selector,
|
||||
open_file,
|
||||
_count /* automatic calc of icon size */
|
||||
};
|
||||
enum class IconState: unsigned { activable = 0, hovered /*1*/, disabled /*2*/};
|
||||
void draw_icon(IconType icon, IconState state);
|
||||
bool draw_button(IconType icon, bool disable = false);
|
||||
|
@ -10,10 +10,13 @@ using namespace Slic3r;
|
||||
using namespace Slic3r::GUI;
|
||||
|
||||
FontManager::FontManager(const ImWchar *language_glyph_range)
|
||||
: m_imgui_init_glyph_range(language_glyph_range),
|
||||
m_font_selected(0)
|
||||
: m_imgui_init_glyph_range(language_glyph_range), m_font_selected(0)
|
||||
{}
|
||||
|
||||
FontManager::~FontManager() {
|
||||
free_imgui_fonts();
|
||||
}
|
||||
|
||||
void FontManager::select(size_t index)
|
||||
{
|
||||
if (index < m_font_list.size())
|
||||
@ -25,6 +28,11 @@ void FontManager::duplicate(size_t index) {
|
||||
Item item = m_font_list[index]; // copy
|
||||
make_unique_name(item.font_item.name);
|
||||
|
||||
// take original font imgui pointer
|
||||
ImFont *imgui_font = get_imgui_font(index);
|
||||
if (imgui_font != nullptr)
|
||||
m_font_list[index].imgui_font_index.reset();
|
||||
|
||||
m_font_list.insert(m_font_list.begin() + index, item);
|
||||
// fix selected index
|
||||
if (index < m_font_selected) ++m_font_selected;
|
||||
@ -32,6 +40,11 @@ void FontManager::duplicate(size_t index) {
|
||||
|
||||
void FontManager::erase(size_t index) {
|
||||
if (index >= m_font_list.size()) return;
|
||||
|
||||
ImFont *imgui_font = get_imgui_font(index);
|
||||
if (imgui_font != nullptr)
|
||||
IM_DELETE(imgui_font);
|
||||
|
||||
m_font_list.erase(m_font_list.begin() + index);
|
||||
// fix selected index
|
||||
if (index < m_font_selected) --m_font_selected;
|
||||
@ -49,13 +62,13 @@ bool FontManager::load_font(size_t font_index)
|
||||
bool FontManager::load_font(size_t font_index, const wxFont &font)
|
||||
{
|
||||
if (font_index >= m_font_list.size()) return false;
|
||||
m_font_list[font_index].wx_font = font;
|
||||
std::swap(font_index, m_font_selected);
|
||||
bool is_loaded = load_font(font);
|
||||
if (!is_loaded) std::swap(font_index, m_font_selected);
|
||||
return is_loaded;
|
||||
}
|
||||
|
||||
|
||||
static std::string get_file_name(const std::string &file_path)
|
||||
{
|
||||
size_t pos_last_delimiter = file_path.find_last_of('\\');
|
||||
@ -84,13 +97,13 @@ bool FontManager::load_font()
|
||||
return true;
|
||||
}
|
||||
if (fi.type != WxFontUtils::get_actual_type()) return false;
|
||||
std::optional<wxFont> wx_font = WxFontUtils::load_wxFont(fi.path);
|
||||
if (!wx_font.has_value()) return false;
|
||||
item.wx_font = WxFontUtils::load_wxFont(fi.path);
|
||||
if (!item.wx_font.has_value()) return false;
|
||||
|
||||
// fill font name after load from .3mf
|
||||
if (fi.name.empty())
|
||||
fi.name = WxFontUtils::get_human_readable_name(*wx_font);
|
||||
return load_font(*wx_font);
|
||||
fi.name = WxFontUtils::get_human_readable_name(*item.wx_font);
|
||||
return load_font(*item.wx_font);
|
||||
}
|
||||
|
||||
bool FontManager::load_first_valid_font() {
|
||||
@ -121,25 +134,85 @@ void FontManager::add_fonts(FontList font_list)
|
||||
|
||||
std::shared_ptr<Emboss::FontFile> &FontManager::get_font_file()
|
||||
{
|
||||
// TODO: fix not selected font
|
||||
//if (m_font_selected >= m_font_list.size()) return nullptr;
|
||||
return m_font_list[m_font_selected].font_file;
|
||||
}
|
||||
|
||||
const FontItem &FontManager::get_font_item() const
|
||||
{
|
||||
// TODO: fix not selected font
|
||||
return m_font_list[m_font_selected].font_item;
|
||||
}
|
||||
|
||||
FontItem &FontManager::get_font_item()
|
||||
{
|
||||
// TODO: fix not selected font
|
||||
return m_font_list[m_font_selected].font_item;
|
||||
}
|
||||
|
||||
ImFont *FontManager::get_imgui_font()
|
||||
const FontProp &FontManager::get_font_prop() const
|
||||
{
|
||||
return m_font_list[m_font_selected].imgui_font;
|
||||
// TODO: fix not selected font
|
||||
return m_font_list[m_font_selected].font_item.prop;
|
||||
}
|
||||
|
||||
const std::vector<FontManager::Item> &Slic3r::GUI::FontManager::get_fonts() const
|
||||
FontProp &FontManager::get_font_prop()
|
||||
{
|
||||
// TODO: fix not selected font
|
||||
return m_font_list[m_font_selected].font_item.prop;
|
||||
}
|
||||
|
||||
std::optional<wxFont> &FontManager::get_wx_font()
|
||||
{
|
||||
return m_font_list[m_font_selected].wx_font;
|
||||
}
|
||||
|
||||
const std::optional<wxFont> &FontManager::get_wx_font() const
|
||||
{
|
||||
return m_font_list[m_font_selected].wx_font;
|
||||
}
|
||||
|
||||
ImFont *FontManager::get_imgui_font(const std::string &text)
|
||||
{
|
||||
return get_imgui_font(m_font_selected, text);
|
||||
}
|
||||
|
||||
ImFont *FontManager::get_imgui_font(size_t item_index, const std::string &text)
|
||||
{
|
||||
// is selected font
|
||||
if (item_index >= m_font_list.size()) return nullptr;
|
||||
|
||||
Item &item = m_font_list[item_index];
|
||||
// check is already loaded
|
||||
if (!item.imgui_font_index.has_value()) return nullptr;
|
||||
size_t index = *item.imgui_font_index;
|
||||
auto & fonts = m_imgui_font_atlas.Fonts;
|
||||
|
||||
// check correct index
|
||||
assert(index < fonts.size());
|
||||
if (index >= fonts.size()) return nullptr;
|
||||
ImFont *font = fonts[index];
|
||||
if (font == nullptr) return nullptr;
|
||||
|
||||
if (!text.empty() && !is_text_in_ranges(font, text))
|
||||
extend_imgui_font_range(item_index, text);
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
void FontManager::free_except_active_font() {
|
||||
free_imgui_fonts();
|
||||
|
||||
// free font_files
|
||||
const Item &act_item = m_font_list[m_font_selected];
|
||||
for (auto &item : m_font_list) {
|
||||
if (&item == &act_item) continue; // keep alive actual font file
|
||||
item.font_file = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<FontManager::Item> &FontManager::get_fonts() const
|
||||
{
|
||||
return m_font_list;
|
||||
}
|
||||
@ -154,6 +227,11 @@ const FontManager::Item &FontManager::get_font() const
|
||||
return m_font_list[m_font_selected];
|
||||
}
|
||||
|
||||
FontManager::Item &FontManager::get_font()
|
||||
{
|
||||
return m_font_list[m_font_selected];
|
||||
}
|
||||
|
||||
FontManager::Item &FontManager::get_font(size_t index)
|
||||
{
|
||||
return m_font_list[index];
|
||||
@ -188,18 +266,17 @@ void FontManager::make_unique_name(std::string &name) {
|
||||
name = new_name;
|
||||
}
|
||||
|
||||
void FontManager::check_imgui_font_range(const std::string& text)
|
||||
bool FontManager::is_text_in_ranges(const ImFont *font, const std::string &text)
|
||||
{
|
||||
const ImFont *font = m_imgui_font_atlas.Fonts.front();
|
||||
if (!font->IsLoaded()) {
|
||||
// when create font no one letter in text was inside font
|
||||
// check text again
|
||||
load_imgui_font();
|
||||
return;
|
||||
if (font == nullptr) return false;
|
||||
if (!font->IsLoaded()) return false;
|
||||
const ImFontConfig *fc = font->ConfigData;
|
||||
if (fc == nullptr) return false;
|
||||
return is_text_in_ranges(fc->GlyphRanges, text);
|
||||
}
|
||||
if (font->ConfigData == nullptr) return;
|
||||
const ImWchar *ranges = font->ConfigData->GlyphRanges;
|
||||
auto is_in_ranges = [ranges](unsigned int letter) -> bool {
|
||||
|
||||
bool FontManager::is_char_in_ranges(const ImWchar *ranges, unsigned int letter)
|
||||
{
|
||||
for (const ImWchar *range = ranges; range[0] && range[1]; range += 2) {
|
||||
ImWchar from = range[0];
|
||||
ImWchar to = range[1];
|
||||
@ -209,7 +286,8 @@ void FontManager::check_imgui_font_range(const std::string& text)
|
||||
return false;
|
||||
};
|
||||
|
||||
bool exist_unknown = false;
|
||||
bool FontManager::is_text_in_ranges(const ImWchar *ranges, const std::string &text)
|
||||
{
|
||||
const char *text_char_ptr = text.c_str();
|
||||
while (*text_char_ptr) {
|
||||
unsigned int c = 0;
|
||||
@ -217,12 +295,28 @@ void FontManager::check_imgui_font_range(const std::string& text)
|
||||
int c_len = ImTextCharFromUtf8(&c, text_char_ptr, NULL);
|
||||
text_char_ptr += c_len;
|
||||
if (c_len == 0) break;
|
||||
if (!is_in_ranges(c)) {
|
||||
exist_unknown = true;
|
||||
break;
|
||||
if (!is_char_in_ranges(ranges, c)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (exist_unknown) load_imgui_font();
|
||||
|
||||
void FontManager::extend_imgui_font_range(size_t index, const std::string& text)
|
||||
{
|
||||
auto &font_index_opt = m_font_list[m_font_selected].imgui_font_index;
|
||||
if (!font_index_opt.has_value()) load_imgui_font(index, text);
|
||||
|
||||
// TODO: start using merge mode
|
||||
// ImFontConfig::MergeMode = true;
|
||||
|
||||
free_imgui_fonts();
|
||||
load_imgui_font(index, text);
|
||||
}
|
||||
|
||||
void FontManager::free_imgui_fonts()
|
||||
{
|
||||
for (auto &item : m_font_list)
|
||||
item.imgui_font_index.reset();
|
||||
m_imgui_font_atlas.Clear();
|
||||
}
|
||||
|
||||
bool FontManager::load_font(const wxFont &font)
|
||||
@ -234,10 +328,16 @@ bool FontManager::load_font(const wxFont &font)
|
||||
return true;
|
||||
}
|
||||
|
||||
void FontManager::load_imgui_font(const std::string &text)
|
||||
void FontManager::load_imgui_font(const std::string &text) {
|
||||
load_imgui_font(m_font_selected, text);
|
||||
}
|
||||
|
||||
void FontManager::load_imgui_font(size_t index, const std::string &text)
|
||||
{
|
||||
Item &item = m_font_list[m_font_selected];
|
||||
if (index >= m_font_list.size()) return;
|
||||
Item &item = m_font_list[index];
|
||||
if (item.font_file == nullptr) return;
|
||||
const Emboss::FontFile &font_file = *item.font_file;
|
||||
|
||||
// TODO: Create glyph range
|
||||
ImFontGlyphRangesBuilder builder;
|
||||
@ -247,6 +347,10 @@ void FontManager::load_imgui_font(const std::string &text)
|
||||
item.font_ranges.clear();
|
||||
|
||||
builder.BuildRanges(&item.font_ranges);
|
||||
|
||||
m_imgui_font_atlas.Flags |= ImFontAtlasFlags_NoMouseCursors |
|
||||
ImFontAtlasFlags_NoPowerOfTwoHeight;
|
||||
|
||||
const FontProp &font_prop = item.font_item.prop;
|
||||
int font_size = static_cast<int>(
|
||||
std::round(std::abs(font_prop.size_in_mm / 0.3528)));
|
||||
@ -256,12 +360,17 @@ void FontManager::load_imgui_font(const std::string &text)
|
||||
font_size = m_cfg.max_imgui_font_size;
|
||||
|
||||
ImFontConfig font_config;
|
||||
// TODO: start using merge mode
|
||||
//font_config.MergeMode = true;
|
||||
if (font_prop.char_gap.has_value()) {
|
||||
double coef = font_size / (double)font_file.ascent;
|
||||
double char_gap_double = coef * (*font_prop.char_gap);
|
||||
font_config.GlyphExtraSpacing.x =
|
||||
static_cast<int>(std::round(char_gap_double));
|
||||
}
|
||||
font_config.FontDataOwnedByAtlas = false;
|
||||
m_imgui_font_atlas.Flags |= ImFontAtlasFlags_NoMouseCursors |
|
||||
ImFontAtlasFlags_NoPowerOfTwoHeight;
|
||||
m_imgui_font_atlas.Clear();
|
||||
|
||||
const std::vector<unsigned char> &buffer = item.font_file->buffer;
|
||||
const std::vector<unsigned char> &buffer = font_file.buffer;
|
||||
m_imgui_font_atlas.AddFontFromMemoryTTF(
|
||||
(void *) buffer.data(), buffer.size(), font_size, &font_config, item.font_ranges.Data);
|
||||
|
||||
@ -287,5 +396,7 @@ void FontManager::load_imgui_font(const std::string &text)
|
||||
|
||||
// Store our identifier
|
||||
m_imgui_font_atlas.TexID = (ImTextureID) (intptr_t) font_texture;
|
||||
item.imgui_font = m_imgui_font_atlas.Fonts.front();
|
||||
assert(!m_imgui_font_atlas.Fonts.empty());
|
||||
if (m_imgui_font_atlas.Fonts.empty()) return;
|
||||
item.imgui_font_index = m_imgui_font_atlas.Fonts.size() - 1;
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ class FontManager
|
||||
{
|
||||
public:
|
||||
FontManager(const ImWchar *language_glyph_range);
|
||||
~FontManager();
|
||||
|
||||
void select(size_t index);
|
||||
void duplicate(size_t index);
|
||||
void erase(size_t index);
|
||||
@ -29,10 +31,7 @@ public:
|
||||
bool load_font(size_t font_index, const wxFont &font);
|
||||
|
||||
void load_imgui_font(const std::string &text = "");
|
||||
|
||||
// extend actual imgui font when exist unknown char in text
|
||||
// NOTE: imgui_font has to be unused
|
||||
void check_imgui_font_range(const std::string &text);
|
||||
void load_imgui_font(size_t index, const std::string &text);
|
||||
|
||||
// erase font when not possible to load
|
||||
bool load_first_valid_font();
|
||||
@ -49,8 +48,21 @@ public:
|
||||
const FontItem &get_font_item() const;
|
||||
FontItem &get_font_item();
|
||||
|
||||
// getter on active font property
|
||||
const FontProp &get_font_prop() const;
|
||||
FontProp &get_font_prop();
|
||||
|
||||
// getter on activ wx font
|
||||
const std::optional<wxFont> &get_wx_font() const;
|
||||
std::optional<wxFont> &get_wx_font();
|
||||
|
||||
// getter on acitve font pointer for imgui
|
||||
ImFont *get_imgui_font();
|
||||
// text could extend font atlas when not in glyph range
|
||||
ImFont *get_imgui_font(const std::string &text = "");
|
||||
|
||||
// getter on index selected font pointer for imgui
|
||||
// text could extend font atlas when not in glyph range
|
||||
ImFont *get_imgui_font(size_t item_index, const std::string &text = "");
|
||||
|
||||
// free used memory and font file data
|
||||
void free_except_active_font();
|
||||
@ -61,6 +73,7 @@ public:
|
||||
|
||||
std::vector<Item> &get_fonts();
|
||||
const Item &get_font() const;
|
||||
Item &get_font();
|
||||
const Item &get_font(size_t index) const;
|
||||
Item &get_font(size_t index);
|
||||
|
||||
@ -74,14 +87,31 @@ public:
|
||||
// share font file data with emboss job thread
|
||||
std::shared_ptr<Emboss::FontFile> font_file = nullptr;
|
||||
|
||||
// ImGui font
|
||||
ImFont *imgui_font;
|
||||
std::optional<size_t> imgui_font_index;
|
||||
|
||||
// must live same as imgui_font inside of atlas
|
||||
ImVector<ImWchar> font_ranges;
|
||||
|
||||
// wx widget font
|
||||
std::optional<wxFont> wx_font;
|
||||
};
|
||||
|
||||
// TODO: make private
|
||||
ImFontAtlas m_imgui_font_atlas;
|
||||
|
||||
private:
|
||||
// extend actual imgui font when exist unknown char in text
|
||||
// NOTE: imgui_font has to be unused
|
||||
void extend_imgui_font_range(size_t font_index, const std::string &text);
|
||||
|
||||
// Move to imgui utils
|
||||
static bool is_text_in_ranges(const ImFont *font, const std::string &text);
|
||||
static bool is_text_in_ranges(const ImWchar *ranges, const std::string &text);
|
||||
static bool is_char_in_ranges(const ImWchar *ranges, unsigned int letter);
|
||||
|
||||
bool check_imgui_font_range(ImFont *font, const std::string &text);
|
||||
void free_imgui_fonts();
|
||||
|
||||
struct Configuration
|
||||
{
|
||||
// limits for imgui loaded font
|
||||
@ -100,7 +130,7 @@ private:
|
||||
size_t m_font_selected; // index to m_font_list
|
||||
|
||||
// store all font GLImages
|
||||
ImFontAtlas m_imgui_font_atlas;
|
||||
//ImFontAtlas m_imgui_font_atlas;
|
||||
const ImWchar *m_imgui_init_glyph_range;
|
||||
};
|
||||
|
||||
|
@ -210,3 +210,62 @@ void WxFontUtils::update_property(FontProp &font_prop, const wxFont &font)
|
||||
if (it != from_weight.end()) font_prop.weight = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
bool WxFontUtils::is_italic(const wxFont &font) {
|
||||
wxFontStyle wx_style = font.GetStyle();
|
||||
return wx_style == wxFONTSTYLE_ITALIC ||
|
||||
wx_style == wxFONTSTYLE_SLANT;
|
||||
}
|
||||
|
||||
bool WxFontUtils::is_bold(const wxFont &font) {
|
||||
wxFontWeight wx_weight = font.GetWeight();
|
||||
return wx_weight != wxFONTWEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
bool WxFontUtils::set_italic(wxFont &font, std::shared_ptr<Emboss::FontFile>& font_file)
|
||||
{
|
||||
static std::vector<wxFontStyle> italic_styles = {
|
||||
wxFontStyle::wxFONTSTYLE_ITALIC,
|
||||
wxFontStyle::wxFONTSTYLE_SLANT
|
||||
};
|
||||
if (font_file == nullptr)
|
||||
font_file = WxFontUtils::load_font(font);
|
||||
|
||||
for (wxFontStyle style : italic_styles) {
|
||||
font.SetStyle(style);
|
||||
std::unique_ptr<Emboss::FontFile> act_font_file = WxFontUtils::load_font(font);
|
||||
if (act_font_file == nullptr) continue;
|
||||
|
||||
// is still same font file pointer?
|
||||
if (font_file != nullptr)
|
||||
if (act_font_file->buffer == font_file->buffer) continue;
|
||||
|
||||
font_file = std::move(act_font_file);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WxFontUtils::set_bold(wxFont &font, std::shared_ptr<Emboss::FontFile>& font_file)
|
||||
{
|
||||
static std::vector<wxFontWeight> bold_weight = {
|
||||
wxFontWeight::wxFONTWEIGHT_BOLD,
|
||||
wxFontWeight::wxFONTWEIGHT_HEAVY,
|
||||
wxFontWeight::wxFONTWEIGHT_EXTRABOLD,
|
||||
wxFontWeight::wxFONTWEIGHT_EXTRAHEAVY
|
||||
};
|
||||
if (font_file == nullptr)
|
||||
font_file = WxFontUtils::load_font(font);
|
||||
|
||||
for (wxFontWeight weight : bold_weight) {
|
||||
font.SetWeight(weight);
|
||||
std::unique_ptr<Emboss::FontFile> act_font_file = WxFontUtils::load_font(font);
|
||||
if (act_font_file == nullptr) continue;
|
||||
if (font_file != nullptr)
|
||||
// is still same font?
|
||||
if (act_font_file->buffer == font_file->buffer) continue;
|
||||
font_file = std::move(act_font_file);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
@ -27,8 +27,7 @@ public:
|
||||
|
||||
// serialize / deserialize font
|
||||
static std::string store_wxFont(const wxFont &font);
|
||||
static std::optional<wxFont> load_wxFont(
|
||||
const std::string &font_descriptor);
|
||||
static std::optional<wxFont> load_wxFont(const std::string &font_descriptor);
|
||||
|
||||
// Try to create similar font, loaded from 3mf from different Computer
|
||||
static std::optional<wxFont> create_wxFont(const FontItem &fi,
|
||||
@ -36,6 +35,21 @@ public:
|
||||
// update font property by wxFont
|
||||
static void update_property(FontProp &font_prop, const wxFont &font);
|
||||
|
||||
static bool is_italic(const wxFont &font);
|
||||
static bool is_bold(const wxFont &font);
|
||||
|
||||
// Font could not support italic than return FALSE.
|
||||
// For check of support is neccessary font file pointer.
|
||||
// Font file is optional it could be created inside of function, but it slow down.
|
||||
// To not load font file twice on success font_file contain new created font file.
|
||||
static bool set_italic(wxFont &font, std::shared_ptr<Emboss::FontFile>& font_file = std::shared_ptr<Emboss::FontFile>());
|
||||
|
||||
// Font could not support bold than return FALSE.
|
||||
// For check of support is neccessary font file pointer.
|
||||
// Font file is optional it could be created inside of function, but it slow down.
|
||||
// To not load font file twice on success font_file contain new created font file.
|
||||
static bool set_bold(wxFont &font, std::shared_ptr<Emboss::FontFile>& font_file = std::shared_ptr<Emboss::FontFile>());
|
||||
|
||||
// map to convert wxFont type to string and vice versa
|
||||
static const std::map<wxFontFamily, std::string> from_family;
|
||||
static const std::map<std::string, wxFontFamily> to_family;
|
||||
|
Loading…
Reference in New Issue
Block a user