Skip to content

Commit

Permalink
Added multiple skin selection feature. Adds the ability to select mul…
Browse files Browse the repository at this point in the history
…tiple skins and drag them around the screen or use the arrow keyboard keys to move the selected skins a small distance.

Options added: SelectedColor, DragGroup
  • Loading branch information
brianferguson committed Jul 6, 2017
1 parent 6c7baad commit 521e966
Show file tree
Hide file tree
Showing 11 changed files with 351 additions and 11 deletions.
8 changes: 8 additions & 0 deletions Library/ContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@ HMENU ContextMenu::CreateSkinMenu(Skin* skin, int index, HMENU menu)
{
CheckMenuItem(settingsMenu, IDM_SKIN_FAVORITE, MF_BYCOMMAND | MF_CHECKED);
}

// Disable options if skin is selected
if (skin->IsSelected())
{
EnableMenuItem(settingsMenu, IDM_SKIN_DRAGGABLE, MF_GRAYED);
EnableMenuItem(settingsMenu, IDM_SKIN_KEEPONSCREEN, MF_GRAYED);
EnableMenuItem(settingsMenu, IDM_SKIN_CLICKTHROUGH, MF_GRAYED);
}
}

// Add the name of the Skin to the menu
Expand Down
23 changes: 23 additions & 0 deletions Library/DialogManage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ void DialogManage::Open(const WCHAR* tabName, const WCHAR* param1, const WCHAR*
}
}

void DialogManage::UpdateSelectedSkinOptions(Skin* skin)
{
if (c_Dialog && c_Dialog->m_TabSkins.IsInitialized())
{
c_Dialog->m_TabSkins.UpdateSelected(skin);
}
}

void DialogManage::UpdateSkins(Skin* skin, bool deleted)
{
if (c_Dialog && c_Dialog->m_TabSkins.IsInitialized())
Expand Down Expand Up @@ -584,6 +592,21 @@ void DialogManage::TabSkins::Initialize()
m_HandleCommands = true;
}

void DialogManage::TabSkins::UpdateSelected(Skin* skin)
{
if (m_SkinWindow && m_SkinWindow == skin)
{
bool selected = skin->IsSelected();

HWND item = GetControl(Id_DraggableCheckBox);
EnableWindow(item, selected ? FALSE : TRUE);
item = GetControl(Id_KeepOnScreenCheckBox);
EnableWindow(item, selected ? FALSE : TRUE);
item = GetControl(Id_ClickThroughCheckBox);
EnableWindow(item, selected ? FALSE : TRUE);
}
}

