From 58896c67fdc310f5501990afd758da23ff64d3c0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 16 Feb 2022 17:23:59 +0300 Subject: fixes #3033 ("Gap between buttons" option is broken) --- include/m_message.h | 3 +++ libs/win32/mir_app.lib | Bin 224272 -> 224502 bytes libs/win64/mir_app.lib | Bin 220002 -> 220212 bytes plugins/Scriver/src/utils.cpp | 2 +- plugins/TabSRMM/src/buttonsbar.cpp | 4 ++-- src/core/stdmsg/src/globals.cpp | 1 - src/core/stdmsg/src/globals.h | 1 - src/core/stdmsg/src/msgs.cpp | 6 +++--- src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + src/mir_app/src/srmm_toolbar.cpp | 13 ++++++++++--- src/mir_core/src/mir_core.def | 1 + src/mir_core/src/mir_core64.def | 1 + 13 files changed, 23 insertions(+), 11 deletions(-) diff --git a/include/m_message.h b/include/m_message.h index 08694e5bd0..731314d8a1 100644 --- a/include/m_message.h +++ b/include/m_message.h @@ -251,6 +251,9 @@ EXTERN_C MIR_APP_DLL(int) Srmm_ModifyButton(BBButton *bbdi); // returns 0 on success and nonzero value otherwise EXTERN_C MIR_APP_DLL(int) Srmm_RemoveButton(BBButton *bbdi); +// gets a gab between buttons in a toolbar +EXTERN_C MIR_APP_DLL(int) Srmm_GetButtonGap(); + // retrieves data from a toolbar button to a structure // returns 0 on success and nonzero value otherwise EXTERN_C MIR_APP_DLL(int) Srmm_GetButtonState(HWND hwndDlg, BBButton *bbdi); diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib index 07f3067d3c..521b025b7a 100644 Binary files a/libs/win32/mir_app.lib and b/libs/win32/mir_app.lib differ diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib index e1c0110e62..fd9472c8ec 100644 Binary files a/libs/win64/mir_app.lib and b/libs/win64/mir_app.lib differ diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index b253ccdddf..a2702075f5 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -250,7 +250,7 @@ void SetButtonsPos(HWND hwndDlg, MCONTACT hContact, bool bShow) pt.y -= 20; int iLeftX = 2, iRightX = rc.right - rc.left - 2; - int iGap = g_plugin.getByte("ButtonsBarGap", 1); + int iGap = Srmm_GetButtonGap(); CustomButtonData *cbd; for (int i = 0; cbd = Srmm_GetNthButton(i); i++) { diff --git a/plugins/TabSRMM/src/buttonsbar.cpp b/plugins/TabSRMM/src/buttonsbar.cpp index 535937acf4..c9f815b7b5 100644 --- a/plugins/TabSRMM/src/buttonsbar.cpp +++ b/plugins/TabSRMM/src/buttonsbar.cpp @@ -141,7 +141,7 @@ static int CB_InitDefaultButtons(WPARAM, LPARAM) void CMsgDialog::BB_InitDlgButtons() { - uint8_t gap = DPISCALEX_S(g_plugin.getByte("ButtonsBarGap", 1)); + uint8_t gap = DPISCALEX_S(Srmm_GetButtonGap()); RECT rcSplitter; GetWindowRect(GetDlgItem(m_hwnd, IDC_SPLITTERY), &rcSplitter); @@ -203,7 +203,7 @@ BOOL CMsgDialog::BB_SetButtonsPos() if (!m_hwnd || !IsWindowVisible(m_hwnd)) return 0; - uint8_t gap = DPISCALEX_S(g_plugin.getByte("ButtonsBarGap", 1)); + uint8_t gap = DPISCALEX_S(Srmm_GetButtonGap()); bool showToolbar = !m_pContainer->m_flags.m_bHideToolbar; bool bBottomToolbar = m_pContainer->m_flags.m_bBottomToolbar; diff --git a/src/core/stdmsg/src/globals.cpp b/src/core/stdmsg/src/globals.cpp index 86ec29130a..a2d6e175fe 100644 --- a/src/core/stdmsg/src/globals.cpp +++ b/src/core/stdmsg/src/globals.cpp @@ -136,7 +136,6 @@ GlobalMessageData::GlobalMessageData() : popupFlags(SRMMMOD, "PopupFlags", 0), nFlashMax(SRMMMOD, "FlashMax", 5), - iGap(SRMSGMOD, "ButtonsBarGap", 1), msgTimeout(SRMMMOD, "MessageTimeout", 65000), diff --git a/src/core/stdmsg/src/globals.h b/src/core/stdmsg/src/globals.h index f44a4521b7..031357356b 100644 --- a/src/core/stdmsg/src/globals.h +++ b/src/core/stdmsg/src/globals.h @@ -60,7 +60,6 @@ struct GlobalMessageData CMOption popupFlags; CMOption msgTimeout; CMOption nFlashMax; - CMOption iGap; CMOption iLoadHistory; CMOption nLoadCount, nLoadTime; diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 1dc1bf4341..23f9bf5702 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -412,7 +412,7 @@ void SetButtonsPos(HWND hwndDlg, bool bIsChat) else yPos = 2; GetClientRect(hwndDlg, &rc); - int iLeftX = 2, iRightX = rc.right - 2; + int iLeftX = 2, iRightX = rc.right - 2, iGap = Srmm_GetButtonGap(); CustomButtonData *cbd; for (int i = 0; cbd = Srmm_GetNthButton(i); i++) { @@ -421,12 +421,12 @@ void SetButtonsPos(HWND hwndDlg, bool bIsChat) continue; if (cbd->m_bRSided) { - iRightX -= g_dat.iGap + cbd->m_iButtonWidth; + iRightX -= iGap + cbd->m_iButtonWidth; hdwp = DeferWindowPos(hdwp, hwndButton, nullptr, iRightX, yPos, 0, 0, SWP_NOZORDER | SWP_NOSIZE); } else { hdwp = DeferWindowPos(hdwp, hwndButton, nullptr, iLeftX, yPos, 0, 0, SWP_NOZORDER | SWP_NOSIZE); - iLeftX += g_dat.iGap + cbd->m_iButtonWidth; + iLeftX += iGap + cbd->m_iButtonWidth; } } diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 20befc32d3..e4dd6236b9 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -792,3 +792,4 @@ _Netlib_SslWrite@12 @877 NONAME ?SafeRecycleBin@PU@@YGHPB_W@Z @880 NONAME ?IsMirandaFolderWritable@PU@@YG_NXZ @881 NONAME ?IsDuplicateEvent@DB@@YG_NIAAUDBEVENTINFO@@@Z @882 NONAME +Srmm_GetButtonGap @883 diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 0330b8708a..b8b265a9d3 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -792,3 +792,4 @@ Netlib_SslWrite @877 NONAME ?SafeRecycleBin@PU@@YAHPEB_W@Z @880 NONAME ?IsMirandaFolderWritable@PU@@YA_NXZ @881 NONAME ?IsDuplicateEvent@DB@@YA_NIAEAUDBEVENTINFO@@@Z @882 NONAME +Srmm_GetButtonGap @883 diff --git a/src/mir_app/src/srmm_toolbar.cpp b/src/mir_app/src/srmm_toolbar.cpp index ac52b6b296..7d4b45bf8f 100644 --- a/src/mir_app/src/srmm_toolbar.cpp +++ b/src/mir_app/src/srmm_toolbar.cpp @@ -32,6 +32,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static double g_DPIscaleX, g_DPIscaleY; +static CMOption g_iButtonGap(BB_MODULE_NAME, "ButtonsBarGap", 1); + static int SortButtons(const CustomButtonData *p1, const CustomButtonData *p2) { if (p1->m_bRSided != p2->m_bRSided) @@ -79,6 +81,11 @@ MIR_APP_DLL(int) Srmm_GetButtonCount(void) return arButtonsList.getCount(); } +MIR_APP_DLL(int) Srmm_GetButtonGap() +{ + return g_iButtonGap; +} + MIR_APP_DLL(HANDLE) Srmm_AddButton(const BBButton *bbdi, HPLUGIN _hLang) { if (bbdi == nullptr) @@ -624,7 +631,7 @@ public: m_btnChat.Disable(); m_btnHidden.Disable(); - m_gap.SetPosition(db_get_b(0, BB_MODULE_NAME, "ButtonsBarGap", 1)); + m_gap.SetPosition(g_iButtonGap); return true; } @@ -641,9 +648,9 @@ public: CB_ReInitCustomButtons(); uint16_t newGap = m_gap.GetPosition(); - if (newGap != db_get_b(0, BB_MODULE_NAME, "ButtonsBarGap", 1)) { + if (newGap != g_iButtonGap) { + g_iButtonGap = newGap; WindowList_BroadcastAsync(g_hWindowList, WM_SIZE, 0, 0); - db_set_b(0, BB_MODULE_NAME, "ButtonsBarGap", newGap); } BuildMenuObjectsTree(); diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index bcfad9a713..4eddd40de0 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1514,3 +1514,4 @@ TimeZone_GetSystemTime @1692 db_copy_module @1736 ?db_is_module_empty@@YG_NIPBD@Z @1737 NONAME ?AddOption@CCtrlTreeOpts@@QAEXPB_W0AA_N@Z @1738 NONAME +?AddOption@CCtrlTreeOpts@@QAEXPB_W0AAII@Z @1739 NONAME diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 030e27b5c1..eb527bf8be 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1514,3 +1514,4 @@ TimeZone_GetSystemTime @1692 db_copy_module @1736 ?db_is_module_empty@@YA_NIPEBD@Z @1737 NONAME ?AddOption@CCtrlTreeOpts@@QEAAXPEB_W0AEA_N@Z @1738 NONAME +?AddOption@CCtrlTreeOpts@@QEAAXPEB_W0AEAII@Z @1739 NONAME -- cgit v1.2.3