From 7043ef76cce7a0ad4ddb37592310cdda74a1cbcc Mon Sep 17 00:00:00 2001 From: zufuliu Date: Sat, 24 Apr 2021 08:08:24 +0800 Subject: [PATCH] Add "Always on Top" button on toolbar, issue #280. --- License.txt | 28 ++++++++++++++++++++++++++++ locale/de/Notepad2.rc | 1 + locale/it/Notepad2.rc | 1 + locale/ja/Notepad2.rc | 1 + locale/ko/Notepad2.rc | 1 + locale/zh-Hans/Notepad2.rc | 1 + locale/zh-Hant/Notepad2.rc | 1 + res/Toolbar.bmp | Bin 25654 -> 26678 bytes src/Helpers.h | 4 ++-- src/Notepad2.c | 6 ++++++ src/Notepad2.rc | 1 + src/resource.h | 1 + tools/ImageTool.py | 5 +++-- tools/images/pin-angle-16x.png | Bin 0 -> 340 bytes tools/images/pin-angle.svg | 3 +++ tools/readme.txt | 6 +++++- 16 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 tools/images/pin-angle-16x.png create mode 100644 tools/images/pin-angle.svg diff --git a/License.txt b/License.txt index 6cb4f1ecaa..ff2581b856 100644 --- a/License.txt +++ b/License.txt @@ -181,3 +181,31 @@ https://github.com/zwegner/faster-utf8-validator // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. + + +================================================================================ + +Visual Studio 2017 Image Library + +https://www.microsoft.com/en-us/download/details.aspx?id=35825 +http://download.microsoft.com/download/0/6/0/0607D8EA-9BB7-440B-A36A-A24EB8C9C67E/Visual%20Studio%202017%20Image%20Library%20EULA.RTF + + +================================================================================ +Bootstrap Icons + +https://github.com/twbs/icons +https://github.com/twbs/icons/blob/main/LICENSE.md + + + +The MIT License (MIT) + +Copyright (c) 2019-2020 The Bootstrap Authors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/locale/de/Notepad2.rc b/locale/de/Notepad2.rc index f9fa8d5419..2ccd2700c9 100644 --- a/locale/de/Notepad2.rc +++ b/locale/de/Notepad2.rc @@ -1906,6 +1906,7 @@ BEGIN IDT_FILE_ADDTOFAV "Add to Favorites" IDT_VIEW_TOGGLEFOLDS "Toggle Folds" IDT_FILE_LAUNCH "Execute Document" + IDT_VIEW_ALWAYSONTOP "Always On Top" END STRINGTABLE diff --git a/locale/it/Notepad2.rc b/locale/it/Notepad2.rc index 3f60e431e3..55d8632335 100644 --- a/locale/it/Notepad2.rc +++ b/locale/it/Notepad2.rc @@ -1906,6 +1906,7 @@ BEGIN IDT_FILE_ADDTOFAV "Add to Favorites" IDT_VIEW_TOGGLEFOLDS "Toggle Folds" IDT_FILE_LAUNCH "Execute Document" + IDT_VIEW_ALWAYSONTOP "Always On Top" END STRINGTABLE diff --git a/locale/ja/Notepad2.rc b/locale/ja/Notepad2.rc index 29d2719963..c64f91712e 100644 --- a/locale/ja/Notepad2.rc +++ b/locale/ja/Notepad2.rc @@ -1906,6 +1906,7 @@ BEGIN IDT_FILE_ADDTOFAV "お気に入りに追加" IDT_VIEW_TOGGLEFOLDS "折りたたみの切り替え" IDT_FILE_LAUNCH "開いている文書を実行" + IDT_VIEW_ALWAYSONTOP "常に手前に表示" END STRINGTABLE diff --git a/locale/ko/Notepad2.rc b/locale/ko/Notepad2.rc index 06f13c5858..1536e6f1ae 100644 --- a/locale/ko/Notepad2.rc +++ b/locale/ko/Notepad2.rc @@ -1906,6 +1906,7 @@ BEGIN IDT_FILE_ADDTOFAV "즐겨찾기에 추가" IDT_VIEW_TOGGLEFOLDS "접기 전환" IDT_FILE_LAUNCH "문서 실행" + IDT_VIEW_ALWAYSONTOP "항상 맨 위" END STRINGTABLE diff --git a/locale/zh-Hans/Notepad2.rc b/locale/zh-Hans/Notepad2.rc index ddb21971e8..7cefae4e79 100644 --- a/locale/zh-Hans/Notepad2.rc +++ b/locale/zh-Hans/Notepad2.rc @@ -1906,6 +1906,7 @@ BEGIN IDT_FILE_ADDTOFAV "添加到收藏夹" IDT_VIEW_TOGGLEFOLDS "切换折叠" IDT_FILE_LAUNCH "运行文件" + IDT_VIEW_ALWAYSONTOP "始终置顶" END STRINGTABLE diff --git a/locale/zh-Hant/Notepad2.rc b/locale/zh-Hant/Notepad2.rc index f09f2a96c1..87d70e120b 100644 --- a/locale/zh-Hant/Notepad2.rc +++ b/locale/zh-Hant/Notepad2.rc @@ -1906,6 +1906,7 @@ BEGIN IDT_FILE_ADDTOFAV "新增到我的最愛" IDT_VIEW_TOGGLEFOLDS "切換折疊" IDT_FILE_LAUNCH "執行檔案" + IDT_VIEW_ALWAYSONTOP "始終置頂" END STRINGTABLE diff --git a/res/Toolbar.bmp b/res/Toolbar.bmp index 0be2c313d7bf1e1c496ba63e2cee50c54e52c098..2a47603f157c42042ba64b47b2db49cb858825b3 100644 GIT binary patch delta 667 zcmZ9JO-n*S6o#+n9mUi#4ZCS(aQh%_aU;Yabchzx$07`h!WOOi0p+5Fzro=KMJu6* zXjcQ$N?I7SY!mHj7gSIb(NcQPl^fE5XJ*cs_nb2ywOdE+&XJm3N^dKcr7@0yszXt_ zF*}q5Mi}-R0ph~YT!O1|-ZkYEoXaxHF|`QAxG-j9-IrsYB)k`3es+b`0v0>MNXTXn zXF41XXqRT&*06X6Umz%qn9OP|F$p-Z6Kr7$u?LVOae0t4bI;wWk@5{tDN>MqfGDZz z!!6Z7dkss1;TY6_TNr(^ndHn)UqO({O@MamfO7(_fJYc%GhK|CfsjXTO~#lHLAtkf z4q-%kU2x6-wa|bQD6*8vvkVry;2Ye7cW??Qqut1-essM@5SO)VD;tgy0(9aipdQrg ze+B%gasV2@D}Uzl^k$(U2KN%213QJJ```xn&DX_*S;=_h`hrd=5zUP-b*Tc99s;WB xH%AJ(B|Tc!nV60S`w^uR|0(cNvc9^({PccLz{(RwMV2 zZQjRb&$ii?*MV*GUSUVJ&2~~i);KUn&@b@i4L)w&5{nV0sy{-F8Tlf diff --git a/src/Helpers.h b/src/Helpers.h index 9a2f6f0e29..e131659221 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -755,8 +755,8 @@ BOOL StatusSetTextID(HWND hwnd, UINT nPart, UINT uID); int StatusCalcPaneWidth(HWND hwnd, LPCWSTR lpsz); /** - * we only have 25 commands in toolbar - * max size = 25*(3 + 2) + 1 (each command with a separator) + * we only have 26 commands in toolbar + * max size = 26*(3 + 2) + 1 (each command with a separator) */ #define MAX_TOOLBAR_ITEM_COUNT_WITH_SEPARATOR 50 #define MAX_TOOLBAR_BUTTON_CONFIG_BUFFER_SIZE 160 diff --git a/src/Notepad2.c b/src/Notepad2.c index 4451e64073..2df3a7440d 100644 --- a/src/Notepad2.c +++ b/src/Notepad2.c @@ -93,6 +93,7 @@ static TBBUTTON tbbMainWnd[] = { {22, IDT_FILE_ADDTOFAV, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, {23, IDT_VIEW_TOGGLEFOLDS, TBSTATE_ENABLED, BTNS_WHOLEDROPDOWN, {0}, 0, 0}, {24, IDT_FILE_LAUNCH, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, + {25, IDT_VIEW_ALWAYSONTOP, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, }; WCHAR szIniFile[MAX_PATH] = L""; @@ -4210,6 +4211,7 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) { flagAlwaysOnTop = 0; SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } + UpdateToolbar(); break; case IDM_VIEW_MINTOTRAY: @@ -4854,6 +4856,9 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) { SendWMCommandOrBeep(hwnd, IDM_FILE_LAUNCH); break; + case IDT_VIEW_ALWAYSONTOP: + SendWMCommandOrBeep(hwnd, IDM_VIEW_ALWAYSONTOP); + break; } return 0; @@ -6863,6 +6868,7 @@ void UpdateToolbar(void) { EnableTool(IDT_FILE_LAUNCH, i); CheckTool(IDT_VIEW_WORDWRAP, fvCurFile.fWordWrap); + CheckTool(IDT_VIEW_ALWAYSONTOP, IsTopMost()); } //============================================================================= diff --git a/src/Notepad2.rc b/src/Notepad2.rc index dd9bbb3783..e58addb416 100644 --- a/src/Notepad2.rc +++ b/src/Notepad2.rc @@ -1906,6 +1906,7 @@ BEGIN IDT_FILE_ADDTOFAV "Add to Favorites" IDT_VIEW_TOGGLEFOLDS "Toggle Folds" IDT_FILE_LAUNCH "Execute Document" + IDT_VIEW_ALWAYSONTOP "Always On Top" END STRINGTABLE diff --git a/src/resource.h b/src/resource.h index e7e0f208f7..fed865a476 100644 --- a/src/resource.h +++ b/src/resource.h @@ -725,6 +725,7 @@ #define IDT_FILE_ADDTOFAV 40722 #define IDT_VIEW_TOGGLEFOLDS 40723 #define IDT_FILE_LAUNCH 40724 +#define IDT_VIEW_ALWAYSONTOP 40725 #define IDM_LANG_USER_DEFAULT 40900 #define IDM_LANG_ENGLISH_US 40901 diff --git a/tools/ImageTool.py b/tools/ImageTool.py index 2b7130b948..61d2dada58 100644 --- a/tools/ImageTool.py +++ b/tools/ImageTool.py @@ -228,9 +228,10 @@ def make_notepad2_toolbar_bitmap(): 'images/.png', # IDT_FILE_LAUNCH ], 'Toolbar.bmp') -make_matapath_toolbar_bitmap() +#make_matapath_toolbar_bitmap() #make_notepad2_toolbar_bitmap() -convert_image('images/OpenFolder_16x.png', 'OpenFolder.bmp') +#convert_image('images/OpenFolder_16x.png', 'OpenFolder.bmp') +#concat_horizontal(['../res/Toolbar.bmp', 'images/pin-angle-16x.png'], 'Toolbar.bmp') #split_horizontal('Toolbar.bmp', '16x40') diff --git a/tools/images/pin-angle-16x.png b/tools/images/pin-angle-16x.png new file mode 100644 index 0000000000000000000000000000000000000000..61948469598d44a21dd3c076591c32d28df8880d GIT binary patch literal 340 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F5he4R}c>anMprB-l zYeY$Kep*R+Vo@qXd3m{BW?pu2a$-TMUVc&f>~}U&Kt&HdT^vI!dbeJ*_hNRGXn&Y~ zHc2HzQA~-EKj91CJw-9IdrtXE8JZF9dd3(N!FY!P+|5a3VPc)!i`T-x?;gU z-_(}-Mfv9@CB2gcLcVo2Zv^*!Xef_SIb!Knad`5h@?|_9g?NLWT+C?VHI?5Wu4Zlg zd#=a6gF(Irru=o8{MqB3S!ZH+;qg@`+aD!Hcg82LHLE=GK>yLCOHYJXe?HROvLmJA i@Ukz=Ii|dSx$hg>YD|k@ejo_+EQ6=3pUXO@geCxvABLO& literal 0 HcmV?d00001 diff --git a/tools/images/pin-angle.svg b/tools/images/pin-angle.svg new file mode 100644 index 0000000000..a07b038e60 --- /dev/null +++ b/tools/images/pin-angle.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/tools/readme.txt b/tools/readme.txt index c37152912f..3d55f86379 100644 --- a/tools/readme.txt +++ b/tools/readme.txt @@ -2,5 +2,9 @@ images: Visual Studio Image Library 2017 https://www.microsoft.com/en-us/download/details.aspx?id=35825 - file original + file original name RedCrossMark TestCoveredFailing + + Bootstrap Icons + https://github.com/twbs/icons + pin-angle.svg