/*
** Updates metadata and settings when changed.
**
Expand Down
3 changes: 3 additions & 0 deletions Library/DialogManage.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class DialogManage : public Dialog
static void Open(int tab = 0);
static void OpenSkin(Skin* skin);

static void UpdateSelectedSkinOptions(Skin* skin);

static void UpdateSkins(Skin* skin, bool deleted = false);
static void UpdateLayouts();

Expand Down Expand Up @@ -81,6 +83,7 @@ class DialogManage : public Dialog
void Create(HWND owner);
virtual void Initialize();

void UpdateSelected(Skin* skin);
void Update(Skin* skin, bool deleted);

static void SelectTreeItem(HWND tree, HTREEITEM item, LPCWSTR name);
Expand Down
23 changes: 23 additions & 0 deletions Library/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,29 @@ void Group::InitializeGroup(const std::wstring& groups)
}
}

bool Group::AddToGroup(const std::wstring& group)
{
if (!group.empty() && !BelongsToGroup(group))
{
if (!m_OldGroups.empty())
{
m_OldGroups.append(1, L'|');
}

m_OldGroups.append(group);

std::vector<std::wstring> vGroups = ConfigParser::Tokenize(group, L"|");
for (auto iter = vGroups.begin(); iter != vGroups.end(); ++iter)
{
m_Groups.insert(m_Groups.end(), CreateGroup(*iter));
}

return true;
}

return false;
}

bool Group::BelongsToGroup(const std::wstring& group) const
{
return (m_Groups.find(VerifyGroup(group)) != m_Groups.end());
Expand Down
9 changes: 5 additions & 4 deletions Library/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@
class __declspec(novtable) Group
{
public:
Group() {}
virtual ~Group() {}

Group(const Group& other) = delete;
Group& operator=(Group other) = delete;

bool BelongsToGroup(const std::wstring& group) const;
void InitializeGroup(const std::wstring& groups);

protected:
Group() {}
const std::unordered_set<std::wstring>& GetGroups() const { return m_Groups; }

void InitializeGroup(const std::wstring& groups);
bool AddToGroup(const std::wstring& group);
bool BelongsToGroup(const std::wstring& group) const;

private:
std::wstring& CreateGroup(std::wstring& str) const;
Expand Down
3 changes: 2 additions & 1 deletion Library/Meter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Meter::Meter(Skin* skin, const WCHAR* name) : Section(skin, name),
m_ToolTipWidth(),
m_ToolTipType(false),
m_ToolTipHidden(skin->GetMeterToolTipHidden()),
m_ToolTipDisabled(false),
m_ToolTipHandle(),
m_Mouse(skin, this),
m_HasMouseAction(false),
Expand Down Expand Up @@ -646,7 +647,7 @@ void Meter::UpdateToolTip()
SendMessage(hwndTT, TTM_SETTOOLINFO, 0, (LPARAM)&ti);
SendMessage(hwndTT, TTM_SETMAXTIPWIDTH, 0, m_ToolTipWidth);

if (m_ToolTipHidden)
if (m_ToolTipHidden || m_ToolTipDisabled)
{
SendMessage(hwndTT, TTM_ACTIVATE, FALSE, 0);
}
Expand Down
4 changes: 3 additions & 1 deletion Library/Meter.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class __declspec(novtable) Meter : public Section

void CreateToolTip(Skin* skin);
void UpdateToolTip();
void DisableToolTip() { m_ToolTipDisabled = true; UpdateToolTip(); }
void ResetToolTip() { m_ToolTipDisabled = false; UpdateToolTip(); }

void Hide();
void Show();
Expand Down Expand Up @@ -128,7 +130,7 @@ class __declspec(novtable) Meter : public Section
unsigned int m_ToolTipWidth;
bool m_ToolTipType;
bool m_ToolTipHidden;

bool m_ToolTipDisabled; // Selected skins disable all tooltips
HWND m_ToolTipHandle;

Mouse m_Mouse;
Expand Down
3 changes: 3 additions & 0 deletions Library/Rainmeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,8 @@ void Rainmeter::ReadGeneralSettings(const std::wstring& iniFile)
m_DisableDragging = parser.ReadBool(L"Rainmeter", L"DisableDragging", false);
m_DisableRDP = parser.ReadBool(L"Rainmeter", L"DisableRDP", false);

m_DefaultSelectedColor = parser.ReadColor(L"Rainmeter", L"SelectedColor", Color::MakeARGB(90, 255, 0, 0));

m_SkinEditor = parser.ReadString(L"Rainmeter", L"ConfigEditor", L"");
if (m_SkinEditor.empty())
{
Expand Down Expand Up @@ -1535,6 +1537,7 @@ bool Rainmeter::LoadLayout(const std::wstring& name)
PreserveSetting(backup, L"DisableVersionCheck");
PreserveSetting(backup, L"Language");
PreserveSetting(backup, L"NormalStayDesktop");
PreserveSetting(backup, L"SelectedColor");
PreserveSetting(backup, L"TrayExecuteM", false);
PreserveSetting(backup, L"TrayExecuteR", false);
PreserveSetting(backup, L"TrayExecuteDM", false);
Expand Down
4 changes: 4 additions & 0 deletions Library/Rainmeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ class Rainmeter
bool IsSkinAFavorite(const std::wstring& folder, const std::wstring& filename);
void UpdateFavorites(const std::wstring& folder, const std::wstring& file, bool favorite);

Gdiplus::Color& GetDefaultSelectionColor() { return m_DefaultSelectedColor; }

friend class CommandHandler;
friend class ContextMenu;
friend class DialogManage;
Expand Down Expand Up @@ -245,6 +247,8 @@ class Rainmeter

std::wstring m_SkinEditor;

Gdiplus::Color m_DefaultSelectedColor;

CommandHandler m_CommandHandler;
ContextMenu m_ContextMenu;
SkinRegistry m_SkinRegistry;
Expand Down
Loading

0 comments on commit 521e966

Please sign in to comment.