summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-04-04 16:02:56 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-04-04 16:02:56 +0300
commite230d5b323f08f9bf07cfd4822f22a22c22660b7 (patch)
treeab84396539f13100ba119cbc5b2575b374c8f503
parent8937c49faab219b51b9863847406a21945d3a9cb (diff)
fix for adding separators into SRMM toolbar
-rw-r--r--include/m_message.h4
-rw-r--r--plugins/MirLua/src/m_srmm.cpp4
-rw-r--r--src/mir_app/src/srmm_toolbar.cpp32
3 files changed, 20 insertions, 20 deletions
diff --git a/include/m_message.h b/include/m_message.h
index d21bed5c7c..7c33127ce9 100644
--- a/include/m_message.h
+++ b/include/m_message.h
@@ -240,8 +240,8 @@ struct BBButton
};
// adds a new toolbar button
-// returns 0 on success and nonzero value otherwise
-EXTERN_C MIR_APP_DLL(int) Srmm_AddButton(const BBButton *bbdi, int = hLangpack);
+// returns button's handle on success or NULL otherwise
+EXTERN_C MIR_APP_DLL(HANDLE) Srmm_AddButton(const BBButton *bbdi, int = hLangpack);
// modifies the existing toolbar button
// returns 0 on success and nonzero value otherwise
diff --git a/plugins/MirLua/src/m_srmm.cpp b/plugins/MirLua/src/m_srmm.cpp
index 9a98755380..8ec739bd27 100644
--- a/plugins/MirLua/src/m_srmm.cpp
+++ b/plugins/MirLua/src/m_srmm.cpp
@@ -48,10 +48,10 @@ static int lua_AddButton(lua_State *L)
MakeBBButton(L, bbb);
int hScriptLangpack = CMLuaEnvironment::GetEnvironmentId(L);
- INT_PTR res = Srmm_AddButton(&bbb, hScriptLangpack);
+ HANDLE res = Srmm_AddButton(&bbb, hScriptLangpack);
CleanBBButton(bbb);
- if (res)
+ if (!res)
{
lua_pushnil(L);
return 1;
diff --git a/src/mir_app/src/srmm_toolbar.cpp b/src/mir_app/src/srmm_toolbar.cpp
index f87fdf1376..04877338b6 100644
--- a/src/mir_app/src/srmm_toolbar.cpp
+++ b/src/mir_app/src/srmm_toolbar.cpp
@@ -79,17 +79,12 @@ MIR_APP_DLL(int) Srmm_GetButtonCount(void)
return arButtonsList.getCount();
}
-MIR_APP_DLL(int) Srmm_AddButton(const BBButton *bbdi, int _hLang)
+MIR_APP_DLL(HANDLE) Srmm_AddButton(const BBButton *bbdi, int _hLang)
{
if (bbdi == nullptr)
- return 1;
+ return nullptr;
CustomButtonData *cbd = new CustomButtonData();
- if (bbdi->bbbFlags & BBBF_ISARROWBUTTON)
- cbd->m_iButtonWidth = DPISCALEX_S(34);
- else
- cbd->m_iButtonWidth = DPISCALEX_S(22);
-
cbd->m_pszModuleName = mir_strdup(bbdi->pszModuleName);
cbd->m_pwszText = mir_wstrdup(bbdi->pwszText);
cbd->m_pwszTooltip = mir_wstrdup(bbdi->pwszTooltip);
@@ -111,6 +106,13 @@ MIR_APP_DLL(int) Srmm_AddButton(const BBButton *bbdi, int _hLang)
cbd->m_dwOrigFlags.bit3 = cbd->m_bChatButton = (bbdi->bbbFlags & BBBF_ISCHATBUTTON) != 0;
cbd->m_dwOrigFlags.bit4 = cbd->m_bCanBeHidden = (bbdi->bbbFlags & BBBF_CANBEHIDDEN) != 0;
+ if (cbd->m_bSeparator)
+ cbd->m_iButtonWidth = DPISCALEX_S(10);
+ else if (bbdi->bbbFlags & BBBF_ISARROWBUTTON)
+ cbd->m_iButtonWidth = DPISCALEX_S(34);
+ else
+ cbd->m_iButtonWidth = DPISCALEX_S(22);
+
if (bbdi->pszHotkey) {
for (auto &p : hotkeys) {
if (!mir_strcmp(p->getName(), bbdi->pszHotkey)) {
@@ -150,7 +152,7 @@ MIR_APP_DLL(int) Srmm_AddButton(const BBButton *bbdi, int _hLang)
LastCID++;
WindowList_Broadcast(g_hWindowList, WM_CBD_UPDATED, 0, 0);
- return 0;
+ return cbd;
}
MIR_APP_DLL(int) Srmm_GetButtonState(HWND hwndDlg, BBButton *bbdi)
@@ -678,19 +680,17 @@ public:
if (!hItem)
hItem = TVI_FIRST;
- CustomButtonData *cbd = new CustomButtonData();
- cbd->m_bSeparator = cbd->m_bHidden = cbd->m_bIMButton = true;
- cbd->m_dwButtonID = ++dwSepCount;
- cbd->m_pszModuleName = "Tabsrmm_sep";
- cbd->m_iButtonWidth = 22;
- cbd->m_opFlags = BBSF_NTBDESTRUCT;
- arButtonsList.insert(cbd);
+ BBButton bbd = {};
+ bbd.pszModuleName = "Tabsrmm_sep";
+ bbd.bbbFlags = BBBF_ISSEPARATOR | BBBF_ISIMBUTTON;
+ bbd.dwButtonID = ++dwSepCount;
+
+ CustomButtonData *cbd = (CustomButtonData*)Srmm_AddButton(&bbd);
TVINSERTSTRUCT tvis;
tvis.hParent = nullptr;
tvis.hInsertAfter = hItem;
tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
-
tvis.item.pszText = TranslateT("<Separator>");
tvis.item.iImage = tvis.item.iSelectedImage = -1;
tvis.item.lParam = (LPARAM)cbd;