-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from reupen/show-groups-button-2
Add 'Show groups' state support to the buttons toolbar
- Loading branch information
Showing
9 changed files
with
87 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "stdafx.h" | ||
|
||
#include "button_items.h" | ||
|
||
namespace cui::button_items { | ||
|
||
static uie::button_factory<LiveLayoutEditingButton> live_layout_editing_button_factory; | ||
|
||
static uie::button_factory<ShowGroupsButton> show_groups_button_factory; | ||
|
||
} // namespace cui::button_items |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#pragma once | ||
#include "menu_items.h" | ||
#include "layout.h" | ||
#include "ng_playlist/ng_playlist.h" | ||
|
||
namespace cui::button_items { | ||
|
||
template <class ButtonArgs> | ||
class PushButton : public uie::button { | ||
public: | ||
static void s_on_change() | ||
{ | ||
for (auto&& button : m_buttons) { | ||
for (auto&& callback : button->m_callbacks) { | ||
callback->on_button_state_change(s_get_button_state()); | ||
} | ||
} | ||
} | ||
static unsigned s_get_button_state() | ||
{ | ||
return (ButtonArgs::state() ? uie::BUTTON_STATE_PRESSED : 0) | uie::BUTTON_STATE_DEFAULT; | ||
} | ||
PushButton() { m_buttons.emplace_back(this); } | ||
~PushButton() { m_buttons.erase(std::remove(m_buttons.begin(), m_buttons.end(), this), m_buttons.end()); } | ||
|
||
private: | ||
const GUID& get_item_guid() const override { return ButtonArgs::id; } | ||
HBITMAP get_item_bitmap(unsigned, COLORREF, uie::t_mask&, COLORREF&, HBITMAP&) const override { return nullptr; } | ||
unsigned get_button_state() const override { return s_get_button_state(); } | ||
void register_callback(uie::button_callback& p_callback) override { m_callbacks.emplace_back(&p_callback); } | ||
void deregister_callback(uie::button_callback& p_callback) override | ||
{ | ||
m_callbacks.erase(std::remove(m_callbacks.begin(), m_callbacks.end(), &p_callback), m_callbacks.end()); | ||
} | ||
|
||
static std::vector<PushButton<ButtonArgs>*> m_buttons; | ||
std::vector<uie::button_callback*> m_callbacks; | ||
}; | ||
|
||
template <class ButtonArgs> | ||
std::vector<PushButton<ButtonArgs>*> PushButton<ButtonArgs>::m_buttons; | ||
|
||
struct LiveLayoutEditingButtonArgs { | ||
static bool state() { return g_layout_window.get_layout_editing_active(); } | ||
static constexpr GUID id = main_menu::commands::toggle_live_editing_id; | ||
}; | ||
|
||
using LiveLayoutEditingButton = PushButton<LiveLayoutEditingButtonArgs>; | ||
|
||
struct ShowGroupsButtonArgs { | ||
static bool state() { return pvt::cfg_grouping; } | ||
static constexpr GUID id = main_menu::commands::show_groups_id; | ||
}; | ||
|
||
using ShowGroupsButton = PushButton<ShowGroupsButtonArgs>; | ||
|
||
} // namespace cui::button_items |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters