mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Add !SkinCustomMenu bang that displays the user-defined context menu items only
This commit is contained in:
parent
feb90f35d2
commit
d0fd184063
@ -100,7 +100,8 @@ const BangInfo s_Bangs[] =
|
|||||||
{ Bang::PauseMeasureGroup, L"PauseMeasureGroup", 1 },
|
{ Bang::PauseMeasureGroup, L"PauseMeasureGroup", 1 },
|
||||||
{ Bang::UnpauseMeasureGroup, L"UnpauseMeasureGroup", 1 },
|
{ Bang::UnpauseMeasureGroup, L"UnpauseMeasureGroup", 1 },
|
||||||
{ Bang::TogglePauseMeasureGroup, L"TogglePauseMeasureGroup", 1 },
|
{ Bang::TogglePauseMeasureGroup, L"TogglePauseMeasureGroup", 1 },
|
||||||
{ Bang::UpdateMeasureGroup, L"UpdateMeasureGroup", 1 }
|
{ Bang::UpdateMeasureGroup, L"UpdateMeasureGroup", 1 },
|
||||||
|
{ Bang::SkinCustomMenu, L"SkinCustomMenu", 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Bangs that are to be handled with DoGroupBang().
|
// Bangs that are to be handled with DoGroupBang().
|
||||||
|
@ -106,6 +106,7 @@ enum class Bang
|
|||||||
About,
|
About,
|
||||||
Manage,
|
Manage,
|
||||||
SkinMenu,
|
SkinMenu,
|
||||||
|
SkinCustomMenu,
|
||||||
TrayMenu,
|
TrayMenu,
|
||||||
ResetStats,
|
ResetStats,
|
||||||
Log,
|
Log,
|
||||||
|
@ -170,6 +170,21 @@ void ContextMenu::ShowMenu(POINT pos, MeterWindow* meterWindow)
|
|||||||
m_MenuActive = false;
|
m_MenuActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContextMenu::ShowSkinCustomMenu(POINT pos, MeterWindow* meterWindow)
|
||||||
|
{
|
||||||
|
if (m_MenuActive || meterWindow->IsClosing()) return;
|
||||||
|
|
||||||
|
m_MenuActive = true;
|
||||||
|
|
||||||
|
HMENU menu = CreatePopupMenu();
|
||||||
|
AppendSkinCustomMenu(meterWindow, 0, menu, true);
|
||||||
|
|
||||||
|
DisplayMenu(pos, menu, meterWindow->GetWindow());
|
||||||
|
DestroyMenu(menu);
|
||||||
|
|
||||||
|
m_MenuActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
void ContextMenu::DisplayMenu(POINT pos, HMENU menu, HWND parentWindow)
|
void ContextMenu::DisplayMenu(POINT pos, HMENU menu, HWND parentWindow)
|
||||||
{
|
{
|
||||||
// Set the window to foreground
|
// Set the window to foreground
|
||||||
@ -428,12 +443,13 @@ HMENU ContextMenu::CreateSkinMenu(MeterWindow* meterWindow, int index, HMENU men
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendSkinCustomMenu(meterWindow, index, skinMenu);
|
AppendSkinCustomMenu(meterWindow, index, skinMenu, false);
|
||||||
|
|
||||||
return skinMenu;
|
return skinMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContextMenu::AppendSkinCustomMenu(MeterWindow* meterWindow, int index, HMENU menu)
|
void ContextMenu::AppendSkinCustomMenu(
|
||||||
|
MeterWindow* meterWindow, int index, HMENU menu, bool standaloneMenu)
|
||||||
{
|
{
|
||||||
// Add custom actions to the context menu
|
// Add custom actions to the context menu
|
||||||
std::wstring contextTitle = meterWindow->GetParser().ReadString(L"Rainmeter", L"ContextTitle", L"");
|
std::wstring contextTitle = meterWindow->GetParser().ReadString(L"Rainmeter", L"ContextTitle", L"");
|
||||||
@ -477,7 +493,7 @@ void ContextMenu::AppendSkinCustomMenu(MeterWindow* meterWindow, int index, HMEN
|
|||||||
|
|
||||||
// Build a sub-menu if more than three items
|
// Build a sub-menu if more than three items
|
||||||
const size_t titleSize = cTitles.size();
|
const size_t titleSize = cTitles.size();
|
||||||
if (titleSize <= 3)
|
if (titleSize <= 3 || standaloneMenu)
|
||||||
{
|
{
|
||||||
size_t position = 0;
|
size_t position = 0;
|
||||||
for (size_t i = 0; i < titleSize; ++i)
|
for (size_t i = 0; i < titleSize; ++i)
|
||||||
@ -496,7 +512,7 @@ void ContextMenu::AppendSkinCustomMenu(MeterWindow* meterWindow, int index, HMEN
|
|||||||
++position;
|
++position;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position != 0)
|
if (position != 0 && !standaloneMenu)
|
||||||
{
|
{
|
||||||
InsertMenu(menu, 1, MF_BYPOSITION | MF_STRING | MF_GRAYED, 0, L"Custom skin actions");
|
InsertMenu(menu, 1, MF_BYPOSITION | MF_STRING | MF_GRAYED, 0, L"Custom skin actions");
|
||||||
InsertMenu(menu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, nullptr);
|
InsertMenu(menu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, nullptr);
|
||||||
|
@ -35,6 +35,7 @@ public:
|
|||||||
bool IsMenuActive() { return m_MenuActive; }
|
bool IsMenuActive() { return m_MenuActive; }
|
||||||
|
|
||||||
void ShowMenu(POINT pos, MeterWindow* meterWindow);
|
void ShowMenu(POINT pos, MeterWindow* meterWindow);
|
||||||
|
void ShowSkinCustomMenu(POINT pos, MeterWindow* meterWindow);
|
||||||
|
|
||||||
static void CreateMonitorMenu(HMENU monitorMenu, MeterWindow* meterWindow);
|
static void CreateMonitorMenu(HMENU monitorMenu, MeterWindow* meterWindow);
|
||||||
|
|
||||||
@ -42,7 +43,8 @@ private:
|
|||||||
static void DisplayMenu(POINT pos, HMENU menu, HWND parentWindow);
|
static void DisplayMenu(POINT pos, HMENU menu, HWND parentWindow);
|
||||||
|
|
||||||
static HMENU CreateSkinMenu(MeterWindow* meterWindow, int index, HMENU menu);
|
static HMENU CreateSkinMenu(MeterWindow* meterWindow, int index, HMENU menu);
|
||||||
static void AppendSkinCustomMenu(MeterWindow* meterWindow, int index, HMENU menu);
|
static void AppendSkinCustomMenu(
|
||||||
|
MeterWindow* meterWindow, int index, HMENU menu, bool standaloneMenu);
|
||||||
static void ChangeSkinIndex(HMENU subMenu, int index);
|
static void ChangeSkinIndex(HMENU subMenu, int index);
|
||||||
|
|
||||||
static void CreateAllSkinsMenu(HMENU skinMenu) { CreateAllSkinsMenuRecursive(skinMenu, 0); }
|
static void CreateAllSkinsMenu(HMENU skinMenu) { CreateAllSkinsMenuRecursive(skinMenu, 0); }
|
||||||
|
@ -980,6 +980,10 @@ void MeterWindow::DoBang(Bang bang, const std::vector<std::wstring>& args)
|
|||||||
case Bang::SetOptionGroup:
|
case Bang::SetOptionGroup:
|
||||||
SetOption(args[0], args[1], args[2], true);
|
SetOption(args[0], args[1], args[2], true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Bang::SkinCustomMenu:
|
||||||
|
Rainmeter::GetInstance().ShowSkinCustomContextMenu(System::GetCursorPosition(), this);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +166,7 @@ public:
|
|||||||
|
|
||||||
bool IsMenuActive() { return m_ContextMenu.IsMenuActive(); }
|
bool IsMenuActive() { return m_ContextMenu.IsMenuActive(); }
|
||||||
void ShowContextMenu(POINT pos, MeterWindow* mw) { return m_ContextMenu.ShowMenu(pos, mw); }
|
void ShowContextMenu(POINT pos, MeterWindow* mw) { return m_ContextMenu.ShowMenu(pos, mw); }
|
||||||
|
void ShowSkinCustomContextMenu(POINT pos, MeterWindow* mw) { return m_ContextMenu.ShowSkinCustomMenu(pos, mw); }
|
||||||
|
|
||||||
const std::wstring& GetTrayExecuteR() { return m_TrayExecuteR; }
|
const std::wstring& GetTrayExecuteR() { return m_TrayExecuteR; }
|
||||||
const std::wstring& GetTrayExecuteM() { return m_TrayExecuteM; }
|
const std::wstring& GetTrayExecuteM() { return m_TrayExecuteM; }
|
||||||
|
Loading…
Reference in New Issue
Block a user