Remove the now-pointless convenience overload of GetColorFromUser

This commit is contained in:
Thomas Goyne 2013-01-13 10:43:09 -08:00
parent 4c147cbf0b
commit 247a92607b
3 changed files with 9 additions and 25 deletions

View File

@ -32,7 +32,15 @@ ColourButton::ColourButton(wxWindow *parent, wxSize const& size, agi::Color col,
{ {
UpdateBitmap(); UpdateBitmap();
Bind(wxEVT_COMMAND_BUTTON_CLICKED, [=](wxCommandEvent&) { Bind(wxEVT_COMMAND_BUTTON_CLICKED, [=](wxCommandEvent&) {
GetColorFromUser<ColourButton, &ColourButton::SetColour>(GetParent(), colour, this); GetColorFromUser(GetParent(), colour, [=](agi::Color new_color) {
colour = new_color;
UpdateBitmap();
wxThreadEvent evt(EVT_COLOR, GetId());
evt.SetEventObject(this);
evt.SetPayload(colour);
AddPendingEvent(evt);
});
}); });
} }
@ -43,13 +51,3 @@ void ColourButton::UpdateBitmap() {
dc.DrawRectangle(0, 0, bmp.GetWidth(), bmp.GetHeight()); dc.DrawRectangle(0, 0, bmp.GetWidth(), bmp.GetHeight());
SetBitmapLabel(bmp); SetBitmapLabel(bmp);
} }
void ColourButton::SetColour(agi::Color new_color) {
colour = new_color;
UpdateBitmap();
wxThreadEvent evt(EVT_COLOR, GetId());
evt.SetEventObject(this);
evt.SetPayload(colour);
AddPendingEvent(evt);
}

View File

@ -30,8 +30,6 @@ class ColourButton: public wxButton {
/// Update the bitmap label after the color is changed /// Update the bitmap label after the color is changed
void UpdateBitmap(); void UpdateBitmap();
/// Callback for the colorpicker dialog
void SetColour(agi::Color colour);
public: public:
/// Constructor /// Constructor

View File

@ -31,15 +31,3 @@ class wxWindow;
/// @param callback Function called whenever the selected color changes /// @param callback Function called whenever the selected color changes
/// @return Did the user accept the new color? /// @return Did the user accept the new color?
bool GetColorFromUser(wxWindow* parent, agi::Color original, std::function<void (agi::Color)> callback); bool GetColorFromUser(wxWindow* parent, agi::Color original, std::function<void (agi::Color)> callback);
/// @brief Get a color from the user via a color picker dialog
/// @param T Class which the callback method belongs to
/// @param method Callback method
/// @param parent Parent window
/// @param original Initial color to select
/// @param callbackObj Object to call callback method on. Must be of type T.
/// @return Did the user accept the new color?
template<class T, void (T::*method)(agi::Color)>
bool GetColorFromUser(wxWindow* parent, agi::Color original, T* callbackObj) {
return GetColorFromUser(parent, original, std::bind(method, callbackObj, std::placeholders::_1));
}