diff --git a/nccdll_notes.txt b/nccdll_notes.txt index ca6b9965ae..c6bdf1714a 100644 --- a/nccdll_notes.txt +++ b/nccdll_notes.txt @@ -1,26 +1,26 @@ -Notes to create the Nutcracker DLL project -Updated 26 Jan 2014, by Matt Brown - -* The Visual Studio project is located in xLights\nccdll directory -* Requires MS Visual Studio 2010 or later -* Make sure the vc\bin directory is in your path (e.g. C:\Program Files\Microsoft Visual Studio 10.0\VC\bin) - --- First need to create 32b static libs (debug/release) - -* Create a fresh copy of the wxWidgets source (e.g. C:\wxWidgets-3.0.0vc) - do not reuse the wxWidgets directory compiled for xLights -* Open a command prompt -* cd to the fresh copy's build/msw subdirectory (e.g. C:\wxWidgets-3.0.0vc\build\msw) -* Run: vcvars32.bat -* Run: nmake -f makefile.vc SHARED=0 UNICODE=1 BUILD=debug -* Run: nmake -f makefile.vc SHARED=0 UNICODE=1 BUILD=release -* Close command prompt - --- Now build DLL using Visual Studio - -* Open .sln file in xLights\nccdll directory using Visual Studio -* Right click on "nccdll" in Solution Explorer, select Properties from menu -* Click on VC++ Directories. Edit the Include and Library directories to match the wxWidgets location above. -* Set build type to Debug or Release, depending on your needs -* Build solution! -* DLL file will be in the Debug or Release subdirectory under nccdll. - +Notes to create the Nutcracker DLL project +Updated 26 Jan 2014, by Matt Brown + +* The Visual Studio project is located in xLights\nccdll directory +* Requires MS Visual Studio 2010 or later +* Make sure the vc\bin directory is in your path (e.g. C:\Program Files\Microsoft Visual Studio 10.0\VC\bin) + +-- First need to create 32b static libs (debug/release) + +* Create a fresh copy of the wxWidgets source (e.g. C:\wxWidgets-3.0.0vc) - do not reuse the wxWidgets directory compiled for xLights +* Open a command prompt +* cd to the fresh copy's build/msw subdirectory (e.g. C:\wxWidgets-3.0.0vc\build\msw) +* Run: vcvars32.bat +* Run: nmake -f makefile.vc SHARED=0 UNICODE=1 BUILD=debug +* Run: nmake -f makefile.vc SHARED=0 UNICODE=1 BUILD=release +* Close command prompt + +-- Now build DLL using Visual Studio + +* Open .sln file in xLights\nccdll directory using Visual Studio +* Right click on "nccdll" in Solution Explorer, select Properties from menu +* Click on VC++ Directories. Edit the Include and Library directories to match the wxWidgets location above. +* Set build type to Debug or Release, depending on your needs +* Build solution! +* DLL file will be in the Debug or Release subdirectory under nccdll. + diff --git a/xLights/ColorPanel.cpp b/xLights/ColorPanel.cpp index b061c05ab8..d42e4505ef 100644 --- a/xLights/ColorPanel.cpp +++ b/xLights/ColorPanel.cpp @@ -1,439 +1,439 @@ -#include "ColorPanel.h" -#include "xLightsMain.h" - -#include "../include/padlock16x16-green.xpm" //-DJ -#include "../include/padlock16x16-red.xpm" //-DJ -#include "../include/padlock16x16-blue.xpm" //-DJ - - -class xLightsFrame; -//(*InternalHeaders(ColorPanel) -#include -#include -#include -#include -#include -//*) - -//(*IdInit(ColorPanel) -const long ColorPanel::ID_CHECKBOX_Palette1 = wxNewId(); -const long ColorPanel::ID_CHECKBOX_Palette2 = wxNewId(); -const long ColorPanel::ID_CHECKBOX_Palette3 = wxNewId(); -const long ColorPanel::ID_CHECKBOX_Palette4 = wxNewId(); -const long ColorPanel::ID_CHECKBOX_Palette5 = wxNewId(); -const long ColorPanel::ID_CHECKBOX_Palette6 = wxNewId(); -const long ColorPanel::ID_BUTTON_Palette1 = wxNewId(); -const long ColorPanel::ID_BUTTON_Palette2 = wxNewId(); -const long ColorPanel::ID_BUTTON_Palette3 = wxNewId(); -const long ColorPanel::ID_BUTTON_Palette4 = wxNewId(); -const long ColorPanel::ID_BUTTON_Palette5 = wxNewId(); -const long ColorPanel::ID_BUTTON_Palette6 = wxNewId(); -const long ColorPanel::ID_BITMAPBUTTON_BUTTON_Palette1 = wxNewId(); -const long ColorPanel::ID_BITMAPBUTTON_BUTTON_Palette2 = wxNewId(); -const long ColorPanel::ID_BITMAPBUTTON_BUTTON_Palette3 = wxNewId(); -const long ColorPanel::ID_BITMAPBUTTON_BUTTON_Palette4 = wxNewId(); -const long ColorPanel::ID_BITMAPBUTTON_BUTTON_Palette5 = wxNewId(); -const long ColorPanel::ID_BITMAPBUTTON_BUTTON_Palette6 = wxNewId(); -const long ColorPanel::ID_STATICTEXT24 = wxNewId(); -const long ColorPanel::ID_SLIDER_SparkleFrequency = wxNewId(); -const long ColorPanel::ID_TEXTCTRL5 = wxNewId(); -const long ColorPanel::ID_BITMAPBUTTON_SLIDER_SparkleFrequency = wxNewId(); -const long ColorPanel::ID_STATICTEXT127 = wxNewId(); -const long ColorPanel::ID_SLIDER_Brightness = wxNewId(); -const long ColorPanel::ID_TEXTCTRL6 = wxNewId(); -const long ColorPanel::ID_BITMAPBUTTON_SLIDER_Brightness = wxNewId(); -const long ColorPanel::ID_STATICTEXT128 = wxNewId(); -const long ColorPanel::ID_SLIDER_Contrast = wxNewId(); -const long ColorPanel::ID_TEXTCTRL7 = wxNewId(); -const long ColorPanel::ID_BITMAPBUTTON_SLIDER_Contrast = wxNewId(); -const long ColorPanel::ID_SCROLLED_ColorScroll = wxNewId(); -const long ColorPanel::ID_PANEL1 = wxNewId(); -//*) - -BEGIN_EVENT_TABLE(ColorPanel,wxPanel) - //(*EventTable(ColorPanel) - //*) -END_EVENT_TABLE() - -ColorPanel::ColorPanel(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size) -{ - //(*Initialize(ColorPanel) - wxFlexGridSizer* FlexGridSizer4; - wxFlexGridSizer* FlexGridSizer3; - wxFlexGridSizer* FlexGridSizer5; - wxFlexGridSizer* FlexGridSizer2; - wxFlexGridSizer* FlexGridSizer1; - - Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("wxID_ANY")); - FlexGridSizer1 = new wxFlexGridSizer(1, 1, 0, 0); - Panel_Sizer = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1")); - Panel_Sizer->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BACKGROUND)); - FlexGridSizer3 = new wxFlexGridSizer(0, 1, 0, 0); - ColorScrollWindow = new wxScrolledWindow(Panel_Sizer, ID_SCROLLED_ColorScroll, wxDefaultPosition, wxDefaultSize, wxVSCROLL|wxHSCROLL, _T("ID_SCROLLED_ColorScroll")); - ColorScrollWindow->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); - FlexGridSizer4 = new wxFlexGridSizer(0, 1, 0, 0); - FlexGridSizer4->AddGrowableCol(0); - FlexGridSizer5 = new wxFlexGridSizer(0, 3, 0, 0); - FlexGridSizer5->AddGrowableCol(0); - FlexGridSizer5->AddGrowableCol(1); - FlexGridSizer5->AddGrowableCol(2); - FlexGridSizer5->Add(-1,-1,1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); - FlexGridSizer_Palette = new wxFlexGridSizer(0, 6, 0, 0); - FlexGridSizer_Palette->AddGrowableCol(0); - FlexGridSizer_Palette->AddGrowableCol(1); - FlexGridSizer_Palette->AddGrowableCol(2); - FlexGridSizer_Palette->AddGrowableCol(3); - FlexGridSizer_Palette->AddGrowableCol(4); - FlexGridSizer_Palette->AddGrowableCol(5); - CheckBox_Palette1 = new wxCheckBox(ColorScrollWindow, ID_CHECKBOX_Palette1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Palette1")); - CheckBox_Palette1->SetValue(true); - FlexGridSizer_Palette->Add(CheckBox_Palette1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); - CheckBox_Palette2 = new wxCheckBox(ColorScrollWindow, ID_CHECKBOX_Palette2, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Palette2")); - CheckBox_Palette2->SetValue(true); - FlexGridSizer_Palette->Add(CheckBox_Palette2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); - CheckBox_Palette3 = new wxCheckBox(ColorScrollWindow, ID_CHECKBOX_Palette3, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Palette3")); - CheckBox_Palette3->SetValue(false); - FlexGridSizer_Palette->Add(CheckBox_Palette3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); - CheckBox_Palette4 = new wxCheckBox(ColorScrollWindow, ID_CHECKBOX_Palette4, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Palette4")); - CheckBox_Palette4->SetValue(false); - FlexGridSizer_Palette->Add(CheckBox_Palette4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); - CheckBox_Palette5 = new wxCheckBox(ColorScrollWindow, ID_CHECKBOX_Palette5, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Palette5")); - CheckBox_Palette5->SetValue(false); - FlexGridSizer_Palette->Add(CheckBox_Palette5, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); - CheckBox_Palette6 = new wxCheckBox(ColorScrollWindow, ID_CHECKBOX_Palette6, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Palette6")); - CheckBox_Palette6->SetValue(false); - FlexGridSizer_Palette->Add(CheckBox_Palette6, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); - Button_Palette1 = new wxBitmapButton(ColorScrollWindow, ID_BUTTON_Palette1, wxNullBitmap, wxDefaultPosition, wxSize(21,21), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON_Palette1")); - Button_Palette1->SetDefault(); - FlexGridSizer_Palette->Add(Button_Palette1, 1, wxALIGN_LEFT|wxALIGN_TOP, 2); - Button_Palette2 = new wxBitmapButton(ColorScrollWindow, ID_BUTTON_Palette2, wxNullBitmap, wxDefaultPosition, wxSize(21,21), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON_Palette2")); - Button_Palette2->SetDefault(); - FlexGridSizer_Palette->Add(Button_Palette2, 1, wxALIGN_LEFT|wxALIGN_TOP, 2); - Button_Palette3 = new wxBitmapButton(ColorScrollWindow, ID_BUTTON_Palette3, wxNullBitmap, wxDefaultPosition, wxSize(21,21), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON_Palette3")); - Button_Palette3->SetDefault(); - FlexGridSizer_Palette->Add(Button_Palette3, 1, wxALIGN_LEFT|wxALIGN_TOP, 2); - Button_Palette4 = new wxBitmapButton(ColorScrollWindow, ID_BUTTON_Palette4, wxNullBitmap, wxDefaultPosition, wxSize(21,21), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON_Palette4")); - Button_Palette4->SetDefault(); - FlexGridSizer_Palette->Add(Button_Palette4, 1, wxALIGN_LEFT|wxALIGN_TOP, 2); - Button_Palette5 = new wxBitmapButton(ColorScrollWindow, ID_BUTTON_Palette5, wxNullBitmap, wxDefaultPosition, wxSize(21,21), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON_Palette5")); - Button_Palette5->SetDefault(); - FlexGridSizer_Palette->Add(Button_Palette5, 1, wxALIGN_LEFT|wxALIGN_TOP, 2); - Button_Palette6 = new wxBitmapButton(ColorScrollWindow, ID_BUTTON_Palette6, wxNullBitmap, wxDefaultPosition, wxSize(21,21), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON_Palette6")); - Button_Palette6->SetDefault(); - FlexGridSizer_Palette->Add(Button_Palette6, 1, wxALIGN_LEFT|wxALIGN_TOP, 2); - BitmapButton_Palette1 = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_BUTTON_Palette1, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_BUTTON_Palette1")); - BitmapButton_Palette1->SetDefault(); - BitmapButton_Palette1->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); - FlexGridSizer_Palette->Add(BitmapButton_Palette1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1); - BitmapButton_Palette2 = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_BUTTON_Palette2, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_BUTTON_Palette2")); - BitmapButton_Palette2->SetDefault(); - BitmapButton_Palette2->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); - FlexGridSizer_Palette->Add(BitmapButton_Palette2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1); - BitmapButton_Palette3 = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_BUTTON_Palette3, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_BUTTON_Palette3")); - BitmapButton_Palette3->SetDefault(); - BitmapButton_Palette3->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); - FlexGridSizer_Palette->Add(BitmapButton_Palette3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1); - BitmapButton_Palette4 = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_BUTTON_Palette4, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_BUTTON_Palette4")); - BitmapButton_Palette4->SetDefault(); - BitmapButton_Palette4->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); - FlexGridSizer_Palette->Add(BitmapButton_Palette4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1); - BitmapButton_Palette5 = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_BUTTON_Palette5, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_BUTTON_Palette5")); - BitmapButton_Palette5->SetDefault(); - BitmapButton_Palette5->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); - FlexGridSizer_Palette->Add(BitmapButton_Palette5, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1); - BitmapButton_Palette6 = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_BUTTON_Palette6, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_BUTTON_Palette6")); - BitmapButton_Palette6->SetDefault(); - BitmapButton_Palette6->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); - FlexGridSizer_Palette->Add(BitmapButton_Palette6, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1); - FlexGridSizer5->Add(FlexGridSizer_Palette, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); - FlexGridSizer5->Add(-1,-1,1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); - FlexGridSizer4->Add(FlexGridSizer5, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); - FlexGridSizer2 = new wxFlexGridSizer(0, 4, 0, 0); - FlexGridSizer2->AddGrowableCol(1); - StaticText22 = new wxStaticText(ColorScrollWindow, ID_STATICTEXT24, _("Sparkles"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT24")); - FlexGridSizer2->Add(StaticText22, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); - Slider_SparkleFrequency = new wxSlider(ColorScrollWindow, ID_SLIDER_SparkleFrequency, 200, 10, 200, wxDefaultPosition, wxDefaultSize, wxSL_INVERSE, wxDefaultValidator, _T("ID_SLIDER_SparkleFrequency")); - FlexGridSizer2->Add(Slider_SparkleFrequency, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); - txtCtrlSparkleFreq = new wxTextCtrl(ColorScrollWindow, ID_TEXTCTRL5, _("200"), wxDefaultPosition, wxSize(32,20), wxTE_PROCESS_ENTER|wxTAB_TRAVERSAL, wxDefaultValidator, _T("ID_TEXTCTRL5")); - FlexGridSizer2->Add(txtCtrlSparkleFreq, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); - BitmapButton_SparkleFrequency = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_SLIDER_SparkleFrequency, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_SLIDER_SparkleFrequency")); - BitmapButton_SparkleFrequency->SetDefault(); - BitmapButton_SparkleFrequency->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); - BitmapButton_SparkleFrequency->SetToolTip(_("Lock/Unlock. If Locked then a \"Create Random Effects\" will NOT change this value.")); - FlexGridSizer2->Add(BitmapButton_SparkleFrequency, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); - StaticText126 = new wxStaticText(ColorScrollWindow, ID_STATICTEXT127, _("Brightness"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT127")); - FlexGridSizer2->Add(StaticText126, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); - Slider_Brightness = new wxSlider(ColorScrollWindow, ID_SLIDER_Brightness, 100, 0, 400, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_SLIDER_Brightness")); - FlexGridSizer2->Add(Slider_Brightness, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); - txtCtlBrightness = new wxTextCtrl(ColorScrollWindow, ID_TEXTCTRL6, _("100"), wxDefaultPosition, wxSize(32,20), wxTE_PROCESS_ENTER|wxTAB_TRAVERSAL, wxDefaultValidator, _T("ID_TEXTCTRL6")); - FlexGridSizer2->Add(txtCtlBrightness, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); - BitmapButton_Brightness = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_SLIDER_Brightness, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_SLIDER_Brightness")); - BitmapButton_Brightness->SetDefault(); - BitmapButton_Brightness->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); - BitmapButton_Brightness->SetToolTip(_("Lock/Unlock. If Locked then a \"Create Random Effects\" will NOT change this value.")); - FlexGridSizer2->Add(BitmapButton_Brightness, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); - StaticText127 = new wxStaticText(ColorScrollWindow, ID_STATICTEXT128, _("Contrast"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT128")); - FlexGridSizer2->Add(StaticText127, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); - Slider_Contrast = new wxSlider(ColorScrollWindow, ID_SLIDER_Contrast, 0, 0, 100, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_SLIDER_Contrast")); - FlexGridSizer2->Add(Slider_Contrast, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); - txtCtlContrast = new wxTextCtrl(ColorScrollWindow, ID_TEXTCTRL7, _("0"), wxDefaultPosition, wxSize(32,20), wxTE_PROCESS_ENTER|wxTAB_TRAVERSAL, wxDefaultValidator, _T("ID_TEXTCTRL7")); - FlexGridSizer2->Add(txtCtlContrast, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); - BitmapButton_Contrast = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_SLIDER_Contrast, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_SLIDER_Contrast")); - BitmapButton_Contrast->SetDefault(); - BitmapButton_Contrast->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); - BitmapButton_Contrast->SetToolTip(_("Lock/Unlock. If Locked then a \"Create Random Effects\" will NOT change this value.")); - FlexGridSizer2->Add(BitmapButton_Contrast, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); - FlexGridSizer4->Add(FlexGridSizer2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); - ColorScrollWindow->SetSizer(FlexGridSizer4); - FlexGridSizer4->Fit(ColorScrollWindow); - FlexGridSizer4->SetSizeHints(ColorScrollWindow); - FlexGridSizer3->Add(ColorScrollWindow, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); - Panel_Sizer->SetSizer(FlexGridSizer3); - FlexGridSizer3->Fit(Panel_Sizer); - FlexGridSizer3->SetSizeHints(Panel_Sizer); - FlexGridSizer1->Add(Panel_Sizer, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); - SetSizer(FlexGridSizer1); - FlexGridSizer1->Fit(this); - FlexGridSizer1->SetSizeHints(this); - - Connect(ID_CHECKBOX_Palette1,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ColorPanel::OnCheckBox_PaletteClick); - Connect(ID_CHECKBOX_Palette2,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ColorPanel::OnCheckBox_PaletteClick); - Connect(ID_CHECKBOX_Palette3,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ColorPanel::OnCheckBox_PaletteClick); - Connect(ID_CHECKBOX_Palette4,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ColorPanel::OnCheckBox_PaletteClick); - Connect(ID_CHECKBOX_Palette5,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ColorPanel::OnCheckBox_PaletteClick); - Connect(ID_CHECKBOX_Palette6,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ColorPanel::OnCheckBox_PaletteClick); - Connect(ID_BUTTON_Palette1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnButton_PaletteNumberClick); - Connect(ID_BUTTON_Palette2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnButton_PaletteNumberClick); - Connect(ID_BUTTON_Palette3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnButton_PaletteNumberClick); - Connect(ID_BUTTON_Palette4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnButton_PaletteNumberClick); - Connect(ID_BUTTON_Palette5,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnButton_PaletteNumberClick); - Connect(ID_BUTTON_Palette6,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnButton_PaletteNumberClick); - Connect(ID_BITMAPBUTTON_BUTTON_Palette1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnBitmapButton_Palette1Click); - Connect(ID_BITMAPBUTTON_BUTTON_Palette2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnBitmapButton_Palette2Click); - Connect(ID_BITMAPBUTTON_BUTTON_Palette3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnBitmapButton_Palette3Click); - Connect(ID_BITMAPBUTTON_BUTTON_Palette4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnBitmapButton_Palette4Click); - Connect(ID_BITMAPBUTTON_BUTTON_Palette5,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnBitmapButton_Palette5Click); - Connect(ID_BITMAPBUTTON_BUTTON_Palette6,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnBitmapButton_Palette6Click); - Connect(wxEVT_PAINT,(wxObjectEventFunction)&ColorPanel::OnPaint); - Connect(wxEVT_SIZE,(wxObjectEventFunction)&ColorPanel::OnResize); - //*) - - - SetDefaultPalette(); -} - -ColorPanel::~ColorPanel() -{ - //(*Destroy(ColorPanel) - //*) -} - - -void ColorPanel::SetButtonColor(wxBitmapButton* btn, const wxColour* c) -{ - btn->SetBackgroundColour(*c); - int test=c->Red()*0.299 + c->Green()*0.587 + c->Blue()*0.114; - btn->SetForegroundColour(test < 186 ? *wxWHITE : *wxBLACK); - - wxImage image(15, 15); - image.SetRGB(wxRect(0, 0, 15, 15), - c->Red(), c->Green(), c->Blue()); - wxBitmap bmp(image); - - btn->SetBitmap(bmp); -} - -wxString ColorPanel::GetColorString() -{ - wxString s,ChildName,AttrName; -// wxString prefix=GetAttrPrefix(); -// //~s=prefix+wxString::Format("SLIDER_Speed=%d",Slider_Speed->GetValue()); -// //~s+=prefix+"TEXTCTRL_Fadein="+TextCtrl_Fadein->GetValue(); -// //~s+=prefix+"TEXTCTRL_Fadeout="+TextCtrl_Fadeout->GetValue(); -// //~s+=prefix+wxString::Format("CHECKBOX_FitToTime=%d",CheckBox_FitToTime->GetValue()?1:0); -// //~s+=prefix+wxString::Format("CHECKBOX_OverlayBkg=%d",CheckBox_OverlayBkg->GetValue()?1:0); -// - wxColour color; - for (int i=1; i<=PALETTE_SIZE; i++) - { - color=GetPaletteColor(i); - AttrName.Printf("C_BUTTON_Palette%d=",i); - s+=AttrName+color.GetAsString(wxC2S_HTML_SYNTAX) + ","; - ChildName.Printf("ID_CHECKBOX_Palette%d",i); - AttrName.Printf("C_CHECKBOX_Palette%d",i); - wxCheckBox* ctrl=(wxCheckBox*)wxWindow::FindWindowByName(ChildName,this); - wxString v=(ctrl->IsChecked()) ? "1" : "0"; - s+=AttrName+"="+v + ","; - } - return s; -} - - - -wxColour ColorPanel::GetPaletteColor(int idx) -{ - switch (idx) - { - case 1: - return Button_Palette1->GetBackgroundColour(); - case 2: - return Button_Palette2->GetBackgroundColour(); - case 3: - return Button_Palette3->GetBackgroundColour(); - case 4: - return Button_Palette4->GetBackgroundColour(); - case 5: - return Button_Palette5->GetBackgroundColour(); - case 6: - return Button_Palette6->GetBackgroundColour(); - } - return *wxBLACK; -} - -// idx is 1-6 -void ColorPanel::SetPaletteColor(int idx, const wxColour* c) -{ - switch (idx) - { - case 1: - SetButtonColor(Button_Palette1,c); - break; - case 2: - SetButtonColor(Button_Palette2,c); - break; - case 3: - SetButtonColor(Button_Palette3,c); - break; - case 4: - SetButtonColor(Button_Palette4,c); - break; - case 5: - SetButtonColor(Button_Palette5,c); - break; - case 6: - SetButtonColor(Button_Palette6,c); - break; - } -} - -//allow array-like access to checkboxes also -DJ -wxCheckBox* ColorPanel::GetPaletteCheckbox(int idx) -{ - switch (idx) // idx is 1-6 - { - case 1: - return CheckBox_Palette1; - case 2: - return CheckBox_Palette2; - case 3: - return CheckBox_Palette3; - case 4: - return CheckBox_Palette4; - case 5: - return CheckBox_Palette5; - case 6: - return CheckBox_Palette6; - } - return CheckBox_Palette1; //0; -} - -//allow array-like access to buttons also -DJ -wxButton* ColorPanel::GetPaletteButton(int idx) -{ - switch (idx) // idx is 1-6 - { - case 1: - return Button_Palette1; - case 2: - return Button_Palette2; - case 3: - return Button_Palette3; - case 4: - return Button_Palette4; - case 5: - return Button_Palette5; - case 6: - return Button_Palette6; - } - return Button_Palette1; //0; -} - -void ColorPanel::SetDefaultPalette() -{ - SetButtonColor(Button_Palette1,wxRED); - SetButtonColor(Button_Palette2,wxGREEN); - SetButtonColor(Button_Palette3,wxBLUE); - SetButtonColor(Button_Palette4,wxYELLOW); - SetButtonColor(Button_Palette5,wxWHITE); - SetButtonColor(Button_Palette6,wxBLACK); -} - - - - -void ColorPanel::OnCheckBox_PaletteClick(wxCommandEvent& event) -{ - PaletteChanged=true; -} - -void ColorPanel::OnBitmapButton_Palette2Click(wxCommandEvent& event) -{ -} - -void ColorPanel::OnBitmapButton_Palette1Click(wxCommandEvent& event) -{ -} - -void ColorPanel::OnBitmapButton_Palette3Click(wxCommandEvent& event) -{ -} - -void ColorPanel::OnBitmapButton_Palette4Click(wxCommandEvent& event) -{ -} - -void ColorPanel::OnBitmapButton_Palette5Click(wxCommandEvent& event) -{ -} - -void ColorPanel::OnBitmapButton_Palette6Click(wxCommandEvent& event) -{ -} - -void ColorPanel::OnButton_PaletteNumberClick(wxCommandEvent& event) -{ - wxBitmapButton* w=(wxBitmapButton*)event.GetEventObject(); - wxColour color = w->GetBackgroundColour(); - colorData.SetColour(color); - wxColourDialog dialog(this, &colorData); - if (dialog.ShowModal() == wxID_OK) - { - wxColourData retData = dialog.GetColourData(); - wxColour color = retData.GetColour(); - SetButtonColor(w, &color); - PaletteChanged=true; - } - -} - -void ColorPanel::OnResize(wxSizeEvent& event) -{ - wxSize s = GetSize(); - Panel_Sizer->SetSize(s); - Panel_Sizer->SetMinSize(s); - Panel_Sizer->SetMaxSize(s); - Panel_Sizer->Refresh(); - - ColorScrollWindow->SetSize(s); - ColorScrollWindow->SetMinSize(s); - ColorScrollWindow->SetMaxSize(s); - - ColorScrollWindow->FitInside(); - ColorScrollWindow->SetScrollRate(5, 5); - ColorScrollWindow->Refresh(); - -} - -void ColorPanel::OnPaint(wxPaintEvent& event) -{ -} +#include "ColorPanel.h" +#include "xLightsMain.h" + +#include "../include/padlock16x16-green.xpm" //-DJ +#include "../include/padlock16x16-red.xpm" //-DJ +#include "../include/padlock16x16-blue.xpm" //-DJ + + +class xLightsFrame; +//(*InternalHeaders(ColorPanel) +#include +#include +#include +#include +#include +//*) + +//(*IdInit(ColorPanel) +const long ColorPanel::ID_CHECKBOX_Palette1 = wxNewId(); +const long ColorPanel::ID_CHECKBOX_Palette2 = wxNewId(); +const long ColorPanel::ID_CHECKBOX_Palette3 = wxNewId(); +const long ColorPanel::ID_CHECKBOX_Palette4 = wxNewId(); +const long ColorPanel::ID_CHECKBOX_Palette5 = wxNewId(); +const long ColorPanel::ID_CHECKBOX_Palette6 = wxNewId(); +const long ColorPanel::ID_BUTTON_Palette1 = wxNewId(); +const long ColorPanel::ID_BUTTON_Palette2 = wxNewId(); +const long ColorPanel::ID_BUTTON_Palette3 = wxNewId(); +const long ColorPanel::ID_BUTTON_Palette4 = wxNewId(); +const long ColorPanel::ID_BUTTON_Palette5 = wxNewId(); +const long ColorPanel::ID_BUTTON_Palette6 = wxNewId(); +const long ColorPanel::ID_BITMAPBUTTON_BUTTON_Palette1 = wxNewId(); +const long ColorPanel::ID_BITMAPBUTTON_BUTTON_Palette2 = wxNewId(); +const long ColorPanel::ID_BITMAPBUTTON_BUTTON_Palette3 = wxNewId(); +const long ColorPanel::ID_BITMAPBUTTON_BUTTON_Palette4 = wxNewId(); +const long ColorPanel::ID_BITMAPBUTTON_BUTTON_Palette5 = wxNewId(); +const long ColorPanel::ID_BITMAPBUTTON_BUTTON_Palette6 = wxNewId(); +const long ColorPanel::ID_STATICTEXT24 = wxNewId(); +const long ColorPanel::ID_SLIDER_SparkleFrequency = wxNewId(); +const long ColorPanel::ID_TEXTCTRL5 = wxNewId(); +const long ColorPanel::ID_BITMAPBUTTON_SLIDER_SparkleFrequency = wxNewId(); +const long ColorPanel::ID_STATICTEXT127 = wxNewId(); +const long ColorPanel::ID_SLIDER_Brightness = wxNewId(); +const long ColorPanel::ID_TEXTCTRL6 = wxNewId(); +const long ColorPanel::ID_BITMAPBUTTON_SLIDER_Brightness = wxNewId(); +const long ColorPanel::ID_STATICTEXT128 = wxNewId(); +const long ColorPanel::ID_SLIDER_Contrast = wxNewId(); +const long ColorPanel::ID_TEXTCTRL7 = wxNewId(); +const long ColorPanel::ID_BITMAPBUTTON_SLIDER_Contrast = wxNewId(); +const long ColorPanel::ID_SCROLLED_ColorScroll = wxNewId(); +const long ColorPanel::ID_PANEL1 = wxNewId(); +//*) + +BEGIN_EVENT_TABLE(ColorPanel,wxPanel) + //(*EventTable(ColorPanel) + //*) +END_EVENT_TABLE() + +ColorPanel::ColorPanel(wxWindow* parent,wxWindowID id,const wxPoint& pos,const wxSize& size) +{ + //(*Initialize(ColorPanel) + wxFlexGridSizer* FlexGridSizer4; + wxFlexGridSizer* FlexGridSizer3; + wxFlexGridSizer* FlexGridSizer5; + wxFlexGridSizer* FlexGridSizer2; + wxFlexGridSizer* FlexGridSizer1; + + Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("wxID_ANY")); + FlexGridSizer1 = new wxFlexGridSizer(1, 1, 0, 0); + Panel_Sizer = new wxPanel(this, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ID_PANEL1")); + Panel_Sizer->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BACKGROUND)); + FlexGridSizer3 = new wxFlexGridSizer(0, 1, 0, 0); + ColorScrollWindow = new wxScrolledWindow(Panel_Sizer, ID_SCROLLED_ColorScroll, wxDefaultPosition, wxDefaultSize, wxVSCROLL|wxHSCROLL, _T("ID_SCROLLED_ColorScroll")); + ColorScrollWindow->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); + FlexGridSizer4 = new wxFlexGridSizer(0, 1, 0, 0); + FlexGridSizer4->AddGrowableCol(0); + FlexGridSizer5 = new wxFlexGridSizer(0, 3, 0, 0); + FlexGridSizer5->AddGrowableCol(0); + FlexGridSizer5->AddGrowableCol(1); + FlexGridSizer5->AddGrowableCol(2); + FlexGridSizer5->Add(-1,-1,1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + FlexGridSizer_Palette = new wxFlexGridSizer(0, 6, 0, 0); + FlexGridSizer_Palette->AddGrowableCol(0); + FlexGridSizer_Palette->AddGrowableCol(1); + FlexGridSizer_Palette->AddGrowableCol(2); + FlexGridSizer_Palette->AddGrowableCol(3); + FlexGridSizer_Palette->AddGrowableCol(4); + FlexGridSizer_Palette->AddGrowableCol(5); + CheckBox_Palette1 = new wxCheckBox(ColorScrollWindow, ID_CHECKBOX_Palette1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Palette1")); + CheckBox_Palette1->SetValue(true); + FlexGridSizer_Palette->Add(CheckBox_Palette1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + CheckBox_Palette2 = new wxCheckBox(ColorScrollWindow, ID_CHECKBOX_Palette2, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Palette2")); + CheckBox_Palette2->SetValue(true); + FlexGridSizer_Palette->Add(CheckBox_Palette2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + CheckBox_Palette3 = new wxCheckBox(ColorScrollWindow, ID_CHECKBOX_Palette3, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Palette3")); + CheckBox_Palette3->SetValue(false); + FlexGridSizer_Palette->Add(CheckBox_Palette3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + CheckBox_Palette4 = new wxCheckBox(ColorScrollWindow, ID_CHECKBOX_Palette4, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Palette4")); + CheckBox_Palette4->SetValue(false); + FlexGridSizer_Palette->Add(CheckBox_Palette4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + CheckBox_Palette5 = new wxCheckBox(ColorScrollWindow, ID_CHECKBOX_Palette5, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Palette5")); + CheckBox_Palette5->SetValue(false); + FlexGridSizer_Palette->Add(CheckBox_Palette5, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + CheckBox_Palette6 = new wxCheckBox(ColorScrollWindow, ID_CHECKBOX_Palette6, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX_Palette6")); + CheckBox_Palette6->SetValue(false); + FlexGridSizer_Palette->Add(CheckBox_Palette6, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + Button_Palette1 = new wxBitmapButton(ColorScrollWindow, ID_BUTTON_Palette1, wxNullBitmap, wxDefaultPosition, wxSize(21,21), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON_Palette1")); + Button_Palette1->SetDefault(); + FlexGridSizer_Palette->Add(Button_Palette1, 1, wxALIGN_LEFT|wxALIGN_TOP, 2); + Button_Palette2 = new wxBitmapButton(ColorScrollWindow, ID_BUTTON_Palette2, wxNullBitmap, wxDefaultPosition, wxSize(21,21), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON_Palette2")); + Button_Palette2->SetDefault(); + FlexGridSizer_Palette->Add(Button_Palette2, 1, wxALIGN_LEFT|wxALIGN_TOP, 2); + Button_Palette3 = new wxBitmapButton(ColorScrollWindow, ID_BUTTON_Palette3, wxNullBitmap, wxDefaultPosition, wxSize(21,21), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON_Palette3")); + Button_Palette3->SetDefault(); + FlexGridSizer_Palette->Add(Button_Palette3, 1, wxALIGN_LEFT|wxALIGN_TOP, 2); + Button_Palette4 = new wxBitmapButton(ColorScrollWindow, ID_BUTTON_Palette4, wxNullBitmap, wxDefaultPosition, wxSize(21,21), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON_Palette4")); + Button_Palette4->SetDefault(); + FlexGridSizer_Palette->Add(Button_Palette4, 1, wxALIGN_LEFT|wxALIGN_TOP, 2); + Button_Palette5 = new wxBitmapButton(ColorScrollWindow, ID_BUTTON_Palette5, wxNullBitmap, wxDefaultPosition, wxSize(21,21), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON_Palette5")); + Button_Palette5->SetDefault(); + FlexGridSizer_Palette->Add(Button_Palette5, 1, wxALIGN_LEFT|wxALIGN_TOP, 2); + Button_Palette6 = new wxBitmapButton(ColorScrollWindow, ID_BUTTON_Palette6, wxNullBitmap, wxDefaultPosition, wxSize(21,21), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BUTTON_Palette6")); + Button_Palette6->SetDefault(); + FlexGridSizer_Palette->Add(Button_Palette6, 1, wxALIGN_LEFT|wxALIGN_TOP, 2); + BitmapButton_Palette1 = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_BUTTON_Palette1, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_BUTTON_Palette1")); + BitmapButton_Palette1->SetDefault(); + BitmapButton_Palette1->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); + FlexGridSizer_Palette->Add(BitmapButton_Palette1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1); + BitmapButton_Palette2 = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_BUTTON_Palette2, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_BUTTON_Palette2")); + BitmapButton_Palette2->SetDefault(); + BitmapButton_Palette2->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); + FlexGridSizer_Palette->Add(BitmapButton_Palette2, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1); + BitmapButton_Palette3 = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_BUTTON_Palette3, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_BUTTON_Palette3")); + BitmapButton_Palette3->SetDefault(); + BitmapButton_Palette3->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); + FlexGridSizer_Palette->Add(BitmapButton_Palette3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1); + BitmapButton_Palette4 = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_BUTTON_Palette4, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_BUTTON_Palette4")); + BitmapButton_Palette4->SetDefault(); + BitmapButton_Palette4->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); + FlexGridSizer_Palette->Add(BitmapButton_Palette4, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1); + BitmapButton_Palette5 = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_BUTTON_Palette5, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_BUTTON_Palette5")); + BitmapButton_Palette5->SetDefault(); + BitmapButton_Palette5->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); + FlexGridSizer_Palette->Add(BitmapButton_Palette5, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1); + BitmapButton_Palette6 = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_BUTTON_Palette6, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_BUTTON_Palette6")); + BitmapButton_Palette6->SetDefault(); + BitmapButton_Palette6->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); + FlexGridSizer_Palette->Add(BitmapButton_Palette6, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 1); + FlexGridSizer5->Add(FlexGridSizer_Palette, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + FlexGridSizer5->Add(-1,-1,1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5); + FlexGridSizer4->Add(FlexGridSizer5, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); + FlexGridSizer2 = new wxFlexGridSizer(0, 4, 0, 0); + FlexGridSizer2->AddGrowableCol(1); + StaticText22 = new wxStaticText(ColorScrollWindow, ID_STATICTEXT24, _("Sparkles"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT24")); + FlexGridSizer2->Add(StaticText22, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); + Slider_SparkleFrequency = new wxSlider(ColorScrollWindow, ID_SLIDER_SparkleFrequency, 200, 10, 200, wxDefaultPosition, wxDefaultSize, wxSL_INVERSE, wxDefaultValidator, _T("ID_SLIDER_SparkleFrequency")); + FlexGridSizer2->Add(Slider_SparkleFrequency, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); + txtCtrlSparkleFreq = new wxTextCtrl(ColorScrollWindow, ID_TEXTCTRL5, _("200"), wxDefaultPosition, wxSize(32,20), wxTE_PROCESS_ENTER|wxTAB_TRAVERSAL, wxDefaultValidator, _T("ID_TEXTCTRL5")); + FlexGridSizer2->Add(txtCtrlSparkleFreq, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + BitmapButton_SparkleFrequency = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_SLIDER_SparkleFrequency, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_SLIDER_SparkleFrequency")); + BitmapButton_SparkleFrequency->SetDefault(); + BitmapButton_SparkleFrequency->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); + BitmapButton_SparkleFrequency->SetToolTip(_("Lock/Unlock. If Locked then a \"Create Random Effects\" will NOT change this value.")); + FlexGridSizer2->Add(BitmapButton_SparkleFrequency, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); + StaticText126 = new wxStaticText(ColorScrollWindow, ID_STATICTEXT127, _("Brightness"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT127")); + FlexGridSizer2->Add(StaticText126, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); + Slider_Brightness = new wxSlider(ColorScrollWindow, ID_SLIDER_Brightness, 100, 0, 400, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_SLIDER_Brightness")); + FlexGridSizer2->Add(Slider_Brightness, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); + txtCtlBrightness = new wxTextCtrl(ColorScrollWindow, ID_TEXTCTRL6, _("100"), wxDefaultPosition, wxSize(32,20), wxTE_PROCESS_ENTER|wxTAB_TRAVERSAL, wxDefaultValidator, _T("ID_TEXTCTRL6")); + FlexGridSizer2->Add(txtCtlBrightness, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + BitmapButton_Brightness = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_SLIDER_Brightness, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_SLIDER_Brightness")); + BitmapButton_Brightness->SetDefault(); + BitmapButton_Brightness->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); + BitmapButton_Brightness->SetToolTip(_("Lock/Unlock. If Locked then a \"Create Random Effects\" will NOT change this value.")); + FlexGridSizer2->Add(BitmapButton_Brightness, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); + StaticText127 = new wxStaticText(ColorScrollWindow, ID_STATICTEXT128, _("Contrast"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT128")); + FlexGridSizer2->Add(StaticText127, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); + Slider_Contrast = new wxSlider(ColorScrollWindow, ID_SLIDER_Contrast, 0, 0, 100, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_SLIDER_Contrast")); + FlexGridSizer2->Add(Slider_Contrast, 1, wxALL|wxEXPAND|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 2); + txtCtlContrast = new wxTextCtrl(ColorScrollWindow, ID_TEXTCTRL7, _("0"), wxDefaultPosition, wxSize(32,20), wxTE_PROCESS_ENTER|wxTAB_TRAVERSAL, wxDefaultValidator, _T("ID_TEXTCTRL7")); + FlexGridSizer2->Add(txtCtlContrast, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + BitmapButton_Contrast = new wxBitmapButton(ColorScrollWindow, ID_BITMAPBUTTON_SLIDER_Contrast, padlock16x16_blue_xpm, wxDefaultPosition, wxSize(13,13), wxBU_AUTODRAW|wxNO_BORDER, wxDefaultValidator, _T("ID_BITMAPBUTTON_SLIDER_Contrast")); + BitmapButton_Contrast->SetDefault(); + BitmapButton_Contrast->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION)); + BitmapButton_Contrast->SetToolTip(_("Lock/Unlock. If Locked then a \"Create Random Effects\" will NOT change this value.")); + FlexGridSizer2->Add(BitmapButton_Contrast, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); + FlexGridSizer4->Add(FlexGridSizer2, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 2); + ColorScrollWindow->SetSizer(FlexGridSizer4); + FlexGridSizer4->Fit(ColorScrollWindow); + FlexGridSizer4->SetSizeHints(ColorScrollWindow); + FlexGridSizer3->Add(ColorScrollWindow, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); + Panel_Sizer->SetSizer(FlexGridSizer3); + FlexGridSizer3->Fit(Panel_Sizer); + FlexGridSizer3->SetSizeHints(Panel_Sizer); + FlexGridSizer1->Add(Panel_Sizer, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0); + SetSizer(FlexGridSizer1); + FlexGridSizer1->Fit(this); + FlexGridSizer1->SetSizeHints(this); + + Connect(ID_CHECKBOX_Palette1,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ColorPanel::OnCheckBox_PaletteClick); + Connect(ID_CHECKBOX_Palette2,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ColorPanel::OnCheckBox_PaletteClick); + Connect(ID_CHECKBOX_Palette3,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ColorPanel::OnCheckBox_PaletteClick); + Connect(ID_CHECKBOX_Palette4,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ColorPanel::OnCheckBox_PaletteClick); + Connect(ID_CHECKBOX_Palette5,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ColorPanel::OnCheckBox_PaletteClick); + Connect(ID_CHECKBOX_Palette6,wxEVT_COMMAND_CHECKBOX_CLICKED,(wxObjectEventFunction)&ColorPanel::OnCheckBox_PaletteClick); + Connect(ID_BUTTON_Palette1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnButton_PaletteNumberClick); + Connect(ID_BUTTON_Palette2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnButton_PaletteNumberClick); + Connect(ID_BUTTON_Palette3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnButton_PaletteNumberClick); + Connect(ID_BUTTON_Palette4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnButton_PaletteNumberClick); + Connect(ID_BUTTON_Palette5,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnButton_PaletteNumberClick); + Connect(ID_BUTTON_Palette6,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnButton_PaletteNumberClick); + Connect(ID_BITMAPBUTTON_BUTTON_Palette1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnBitmapButton_Palette1Click); + Connect(ID_BITMAPBUTTON_BUTTON_Palette2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnBitmapButton_Palette2Click); + Connect(ID_BITMAPBUTTON_BUTTON_Palette3,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnBitmapButton_Palette3Click); + Connect(ID_BITMAPBUTTON_BUTTON_Palette4,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnBitmapButton_Palette4Click); + Connect(ID_BITMAPBUTTON_BUTTON_Palette5,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnBitmapButton_Palette5Click); + Connect(ID_BITMAPBUTTON_BUTTON_Palette6,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ColorPanel::OnBitmapButton_Palette6Click); + Connect(wxEVT_PAINT,(wxObjectEventFunction)&ColorPanel::OnPaint); + Connect(wxEVT_SIZE,(wxObjectEventFunction)&ColorPanel::OnResize); + //*) + + + SetDefaultPalette(); +} + +ColorPanel::~ColorPanel() +{ + //(*Destroy(ColorPanel) + //*) +} + + +void ColorPanel::SetButtonColor(wxBitmapButton* btn, const wxColour* c) +{ + btn->SetBackgroundColour(*c); + int test=c->Red()*0.299 + c->Green()*0.587 + c->Blue()*0.114; + btn->SetForegroundColour(test < 186 ? *wxWHITE : *wxBLACK); + + wxImage image(15, 15); + image.SetRGB(wxRect(0, 0, 15, 15), + c->Red(), c->Green(), c->Blue()); + wxBitmap bmp(image); + + btn->SetBitmap(bmp); +} + +wxString ColorPanel::GetColorString() +{ + wxString s,ChildName,AttrName; +// wxString prefix=GetAttrPrefix(); +// //~s=prefix+wxString::Format("SLIDER_Speed=%d",Slider_Speed->GetValue()); +// //~s+=prefix+"TEXTCTRL_Fadein="+TextCtrl_Fadein->GetValue(); +// //~s+=prefix+"TEXTCTRL_Fadeout="+TextCtrl_Fadeout->GetValue(); +// //~s+=prefix+wxString::Format("CHECKBOX_FitToTime=%d",CheckBox_FitToTime->GetValue()?1:0); +// //~s+=prefix+wxString::Format("CHECKBOX_OverlayBkg=%d",CheckBox_OverlayBkg->GetValue()?1:0); +// + wxColour color; + for (int i=1; i<=PALETTE_SIZE; i++) + { + color=GetPaletteColor(i); + AttrName.Printf("C_BUTTON_Palette%d=",i); + s+=AttrName+color.GetAsString(wxC2S_HTML_SYNTAX) + ","; + ChildName.Printf("ID_CHECKBOX_Palette%d",i); + AttrName.Printf("C_CHECKBOX_Palette%d",i); + wxCheckBox* ctrl=(wxCheckBox*)wxWindow::FindWindowByName(ChildName,this); + wxString v=(ctrl->IsChecked()) ? "1" : "0"; + s+=AttrName+"="+v + ","; + } + return s; +} + + + +wxColour ColorPanel::GetPaletteColor(int idx) +{ + switch (idx) + { + case 1: + return Button_Palette1->GetBackgroundColour(); + case 2: + return Button_Palette2->GetBackgroundColour(); + case 3: + return Button_Palette3->GetBackgroundColour(); + case 4: + return Button_Palette4->GetBackgroundColour(); + case 5: + return Button_Palette5->GetBackgroundColour(); + case 6: + return Button_Palette6->GetBackgroundColour(); + } + return *wxBLACK; +} + +// idx is 1-6 +void ColorPanel::SetPaletteColor(int idx, const wxColour* c) +{ + switch (idx) + { + case 1: + SetButtonColor(Button_Palette1,c); + break; + case 2: + SetButtonColor(Button_Palette2,c); + break; + case 3: + SetButtonColor(Button_Palette3,c); + break; + case 4: + SetButtonColor(Button_Palette4,c); + break; + case 5: + SetButtonColor(Button_Palette5,c); + break; + case 6: + SetButtonColor(Button_Palette6,c); + break; + } +} + +//allow array-like access to checkboxes also -DJ +wxCheckBox* ColorPanel::GetPaletteCheckbox(int idx) +{ + switch (idx) // idx is 1-6 + { + case 1: + return CheckBox_Palette1; + case 2: + return CheckBox_Palette2; + case 3: + return CheckBox_Palette3; + case 4: + return CheckBox_Palette4; + case 5: + return CheckBox_Palette5; + case 6: + return CheckBox_Palette6; + } + return CheckBox_Palette1; //0; +} + +//allow array-like access to buttons also -DJ +wxButton* ColorPanel::GetPaletteButton(int idx) +{ + switch (idx) // idx is 1-6 + { + case 1: + return Button_Palette1; + case 2: + return Button_Palette2; + case 3: + return Button_Palette3; + case 4: + return Button_Palette4; + case 5: + return Button_Palette5; + case 6: + return Button_Palette6; + } + return Button_Palette1; //0; +} + +void ColorPanel::SetDefaultPalette() +{ + SetButtonColor(Button_Palette1,wxRED); + SetButtonColor(Button_Palette2,wxGREEN); + SetButtonColor(Button_Palette3,wxBLUE); + SetButtonColor(Button_Palette4,wxYELLOW); + SetButtonColor(Button_Palette5,wxWHITE); + SetButtonColor(Button_Palette6,wxBLACK); +} + + + + +void ColorPanel::OnCheckBox_PaletteClick(wxCommandEvent& event) +{ + PaletteChanged=true; +} + +void ColorPanel::OnBitmapButton_Palette2Click(wxCommandEvent& event) +{ +} + +void ColorPanel::OnBitmapButton_Palette1Click(wxCommandEvent& event) +{ +} + +void ColorPanel::OnBitmapButton_Palette3Click(wxCommandEvent& event) +{ +} + +void ColorPanel::OnBitmapButton_Palette4Click(wxCommandEvent& event) +{ +} + +void ColorPanel::OnBitmapButton_Palette5Click(wxCommandEvent& event) +{ +} + +void ColorPanel::OnBitmapButton_Palette6Click(wxCommandEvent& event) +{ +} + +void ColorPanel::OnButton_PaletteNumberClick(wxCommandEvent& event) +{ + wxBitmapButton* w=(wxBitmapButton*)event.GetEventObject(); + wxColour color = w->GetBackgroundColour(); + colorData.SetColour(color); + wxColourDialog dialog(this, &colorData); + if (dialog.ShowModal() == wxID_OK) + { + wxColourData retData = dialog.GetColourData(); + wxColour color = retData.GetColour(); + SetButtonColor(w, &color); + PaletteChanged=true; + } + +} + +void ColorPanel::OnResize(wxSizeEvent& event) +{ + wxSize s = GetSize(); + Panel_Sizer->SetSize(s); + Panel_Sizer->SetMinSize(s); + Panel_Sizer->SetMaxSize(s); + Panel_Sizer->Refresh(); + + ColorScrollWindow->SetSize(s); + ColorScrollWindow->SetMinSize(s); + ColorScrollWindow->SetMaxSize(s); + + ColorScrollWindow->FitInside(); + ColorScrollWindow->SetScrollRate(5, 5); + ColorScrollWindow->Refresh(); + +} + +void ColorPanel::OnPaint(wxPaintEvent& event) +{ +} diff --git a/xLights/PixelBuffer.cpp b/xLights/PixelBuffer.cpp index dffb352486..43b1b194e9 100644 --- a/xLights/PixelBuffer.cpp +++ b/xLights/PixelBuffer.cpp @@ -1,628 +1,628 @@ -/*************************************************************** - * Name: PixelBuffer.cpp - * Purpose: Implements pixel buffer and effects - * Author: Matt Brown (dowdybrown@yahoo.com) - * Created: 2012-10-21 - * Copyright: 2012 by Matt Brown - * License: - This file is part of xLights. - - xLights is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - xLights is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with xLights. If not, see . -**************************************************************/ - -#include "PixelBuffer.h" -#include -#include - -PixelBufferClass::PixelBufferClass() -{ -} - -PixelBufferClass::~PixelBufferClass() -{ -} - -void PixelBufferClass::InitBuffer(wxXmlNode* ModelNode, bool zeroBased) -{ - SetFromXml(ModelNode, zeroBased); - SetModelBrightness(wxAtoi(ModelNode->GetAttribute("ModelBrightness","0"))); - for(size_t i=0; i<2; i++) - { - Effect[i].InitBuffer(BufferHt, BufferWi); - } -} - -void PixelBufferClass::Clear(int which) -{ - xlColour bgColor=*wxBLACK; - if (which != -1) Effect[which].Clear(bgColor); //just clear this one - else //clear them all - for(size_t i=0; i<2; i++) //why does this clear canvas twice? isn't it the same set of pixels for each2? -DJ - { - Effect[i].Clear(bgColor); - } -} - -// convert MixName to MixType enum -void PixelBufferClass::SetMixType(const wxString& MixName) -{ - if (MixName == "Effect 1") - { - MixType=Mix_Effect1; - } - else if (MixName == "Effect 2") - { - MixType=Mix_Effect2; - } - else if (MixName == "1 is Mask") - { - MixType=Mix_Mask1; - } - else if (MixName == "2 is Mask") - { - MixType=Mix_Mask2; - } - else if (MixName == "1 is Unmask") - { - MixType=Mix_Unmask1; - } - else if (MixName == "2 is Unmask") - { - MixType=Mix_Unmask2; - } - else if (MixName == "1 reveals 2") - { - MixType=Mix_1_reveals_2; - } - else if (MixName == "2 reveals 1") - { - MixType=Mix_2_reveals_1; - } - else if (MixName == "Layered") - { - MixType=Mix_Layered; - } - else if (MixName == "Average") - { - MixType=Mix_Average; - } - else if (MixName == "Bottom-Top") - { - MixType=Mix_BottomTop; - } - else if (MixName == "Left-Right") - { - MixType=Mix_LeftRight; - } - -} - -static long mixes_wanted = 0, mixes_needed = 0; -void PixelBufferClass::GetMixedColor(wxCoord x, wxCoord y, xlColour& c) -{ - xlColour c0,c1; - wxImage::HSVValue hsv,hsv0,hsv1; - wxImage::RGBValue rgbVal; - double emt, emtNot; - int n =0; //increase to change the curve of the crossfade - - ++mixes_wanted; -#if 0 //experimental -//short-circuit the most common cases here for better performance: -DJ - if (MixType == Mix_Effect1) - if (!effectMixVaries || (Effect[0].GetEffectTimeIntervalPosition(true) == 1.)) //result depends only on first color - { - if (fadeFactor[0] == 0.) { c.Set(0, 0, 0); return; } - if (fadeFactor[0] == 1.0) { Effect[0].GetPixel(x, y, c); return; } - } - if (MixType == Mix_Effect2) - if (!effectMixVaries || (Effect[0].GetEffectTimeIntervalPosition(true) == 0.)) //result depends only on second color - { - if (fadeFactor[1] == 0.) { c.Set(0, 0, 0); return; } - if (fadeFactor[1] == 1.0) { Effect[1].GetPixel(x, y, c); return; } - } -//TODO: there are a couple of additional cases for cross-mixing when threshold is at the other end of the range - if ((fadeFactor[0] == 0.) && (fadeFactor[1] == 0.)) { c.Set(0, 0, 0); return; } -//and 2 more cases below ... -#endif - Effect[0].GetPixel(x,y,c0); - Effect[1].GetPixel(x,y,c1); -#if 0 //goes with above - if (!c0.red && !c0.green && !c0.blue && !c1.red && !c1.green && !c1.blue) { c.Set(0, 0, 0); return; } //skip redundant calculations -DJ - if ((c0.red == c1.red) && (c0.green == c1.green) && (c0.blue == c1.blue) && (fadeFactor[0] == fadeFactor[1])) { c = c0; return; } -#endif - ++mixes_needed; //useful info for assessing how useful it is to short circuit the common cases -DJ - hsv0 = wxImage::RGBtoHSV( wxImage::RGBValue( c0.Red(), c0.Green(), c0.Blue())); - hsv1 = wxImage::RGBtoHSV(wxImage::RGBValue( c1.Red(), c1.Green(), c1.Blue())); - - hsv0.value *= fadeFactor[0]; - hsv1.value *= fadeFactor[1]; - - rgbVal = wxImage::HSVtoRGB(hsv0); - c0.Set(rgbVal.red, rgbVal.green, rgbVal.blue); - rgbVal = wxImage::HSVtoRGB(hsv1); - c1.Set(rgbVal.red, rgbVal.green, rgbVal.blue); - - float svthresh = effectMixThreshold; - if (effectMixVaries) //vary mix threshold gradually during effect interval -DJ -// effectMixThreshold = Effect[0].GetEffectPeriodPosition(); -// effectMixThreshold = 1 - Effect[0].GetEffectPeriodPosition(); //seems to be backwards, so reverse it - effectMixThreshold = 1 - Effect[0].GetEffectTimeIntervalPosition(true); //seems to be backwards, so reverse it -// debug(1, "get mixed color: varies? %d, mix thresh %f", effectMixVaries, effectMixThreshold); -// wxColour svc0 = c0, svc1 = c1; - - if (effectMixThreshold < 0) { - effectMixThreshold = 0; - } - - switch (MixType) - { - case Mix_Effect1: - case Mix_Effect2: - emt = effectMixThreshold; - emtNot = 1-effectMixThreshold; - if (!effectMixVaries) //make cross-fade linear; this inverts it? -DJ - { - emt = cos((M_PI/4)*(pow(2*emt-1,2*n+1)+1)); - emtNot = cos((M_PI/4)*(pow(2*emtNot-1,2*n+1)+1)); - } - - if (MixType == Mix_Effect2) - { - c0.Set(c0.Red()*(emtNot) ,c0.Green()*(emtNot), c0.Blue()*(emtNot)); - c1.Set(c1.Red()*(emt) ,c1.Green()*(emt), c1.Blue()*(emt)); - } - else - { - c0.Set(c0.Red()*(emt) ,c0.Green()*(emt), c0.Blue()*(emt)); - c1.Set(c1.Red()*(emtNot) ,c1.Green()*(emtNot), c1.Blue()*(emtNot)); - } - c.Set(c0.Red()+c1.Red(), c0.Green()+c1.Green(), c0.Blue()+c1.Blue()); -// if (effectMixVaries) debug(1, "get mixed color: varies? %d, mix thresh %f, c0 %d,%d,%d + c1 %d,%d,%d => c %d,%d,%d", effectMixVaries, effectMixThreshold, svc0.Red(), svc0.Green(), svc0.Blue(), svc1.Red(), svc1.Green(), svc1.Blue(), c.Red(), c.Green(), c.Blue()); - break; - case Mix_Mask1: - // first masks second - if (hsv0.value <= effectMixThreshold) // only if effect 1 is black - { - c=c1; // then show the color of effect 2 - } - else - { - c.Set(0, 0, 0); - } - break; - case Mix_Mask2: - // second masks first - if (hsv1.value <= effectMixThreshold) - { - c=c0; - } - else - { - c.Set(0, 0, 0); - } - break; - case Mix_Unmask1: - // first unmasks second - if (hsv0.value > effectMixThreshold) // if effect 1 is non black - { - - hsv1.value = hsv0.value; - rgbVal = wxImage::HSVtoRGB(hsv1); - c.Set(rgbVal.red, rgbVal.green, rgbVal.blue); - } - else - { - c.Set(0, 0, 0); - } - break; - case Mix_Unmask2: - // second unmasks first - if (hsv1.value > effectMixThreshold) // if effect 2 is non black - { - hsv0.value = hsv1.value; - rgbVal = wxImage::HSVtoRGB(hsv0); - c.Set(rgbVal.red, rgbVal.green, rgbVal.blue); - } - else - { - c.Set(0, 0, 0); - } - break; - case Mix_Layered: - if (hsv1.value <= effectMixThreshold) - { - c=c0; - } - else - { - c=c1; - } - break; - case Mix_Average: - // only average when both colors are non-black - if (c0.GetRGB() == 0) - { - c=c1; - } - else if (c1.GetRGB() == 0) - { - c=c0; - } - else - { - c.Set( (c0.Red()+c1.Red())/2, (c0.Green()+c1.Green())/2, (c0.Blue()+c1.Blue())/2 ); - } - break; - case Mix_BottomTop: - c=y < BufferHt/2 ? c0 : c1; - break; - case Mix_LeftRight: - c=x < BufferWi/2 ? c0 : c1; - break; - case Mix_1_reveals_2: - c = hsv0.value > effectMixThreshold ? c0 : c1; // if effect 1 is non black - break; - case Mix_2_reveals_1: - c = hsv1.value > effectMixThreshold ? c1 : c0; // if effect 2 is non black - break; - } - if (effectMixVaries) effectMixThreshold = svthresh; //put it back afterwards in case next row didn't change it -} - -void PixelBufferClass::SetPalette(int layer, wxColourVector& newcolors) -{ - xlColorVector p2; - for (int x = 0; x < newcolors.size(); x++) - { - p2.push_back(xlColor(newcolors[x])); - } - Effect[layer].SetPalette(p2); -} - -// Not currently used... -//size_t PixelBufferClass::GetColorCount(int layer) -//{ -// return Effect[layer].GetColorCount(); -//} - -// 10-200 or so, or 0 for no sparkle -void PixelBufferClass::SetSparkle(int freq) -{ - sparkle_count=freq; -} - -void PixelBufferClass::SetBrightness(int value) -{ - brightness=value; -} - -void PixelBufferClass::SetModelBrightness(int value) -{ - ModelBrightness=value; -} - -void PixelBufferClass::SetContrast(int value) -{ - contrast=value; -} - -void PixelBufferClass::SetMixThreshold(int value, bool varies) -{ - effectMixThreshold= (float)value/100.0; - effectMixVaries = varies; -} - -void PixelBufferClass::SetLayer(int newlayer, int period, int speed, bool ResetState) -{ - CurrentLayer=newlayer & 1; // only 0 or 1 is allowed - Effect[CurrentLayer].SetState(period,speed,ResetState, name); -} -void PixelBufferClass::SetFadeTimes(int layer, float inTime, float outTime) -{ - Effect[layer].SetFadeTimes(inTime, outTime); -} -void PixelBufferClass::SetTimes(int layer, int startTime, int endTime, int nextTime, bool new_effect_starts) -{ - Effect[layer].SetEffectDuration(startTime, endTime, nextTime, new_effect_starts); -} -void PixelBufferClass::SetFitToTime(int layer, bool fit) -{ - Effect[layer].SetFitToTime(fit); -} - -int PixelBufferClass::StartingPeriod() { - int effStartPer, effNextPer, effEndPer; - Effect[0].GetEffectPeriods( effStartPer, effNextPer, effEndPer); - return effStartPer; -} - -void PixelBufferClass::CalcOutput(int EffectPeriod) -{ - xlColor color; - wxImage::HSVValue hsv; - int curStep, fadeInSteps, fadeOutSteps; - - double fadeInFactor=1, fadeOutFactor=1; - - for(int ii=0; ii<2; ii++) - { - fadeFactor[ii] = 1.0; - Effect[ii].GetFadeSteps( fadeInSteps, fadeOutSteps); - if( fadeInSteps > 0 || fadeOutSteps > 0) - { - int effStartPer, effNextPer, effEndPer; - Effect[ii].GetEffectPeriods( effStartPer, effNextPer, effEndPer); - if (EffectPeriod < (effStartPer)+fadeInSteps) - { - curStep = EffectPeriod - effStartPer; - fadeInFactor = (double)curStep/(double)fadeInSteps; - } - if (EffectPeriod > (effNextPer)-fadeOutSteps) - { - curStep = EffectPeriod - (effNextPer-fadeOutSteps); - fadeOutFactor = 1-(double)curStep/(double)fadeOutSteps; - } - if(fadeInFactor < 1 && fadeOutFactor < 1) - { - fadeFactor[ii] = (fadeInFactor+fadeOutFactor)/(double)2.0; - } - else if (fadeInFactor<1) - { - fadeFactor[ii] = fadeInFactor; - } - else - { - fadeFactor[ii] = fadeOutFactor; - } - } - } - // layer calculation and map to output - size_t NodeCount=Nodes.size(); - for(size_t i=0; iIsVisible()) - { - // unmapped pixel - set to black - Nodes[i]->SetColor(0,0,0); - } - else - { - // get blend of two effects - GetMixedColor(Nodes[i]->Coords[0].bufX, Nodes[i]->Coords[0].bufY, color); - - // add sparkles - if (sparkle_count > 0 && color.GetRGB()!=0) - { - switch (Nodes[i]->sparkle%sparkle_count) - { - case 1: - case 7: - // too dim - //color.Set("#444444"); - break; - case 2: - case 6: - color.Set(0x88, 0x88, 0x88); - break; - case 3: - case 5: - color.Set(0xbb, 0xbb, 0xbb); - break; - case 4: - color.Set(255, 255, 255); - break; - } - Nodes[i]->sparkle++; - } - // Apply brightness - wxImage::RGBValue rgb(color.Red(),color.Green(),color.Blue()); -//TODO: bypass below hsv conversion if brightness == 100 && contrast == 100? - hsv = wxImage::RGBtoHSV(rgb); - //ModelBrightness=1.0; // we will use this until we figure how to pass in Model brightness - -//NOTE: ModelBrightness is additive (+/- adjustment), but brightness from effect settings is a multiplier (scaled) - float fModelBrightness=((float)ModelBrightness/100) + 1.0; - hsv.value = hsv.value * ((double)brightness/(double)100)*fModelBrightness; - - - // Apply Contrast - - if(hsv.value< 0.5) // reduce brightness when below 0.5 in the V value or increase if > 0.5 - { - hsv.value = hsv.value - (hsv.value* ((double)contrast/(double)100)); - } - else - { - - hsv.value = hsv.value + (hsv.value* ((double)contrast/(double)100)); - } - - - if(hsv.value < 0.0) hsv.value=0.0; - if(hsv.value > 1.0) hsv.value=1.0; - - - rgb = wxImage::HSVtoRGB(hsv); - - // set color for physical output - Nodes[i]->SetColor(rgb.red,rgb.green,rgb.blue); - } - } -} - -void PixelBufferClass::RenderOff(void) -{ - Effect[CurrentLayer].RenderOff(); -} - -void PixelBufferClass::RenderOn(int red, int green, int blue) -{ - Effect[CurrentLayer].RenderOn(red, green, blue); -} - -void PixelBufferClass::RenderBars(int PaletteRepeat, int Direction, bool Highlight, bool Show3D) -{ - Effect[CurrentLayer].RenderBars(PaletteRepeat,Direction,Highlight,Show3D); -} - -void PixelBufferClass::RenderButterfly(int ColorScheme, int Style, int Chunks, int Skip, int ButterflyDirection) -{ - Effect[CurrentLayer].RenderButterfly(ColorScheme,Style,Chunks,Skip, ButterflyDirection); -} - -void PixelBufferClass::RenderCircles(int number,int radius, bool bounce, bool collide, bool random, - bool radial, bool radial_3D, bool bubbles, int start_x, int start_y, bool plasma) -{ - Effect[CurrentLayer].RenderCircles(number, radius, bounce, collide, random, radial, radial_3D, bubbles, start_x, start_y, plasma); -} - -void PixelBufferClass::RenderColorWash(bool HorizFade, bool VertFade, int RepeatCount) -{ - Effect[CurrentLayer].RenderColorWash(HorizFade,VertFade,RepeatCount); -} - -void PixelBufferClass::RenderCurtain(int edge, int effect, int swag, bool repeat) -{ - Effect[CurrentLayer].RenderCurtain(edge,effect,swag,repeat); -} - -void PixelBufferClass::RenderFaces(int Phoneme) -{ - Effect[CurrentLayer].RenderFaces(Phoneme); -} -//void PixelBufferClass::RenderCoroFaces(int Phoneme, const wxString& x_y, const wxString& Outline_x_y, const wxString& Eyes_x_y/*, const wxString& parsed_xy*/) -void PixelBufferClass::RenderCoroFaces(const wxString& Phoneme, const wxString& eyes, bool face_outline) -{ -// Effect[CurrentLayer].RenderCoroFaces(Phoneme,x_y,Outline_x_y,Eyes_x_y/*, parsed_xy*/); - Effect[CurrentLayer].RenderCoroFaces(Phoneme, eyes, face_outline); -} - - -void PixelBufferClass::RenderFire(int HeightPct,int HueShift,bool GrowFire) -{ - Effect[CurrentLayer].RenderFire(HeightPct,HueShift,GrowFire); -} - -void PixelBufferClass::RenderFireworks(int Number_Explosions,int Count,float Velocity,int Fade) -{ - Effect[CurrentLayer].RenderFireworks(Number_Explosions,Count,Velocity,Fade); -} - -void PixelBufferClass::RenderGarlands(int GarlandType, int Spacing) -{ - Effect[CurrentLayer].RenderGarlands(GarlandType,Spacing); -} - -void PixelBufferClass::RenderGlediator( const wxString& NewPictureName) -{ - Effect[CurrentLayer].RenderGlediator(NewPictureName); -} - - -void PixelBufferClass::RenderLife(int Count, int Seed) -{ - Effect[CurrentLayer].RenderLife(Count,Seed); -} - -void PixelBufferClass::RenderMeteors(int MeteorType, int Count, int Length, int MeteorsEffect, int SwirlIntensity) -{ - Effect[CurrentLayer].RenderMeteors(MeteorType,Count,Length,MeteorsEffect,SwirlIntensity); -} - -void PixelBufferClass::RenderPiano(int Style, int NumKeys, int NumRows, int DrawMode, bool Clipping, const wxString& CueFilename, const wxString& MapFilename, const wxString& ShapeFilename) //added more controls -DJ -{ - Effect[CurrentLayer].RenderPiano(Style, NumKeys, NumRows, DrawMode, Clipping, CueFilename, MapFilename, ShapeFilename); -} - -void PixelBufferClass::RenderPictures(int dir, const wxString& NewPictureName,int GifSpeed, bool is20FPS) -{ - Effect[CurrentLayer].RenderPictures(dir,NewPictureName,GifSpeed, is20FPS); -} -void PixelBufferClass::RenderPinwheel(int pinwheel_arms,int pinwheel_twist,int pinwheel_thickness, - bool pinwheel_rotation,int pinwheel_3D,int xc_adj, int yc_adj, int pinwheel_armsize) -{ - Effect[CurrentLayer].RenderPinwheel(pinwheel_arms,pinwheel_twist, - pinwheel_thickness,pinwheel_rotation,pinwheel_3D,xc_adj,yc_adj,pinwheel_armsize); -} -void PixelBufferClass::RenderRipple(int Object_To_Draw, int Movement, int Ripple_Thickness,int CheckBox_Ripple3D) -{ - Effect[CurrentLayer].RenderRipple( Object_To_Draw, Movement, Ripple_Thickness, CheckBox_Ripple3D); -} -void PixelBufferClass::RenderShimmer(int Duty_Factor,bool Use_All_Colors,bool Blink_Timing,int Blinks_Per_Row) -{ - Effect[CurrentLayer].RenderShimmer(Duty_Factor,Use_All_Colors,Blink_Timing,Blinks_Per_Row ); -} -void PixelBufferClass::RenderSingleStrandChase(int ColorScheme,int Number_Chases, int Color_Mix1, - int Chase_Spacing1,int Chase_Type1,bool Chase_3dFade1,bool Chase_Group_All) -{ - Effect[CurrentLayer].RenderSingleStrandChase( ColorScheme,Number_Chases, Color_Mix1, - Chase_Spacing1,Chase_Type1, Chase_3dFade1,Chase_Group_All); -} -void PixelBufferClass::RenderSingleStrandSkips(int Skips_BandSize, int Skips_SkipSize, int Skips_StartPos, const wxString &Skips_Direction) -{ - Effect[CurrentLayer].RenderSingleStrandSkips(Skips_BandSize, Skips_SkipSize, Skips_StartPos, Skips_Direction); -} - -void PixelBufferClass::RenderSnowflakes(int Count, int SnowflakeType) -{ - Effect[CurrentLayer].RenderSnowflakes(Count,SnowflakeType); -} - -void PixelBufferClass::RenderSnowstorm(int Count, int Length) -{ - Effect[CurrentLayer].RenderSnowstorm(Count,Length); -} - -void PixelBufferClass::RenderSpirals(int PaletteRepeat, int Direction, int Rotation, int Thickness, - bool Blend, bool Show3D, bool grow, bool shrink) -{ - Effect[CurrentLayer].RenderSpirals(PaletteRepeat,Direction,Rotation,Thickness,Blend,Show3D,grow,shrink); -} - -void PixelBufferClass::RenderSpirograph(int R, int r, int d, bool Animate) -{ - Effect[CurrentLayer].RenderSpirograph( R, r, d, Animate); -} -void PixelBufferClass::RenderStrobe(int Number_Strobes,int StrobeDuration,int Strobe_Type) -{ - Effect[CurrentLayer].RenderStrobe(Number_Strobes,StrobeDuration,Strobe_Type); -} - -void PixelBufferClass::RenderText(int Position1, const wxString& Line1, const wxString& FontString1,int dir1,bool center1,int Effect1,int Countdown1, - int Position2, const wxString& Line2, const wxString& FontString2,int dir2,bool center2,int Effect2,int Countdown2, - int Position3, const wxString& Line3, const wxString& FontString3,int dir3,bool center3,int Effect3,int Countdown3, - int Position4, const wxString& Line4, const wxString& FontString4,int dir4,bool center4,int Effect4,int Countdown4) -{ - Effect[CurrentLayer].RenderText(Position1,Line1,FontString1,dir1,center1,Effect1,Countdown1, - Position2,Line2,FontString2,dir2,center2,Effect2,Countdown2, - Position3,Line3,FontString3,dir3,center3,Effect3,Countdown3, - Position4,Line4,FontString4,dir4,center4,Effect4,Countdown4); -} - -void PixelBufferClass::RenderTree(int Branches) -{ - Effect[CurrentLayer].RenderTree(Branches); -} - -void PixelBufferClass::RenderTwinkle(int Count,int Steps,bool Strobe) -{ - Effect[CurrentLayer].RenderTwinkle(Count,Steps,Strobe); -} - -void PixelBufferClass::RenderWave(int WaveType,int FillColor,bool MirrorWave,int NumberWaves,int ThicknessWave, - int WaveHeight, int WaveDirection) -{ - Effect[CurrentLayer].RenderWave(WaveType, FillColor, MirrorWave, NumberWaves, ThicknessWave, WaveHeight, WaveDirection); -} +/*************************************************************** + * Name: PixelBuffer.cpp + * Purpose: Implements pixel buffer and effects + * Author: Matt Brown (dowdybrown@yahoo.com) + * Created: 2012-10-21 + * Copyright: 2012 by Matt Brown + * License: + This file is part of xLights. + + xLights is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + xLights is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with xLights. If not, see . +**************************************************************/ + +#include "PixelBuffer.h" +#include +#include + +PixelBufferClass::PixelBufferClass() +{ +} + +PixelBufferClass::~PixelBufferClass() +{ +} + +void PixelBufferClass::InitBuffer(wxXmlNode* ModelNode, bool zeroBased) +{ + SetFromXml(ModelNode, zeroBased); + SetModelBrightness(wxAtoi(ModelNode->GetAttribute("ModelBrightness","0"))); + for(size_t i=0; i<2; i++) + { + Effect[i].InitBuffer(BufferHt, BufferWi); + } +} + +void PixelBufferClass::Clear(int which) +{ + xlColour bgColor=*wxBLACK; + if (which != -1) Effect[which].Clear(bgColor); //just clear this one + else //clear them all + for(size_t i=0; i<2; i++) //why does this clear canvas twice? isn't it the same set of pixels for each2? -DJ + { + Effect[i].Clear(bgColor); + } +} + +// convert MixName to MixType enum +void PixelBufferClass::SetMixType(const wxString& MixName) +{ + if (MixName == "Effect 1") + { + MixType=Mix_Effect1; + } + else if (MixName == "Effect 2") + { + MixType=Mix_Effect2; + } + else if (MixName == "1 is Mask") + { + MixType=Mix_Mask1; + } + else if (MixName == "2 is Mask") + { + MixType=Mix_Mask2; + } + else if (MixName == "1 is Unmask") + { + MixType=Mix_Unmask1; + } + else if (MixName == "2 is Unmask") + { + MixType=Mix_Unmask2; + } + else if (MixName == "1 reveals 2") + { + MixType=Mix_1_reveals_2; + } + else if (MixName == "2 reveals 1") + { + MixType=Mix_2_reveals_1; + } + else if (MixName == "Layered") + { + MixType=Mix_Layered; + } + else if (MixName == "Average") + { + MixType=Mix_Average; + } + else if (MixName == "Bottom-Top") + { + MixType=Mix_BottomTop; + } + else if (MixName == "Left-Right") + { + MixType=Mix_LeftRight; + } + +} + +static long mixes_wanted = 0, mixes_needed = 0; +void PixelBufferClass::GetMixedColor(wxCoord x, wxCoord y, xlColour& c) +{ + xlColour c0,c1; + wxImage::HSVValue hsv,hsv0,hsv1; + wxImage::RGBValue rgbVal; + double emt, emtNot; + int n =0; //increase to change the curve of the crossfade + + ++mixes_wanted; +#if 0 //experimental +//short-circuit the most common cases here for better performance: -DJ + if (MixType == Mix_Effect1) + if (!effectMixVaries || (Effect[0].GetEffectTimeIntervalPosition(true) == 1.)) //result depends only on first color + { + if (fadeFactor[0] == 0.) { c.Set(0, 0, 0); return; } + if (fadeFactor[0] == 1.0) { Effect[0].GetPixel(x, y, c); return; } + } + if (MixType == Mix_Effect2) + if (!effectMixVaries || (Effect[0].GetEffectTimeIntervalPosition(true) == 0.)) //result depends only on second color + { + if (fadeFactor[1] == 0.) { c.Set(0, 0, 0); return; } + if (fadeFactor[1] == 1.0) { Effect[1].GetPixel(x, y, c); return; } + } +//TODO: there are a couple of additional cases for cross-mixing when threshold is at the other end of the range + if ((fadeFactor[0] == 0.) && (fadeFactor[1] == 0.)) { c.Set(0, 0, 0); return; } +//and 2 more cases below ... +#endif + Effect[0].GetPixel(x,y,c0); + Effect[1].GetPixel(x,y,c1); +#if 0 //goes with above + if (!c0.red && !c0.green && !c0.blue && !c1.red && !c1.green && !c1.blue) { c.Set(0, 0, 0); return; } //skip redundant calculations -DJ + if ((c0.red == c1.red) && (c0.green == c1.green) && (c0.blue == c1.blue) && (fadeFactor[0] == fadeFactor[1])) { c = c0; return; } +#endif + ++mixes_needed; //useful info for assessing how useful it is to short circuit the common cases -DJ + hsv0 = wxImage::RGBtoHSV( wxImage::RGBValue( c0.Red(), c0.Green(), c0.Blue())); + hsv1 = wxImage::RGBtoHSV(wxImage::RGBValue( c1.Red(), c1.Green(), c1.Blue())); + + hsv0.value *= fadeFactor[0]; + hsv1.value *= fadeFactor[1]; + + rgbVal = wxImage::HSVtoRGB(hsv0); + c0.Set(rgbVal.red, rgbVal.green, rgbVal.blue); + rgbVal = wxImage::HSVtoRGB(hsv1); + c1.Set(rgbVal.red, rgbVal.green, rgbVal.blue); + + float svthresh = effectMixThreshold; + if (effectMixVaries) //vary mix threshold gradually during effect interval -DJ +// effectMixThreshold = Effect[0].GetEffectPeriodPosition(); +// effectMixThreshold = 1 - Effect[0].GetEffectPeriodPosition(); //seems to be backwards, so reverse it + effectMixThreshold = 1 - Effect[0].GetEffectTimeIntervalPosition(true); //seems to be backwards, so reverse it +// debug(1, "get mixed color: varies? %d, mix thresh %f", effectMixVaries, effectMixThreshold); +// wxColour svc0 = c0, svc1 = c1; + + if (effectMixThreshold < 0) { + effectMixThreshold = 0; + } + + switch (MixType) + { + case Mix_Effect1: + case Mix_Effect2: + emt = effectMixThreshold; + emtNot = 1-effectMixThreshold; + if (!effectMixVaries) //make cross-fade linear; this inverts it? -DJ + { + emt = cos((M_PI/4)*(pow(2*emt-1,2*n+1)+1)); + emtNot = cos((M_PI/4)*(pow(2*emtNot-1,2*n+1)+1)); + } + + if (MixType == Mix_Effect2) + { + c0.Set(c0.Red()*(emtNot) ,c0.Green()*(emtNot), c0.Blue()*(emtNot)); + c1.Set(c1.Red()*(emt) ,c1.Green()*(emt), c1.Blue()*(emt)); + } + else + { + c0.Set(c0.Red()*(emt) ,c0.Green()*(emt), c0.Blue()*(emt)); + c1.Set(c1.Red()*(emtNot) ,c1.Green()*(emtNot), c1.Blue()*(emtNot)); + } + c.Set(c0.Red()+c1.Red(), c0.Green()+c1.Green(), c0.Blue()+c1.Blue()); +// if (effectMixVaries) debug(1, "get mixed color: varies? %d, mix thresh %f, c0 %d,%d,%d + c1 %d,%d,%d => c %d,%d,%d", effectMixVaries, effectMixThreshold, svc0.Red(), svc0.Green(), svc0.Blue(), svc1.Red(), svc1.Green(), svc1.Blue(), c.Red(), c.Green(), c.Blue()); + break; + case Mix_Mask1: + // first masks second + if (hsv0.value <= effectMixThreshold) // only if effect 1 is black + { + c=c1; // then show the color of effect 2 + } + else + { + c.Set(0, 0, 0); + } + break; + case Mix_Mask2: + // second masks first + if (hsv1.value <= effectMixThreshold) + { + c=c0; + } + else + { + c.Set(0, 0, 0); + } + break; + case Mix_Unmask1: + // first unmasks second + if (hsv0.value > effectMixThreshold) // if effect 1 is non black + { + + hsv1.value = hsv0.value; + rgbVal = wxImage::HSVtoRGB(hsv1); + c.Set(rgbVal.red, rgbVal.green, rgbVal.blue); + } + else + { + c.Set(0, 0, 0); + } + break; + case Mix_Unmask2: + // second unmasks first + if (hsv1.value > effectMixThreshold) // if effect 2 is non black + { + hsv0.value = hsv1.value; + rgbVal = wxImage::HSVtoRGB(hsv0); + c.Set(rgbVal.red, rgbVal.green, rgbVal.blue); + } + else + { + c.Set(0, 0, 0); + } + break; + case Mix_Layered: + if (hsv1.value <= effectMixThreshold) + { + c=c0; + } + else + { + c=c1; + } + break; + case Mix_Average: + // only average when both colors are non-black + if (c0.GetRGB() == 0) + { + c=c1; + } + else if (c1.GetRGB() == 0) + { + c=c0; + } + else + { + c.Set( (c0.Red()+c1.Red())/2, (c0.Green()+c1.Green())/2, (c0.Blue()+c1.Blue())/2 ); + } + break; + case Mix_BottomTop: + c=y < BufferHt/2 ? c0 : c1; + break; + case Mix_LeftRight: + c=x < BufferWi/2 ? c0 : c1; + break; + case Mix_1_reveals_2: + c = hsv0.value > effectMixThreshold ? c0 : c1; // if effect 1 is non black + break; + case Mix_2_reveals_1: + c = hsv1.value > effectMixThreshold ? c1 : c0; // if effect 2 is non black + break; + } + if (effectMixVaries) effectMixThreshold = svthresh; //put it back afterwards in case next row didn't change it +} + +void PixelBufferClass::SetPalette(int layer, wxColourVector& newcolors) +{ + xlColorVector p2; + for (int x = 0; x < newcolors.size(); x++) + { + p2.push_back(xlColor(newcolors[x])); + } + Effect[layer].SetPalette(p2); +} + +// Not currently used... +//size_t PixelBufferClass::GetColorCount(int layer) +//{ +// return Effect[layer].GetColorCount(); +//} + +// 10-200 or so, or 0 for no sparkle +void PixelBufferClass::SetSparkle(int freq) +{ + sparkle_count=freq; +} + +void PixelBufferClass::SetBrightness(int value) +{ + brightness=value; +} + +void PixelBufferClass::SetModelBrightness(int value) +{ + ModelBrightness=value; +} + +void PixelBufferClass::SetContrast(int value) +{ + contrast=value; +} + +void PixelBufferClass::SetMixThreshold(int value, bool varies) +{ + effectMixThreshold= (float)value/100.0; + effectMixVaries = varies; +} + +void PixelBufferClass::SetLayer(int newlayer, int period, int speed, bool ResetState) +{ + CurrentLayer=newlayer & 1; // only 0 or 1 is allowed + Effect[CurrentLayer].SetState(period,speed,ResetState, name); +} +void PixelBufferClass::SetFadeTimes(int layer, float inTime, float outTime) +{ + Effect[layer].SetFadeTimes(inTime, outTime); +} +void PixelBufferClass::SetTimes(int layer, int startTime, int endTime, int nextTime, bool new_effect_starts) +{ + Effect[layer].SetEffectDuration(startTime, endTime, nextTime, new_effect_starts); +} +void PixelBufferClass::SetFitToTime(int layer, bool fit) +{ + Effect[layer].SetFitToTime(fit); +} + +int PixelBufferClass::StartingPeriod() { + int effStartPer, effNextPer, effEndPer; + Effect[0].GetEffectPeriods( effStartPer, effNextPer, effEndPer); + return effStartPer; +} + +void PixelBufferClass::CalcOutput(int EffectPeriod) +{ + xlColor color; + wxImage::HSVValue hsv; + int curStep, fadeInSteps, fadeOutSteps; + + double fadeInFactor=1, fadeOutFactor=1; + + for(int ii=0; ii<2; ii++) + { + fadeFactor[ii] = 1.0; + Effect[ii].GetFadeSteps( fadeInSteps, fadeOutSteps); + if( fadeInSteps > 0 || fadeOutSteps > 0) + { + int effStartPer, effNextPer, effEndPer; + Effect[ii].GetEffectPeriods( effStartPer, effNextPer, effEndPer); + if (EffectPeriod < (effStartPer)+fadeInSteps) + { + curStep = EffectPeriod - effStartPer; + fadeInFactor = (double)curStep/(double)fadeInSteps; + } + if (EffectPeriod > (effNextPer)-fadeOutSteps) + { + curStep = EffectPeriod - (effNextPer-fadeOutSteps); + fadeOutFactor = 1-(double)curStep/(double)fadeOutSteps; + } + if(fadeInFactor < 1 && fadeOutFactor < 1) + { + fadeFactor[ii] = (fadeInFactor+fadeOutFactor)/(double)2.0; + } + else if (fadeInFactor<1) + { + fadeFactor[ii] = fadeInFactor; + } + else + { + fadeFactor[ii] = fadeOutFactor; + } + } + } + // layer calculation and map to output + size_t NodeCount=Nodes.size(); + for(size_t i=0; iIsVisible()) + { + // unmapped pixel - set to black + Nodes[i]->SetColor(0,0,0); + } + else + { + // get blend of two effects + GetMixedColor(Nodes[i]->Coords[0].bufX, Nodes[i]->Coords[0].bufY, color); + + // add sparkles + if (sparkle_count > 0 && color.GetRGB()!=0) + { + switch (Nodes[i]->sparkle%sparkle_count) + { + case 1: + case 7: + // too dim + //color.Set("#444444"); + break; + case 2: + case 6: + color.Set(0x88, 0x88, 0x88); + break; + case 3: + case 5: + color.Set(0xbb, 0xbb, 0xbb); + break; + case 4: + color.Set(255, 255, 255); + break; + } + Nodes[i]->sparkle++; + } + // Apply brightness + wxImage::RGBValue rgb(color.Red(),color.Green(),color.Blue()); +//TODO: bypass below hsv conversion if brightness == 100 && contrast == 100? + hsv = wxImage::RGBtoHSV(rgb); + //ModelBrightness=1.0; // we will use this until we figure how to pass in Model brightness + +//NOTE: ModelBrightness is additive (+/- adjustment), but brightness from effect settings is a multiplier (scaled) + float fModelBrightness=((float)ModelBrightness/100) + 1.0; + hsv.value = hsv.value * ((double)brightness/(double)100)*fModelBrightness; + + + // Apply Contrast + + if(hsv.value< 0.5) // reduce brightness when below 0.5 in the V value or increase if > 0.5 + { + hsv.value = hsv.value - (hsv.value* ((double)contrast/(double)100)); + } + else + { + + hsv.value = hsv.value + (hsv.value* ((double)contrast/(double)100)); + } + + + if(hsv.value < 0.0) hsv.value=0.0; + if(hsv.value > 1.0) hsv.value=1.0; + + + rgb = wxImage::HSVtoRGB(hsv); + + // set color for physical output + Nodes[i]->SetColor(rgb.red,rgb.green,rgb.blue); + } + } +} + +void PixelBufferClass::RenderOff(void) +{ + Effect[CurrentLayer].RenderOff(); +} + +void PixelBufferClass::RenderOn(int red, int green, int blue) +{ + Effect[CurrentLayer].RenderOn(red, green, blue); +} + +void PixelBufferClass::RenderBars(int PaletteRepeat, int Direction, bool Highlight, bool Show3D) +{ + Effect[CurrentLayer].RenderBars(PaletteRepeat,Direction,Highlight,Show3D); +} + +void PixelBufferClass::RenderButterfly(int ColorScheme, int Style, int Chunks, int Skip, int ButterflyDirection) +{ + Effect[CurrentLayer].RenderButterfly(ColorScheme,Style,Chunks,Skip, ButterflyDirection); +} + +void PixelBufferClass::RenderCircles(int number,int radius, bool bounce, bool collide, bool random, + bool radial, bool radial_3D, bool bubbles, int start_x, int start_y, bool plasma) +{ + Effect[CurrentLayer].RenderCircles(number, radius, bounce, collide, random, radial, radial_3D, bubbles, start_x, start_y, plasma); +} + +void PixelBufferClass::RenderColorWash(bool HorizFade, bool VertFade, int RepeatCount) +{ + Effect[CurrentLayer].RenderColorWash(HorizFade,VertFade,RepeatCount); +} + +void PixelBufferClass::RenderCurtain(int edge, int effect, int swag, bool repeat) +{ + Effect[CurrentLayer].RenderCurtain(edge,effect,swag,repeat); +} + +void PixelBufferClass::RenderFaces(int Phoneme) +{ + Effect[CurrentLayer].RenderFaces(Phoneme); +} +//void PixelBufferClass::RenderCoroFaces(int Phoneme, const wxString& x_y, const wxString& Outline_x_y, const wxString& Eyes_x_y/*, const wxString& parsed_xy*/) +void PixelBufferClass::RenderCoroFaces(const wxString& Phoneme, const wxString& eyes, bool face_outline) +{ +// Effect[CurrentLayer].RenderCoroFaces(Phoneme,x_y,Outline_x_y,Eyes_x_y/*, parsed_xy*/); + Effect[CurrentLayer].RenderCoroFaces(Phoneme, eyes, face_outline); +} + + +void PixelBufferClass::RenderFire(int HeightPct,int HueShift,bool GrowFire) +{ + Effect[CurrentLayer].RenderFire(HeightPct,HueShift,GrowFire); +} + +void PixelBufferClass::RenderFireworks(int Number_Explosions,int Count,float Velocity,int Fade) +{ + Effect[CurrentLayer].RenderFireworks(Number_Explosions,Count,Velocity,Fade); +} + +void PixelBufferClass::RenderGarlands(int GarlandType, int Spacing) +{ + Effect[CurrentLayer].RenderGarlands(GarlandType,Spacing); +} + +void PixelBufferClass::RenderGlediator( const wxString& NewPictureName) +{ + Effect[CurrentLayer].RenderGlediator(NewPictureName); +} + + +void PixelBufferClass::RenderLife(int Count, int Seed) +{ + Effect[CurrentLayer].RenderLife(Count,Seed); +} + +void PixelBufferClass::RenderMeteors(int MeteorType, int Count, int Length, int MeteorsEffect, int SwirlIntensity) +{ + Effect[CurrentLayer].RenderMeteors(MeteorType,Count,Length,MeteorsEffect,SwirlIntensity); +} + +void PixelBufferClass::RenderPiano(int Style, int NumKeys, int NumRows, int DrawMode, bool Clipping, const wxString& CueFilename, const wxString& MapFilename, const wxString& ShapeFilename) //added more controls -DJ +{ + Effect[CurrentLayer].RenderPiano(Style, NumKeys, NumRows, DrawMode, Clipping, CueFilename, MapFilename, ShapeFilename); +} + +void PixelBufferClass::RenderPictures(int dir, const wxString& NewPictureName,int GifSpeed, bool is20FPS) +{ + Effect[CurrentLayer].RenderPictures(dir,NewPictureName,GifSpeed, is20FPS); +} +void PixelBufferClass::RenderPinwheel(int pinwheel_arms,int pinwheel_twist,int pinwheel_thickness, + bool pinwheel_rotation,int pinwheel_3D,int xc_adj, int yc_adj, int pinwheel_armsize) +{ + Effect[CurrentLayer].RenderPinwheel(pinwheel_arms,pinwheel_twist, + pinwheel_thickness,pinwheel_rotation,pinwheel_3D,xc_adj,yc_adj,pinwheel_armsize); +} +void PixelBufferClass::RenderRipple(int Object_To_Draw, int Movement, int Ripple_Thickness,int CheckBox_Ripple3D) +{ + Effect[CurrentLayer].RenderRipple( Object_To_Draw, Movement, Ripple_Thickness, CheckBox_Ripple3D); +} +void PixelBufferClass::RenderShimmer(int Duty_Factor,bool Use_All_Colors,bool Blink_Timing,int Blinks_Per_Row) +{ + Effect[CurrentLayer].RenderShimmer(Duty_Factor,Use_All_Colors,Blink_Timing,Blinks_Per_Row ); +} +void PixelBufferClass::RenderSingleStrandChase(int ColorScheme,int Number_Chases, int Color_Mix1, + int Chase_Spacing1,int Chase_Type1,bool Chase_3dFade1,bool Chase_Group_All) +{ + Effect[CurrentLayer].RenderSingleStrandChase( ColorScheme,Number_Chases, Color_Mix1, + Chase_Spacing1,Chase_Type1, Chase_3dFade1,Chase_Group_All); +} +void PixelBufferClass::RenderSingleStrandSkips(int Skips_BandSize, int Skips_SkipSize, int Skips_StartPos, const wxString &Skips_Direction) +{ + Effect[CurrentLayer].RenderSingleStrandSkips(Skips_BandSize, Skips_SkipSize, Skips_StartPos, Skips_Direction); +} + +void PixelBufferClass::RenderSnowflakes(int Count, int SnowflakeType) +{ + Effect[CurrentLayer].RenderSnowflakes(Count,SnowflakeType); +} + +void PixelBufferClass::RenderSnowstorm(int Count, int Length) +{ + Effect[CurrentLayer].RenderSnowstorm(Count,Length); +} + +void PixelBufferClass::RenderSpirals(int PaletteRepeat, int Direction, int Rotation, int Thickness, + bool Blend, bool Show3D, bool grow, bool shrink) +{ + Effect[CurrentLayer].RenderSpirals(PaletteRepeat,Direction,Rotation,Thickness,Blend,Show3D,grow,shrink); +} + +void PixelBufferClass::RenderSpirograph(int R, int r, int d, bool Animate) +{ + Effect[CurrentLayer].RenderSpirograph( R, r, d, Animate); +} +void PixelBufferClass::RenderStrobe(int Number_Strobes,int StrobeDuration,int Strobe_Type) +{ + Effect[CurrentLayer].RenderStrobe(Number_Strobes,StrobeDuration,Strobe_Type); +} + +void PixelBufferClass::RenderText(int Position1, const wxString& Line1, const wxString& FontString1,int dir1,bool center1,int Effect1,int Countdown1, + int Position2, const wxString& Line2, const wxString& FontString2,int dir2,bool center2,int Effect2,int Countdown2, + int Position3, const wxString& Line3, const wxString& FontString3,int dir3,bool center3,int Effect3,int Countdown3, + int Position4, const wxString& Line4, const wxString& FontString4,int dir4,bool center4,int Effect4,int Countdown4) +{ + Effect[CurrentLayer].RenderText(Position1,Line1,FontString1,dir1,center1,Effect1,Countdown1, + Position2,Line2,FontString2,dir2,center2,Effect2,Countdown2, + Position3,Line3,FontString3,dir3,center3,Effect3,Countdown3, + Position4,Line4,FontString4,dir4,center4,Effect4,Countdown4); +} + +void PixelBufferClass::RenderTree(int Branches) +{ + Effect[CurrentLayer].RenderTree(Branches); +} + +void PixelBufferClass::RenderTwinkle(int Count,int Steps,bool Strobe) +{ + Effect[CurrentLayer].RenderTwinkle(Count,Steps,Strobe); +} + +void PixelBufferClass::RenderWave(int WaveType,int FillColor,bool MirrorWave,int NumberWaves,int ThicknessWave, + int WaveHeight, int WaveDirection) +{ + Effect[CurrentLayer].RenderWave(WaveType, FillColor, MirrorWave, NumberWaves, ThicknessWave, WaveHeight, WaveDirection); +} diff --git a/xLights/ViewsDialog.cpp b/xLights/ViewsDialog.cpp index 7da367fb59..93a261608a 100644 --- a/xLights/ViewsDialog.cpp +++ b/xLights/ViewsDialog.cpp @@ -1,24 +1,24 @@ #include "ViewsDialog.h" - -#include "djdebug.cpp" - -#define WANT_DEBUG_IMPL -#define WANT_DEBUG 100 //unbuffered in case app crashes - -#ifndef debug_function //dummy defs if debug cpp not included above -#define debug(level, ...) -#define debug_more(level, ...) -#define debug_function(level) -#endif - -//cut down on mem allocs outside debug() when WANT_DEBUG is off: -#ifdef WANT_DEBUG -#define IFDEBUG(stmt) stmt -#else -#define IFDEBUG(stmt) -#endif // WANT_DEBUG - - + +#include "djdebug.cpp" + +#define WANT_DEBUG_IMPL +#define WANT_DEBUG 100 //unbuffered in case app crashes + +#ifndef debug_function //dummy defs if debug cpp not included above +#define debug(level, ...) +#define debug_more(level, ...) +#define debug_function(level) +#endif + +//cut down on mem allocs outside debug() when WANT_DEBUG is off: +#ifdef WANT_DEBUG +#define IFDEBUG(stmt) stmt +#else +#define IFDEBUG(stmt) +#endif // WANT_DEBUG + + //(*InternalHeaders(ViewsDialog) #include @@ -65,7 +65,7 @@ ViewsDialog::ViewsDialog(wxWindow* parent,wxWindowID id) wxStaticBoxSizer* StaticBoxSizer1; wxFlexGridSizer* FlexGridSizer1; wxFlexGridSizer* FlexGridSizer11; - + Create(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY")); SetClientSize(wxSize(450,493)); FlexGridSizer1 = new wxFlexGridSizer(0, 1, 0, 0); @@ -128,7 +128,7 @@ ViewsDialog::ViewsDialog(wxWindow* parent,wxWindowID id) SetSizer(FlexGridSizer1); SetSizer(FlexGridSizer1); Layout(); - + Connect(ID_BT_ADD_VIEW,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ViewsDialog::OnBtAddViewClick); Connect(ID_BT_DELETE_VIEW,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ViewsDialog::OnBtRemoveViewClick); Connect(ID_LST_VIEWS,wxEVT_COMMAND_LISTBOX_SELECTED,(wxObjectEventFunction)&ViewsDialog::OnlstViewsSelect); @@ -137,29 +137,29 @@ ViewsDialog::ViewsDialog(wxWindow* parent,wxWindowID id) Connect(ID_BT_REVOVE_MODEL_VIEW,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ViewsDialog::OnbtRemoveModelFromViewClick); Connect(ID_BUTTON_UPDATE_VIEW,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ViewsDialog::OnbtnUpdateViewClick); Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&ViewsDialog::OnbtCloseViewsClick); - //*) -} - -void ViewsDialog::SetModelAndViewNodes(wxXmlNode* modelsNode,wxXmlNode* viewsNode) -{ - wxString name; - wxXmlNode* e; - models = modelsNode; - views = viewsNode; - for(e=views->GetChildren(); e!=NULL; e=e->GetNext() ) - { - if (e->GetName() == "view") - { - name=e->GetAttribute("name"); - if (!name.IsEmpty()) - { - lstViews->Append(name,e); - } - } - } - + //*) } - + +void ViewsDialog::SetModelAndViewNodes(wxXmlNode* modelsNode,wxXmlNode* viewsNode) +{ + wxString name; + wxXmlNode* e; + models = modelsNode; + views = viewsNode; + for(e=views->GetChildren(); e!=NULL; e=e->GetNext() ) + { + if (e->GetName() == "view") + { + name=e->GetAttribute("name"); + if (!name.IsEmpty()) + { + lstViews->Append(name,e); + } + } + } + +} + ViewsDialog::~ViewsDialog() { //(*Destroy(ViewsDialog) @@ -168,130 +168,130 @@ ViewsDialog::~ViewsDialog() void ViewsDialog::OnlstViewsSelect(wxCommandEvent& event) -{ - wxString viewModels; - wxXmlNode* e; - e=(wxXmlNode*)(lstViews->GetClientData(lstViews->GetSelection())); - viewModels = e->GetAttribute("models"); - debug(1,"Model="); - lstModelsInView->Clear(); - wxArrayString model=wxSplit(viewModels,','); - for(int i=0;iAppend(model[i]); - } - Text_ViewName->SetValue(lstViews->GetString(lstViews->GetSelection())); - PopulateUnusedModels(model); +{ + wxString viewModels; + wxXmlNode* e; + e=(wxXmlNode*)(lstViews->GetClientData(lstViews->GetSelection())); + viewModels = e->GetAttribute("models"); + debug(1,"Model="); + lstModelsInView->Clear(); + wxArrayString model=wxSplit(viewModels,','); + for(int i=0;iAppend(model[i]); + } + Text_ViewName->SetValue(lstViews->GetString(lstViews->GetSelection())); + PopulateUnusedModels(model); } - -void ViewsDialog::PopulateUnusedModels(wxArrayString model) -{ - wxString name; - wxXmlNode* e; - lstAddModelToViews->Clear(); - for(e=models->GetChildren(); e!=NULL; e=e->GetNext() ) - { - if (e->GetName() == "model") - { - name=e->GetAttribute("name"); - if(model.Index(name,false,false)==wxNOT_FOUND) - { - lstAddModelToViews->Append(name); - } - } - } + +void ViewsDialog::PopulateUnusedModels(wxArrayString model) +{ + wxString name; + wxXmlNode* e; + lstAddModelToViews->Clear(); + for(e=models->GetChildren(); e!=NULL; e=e->GetNext() ) + { + if (e->GetName() == "model") + { + name=e->GetAttribute("name"); + if(model.Index(name,false,false)==wxNOT_FOUND) + { + lstAddModelToViews->Append(name); + } + } + } } void ViewsDialog::OnbtAddModelToViewClick(wxCommandEvent& event) -{ - int selectedIndex = lstAddModelToViews->GetSelection(); - if(selectedIndex != wxNOT_FOUND) - { - lstModelsInView->Append(lstAddModelToViews->GetString(selectedIndex)); - lstAddModelToViews->Delete(selectedIndex); - } - if(selectedIndexGetCount()) - { +{ + int selectedIndex = lstAddModelToViews->GetSelection(); + if(selectedIndex != wxNOT_FOUND) + { + lstModelsInView->Append(lstAddModelToViews->GetString(selectedIndex)); + lstAddModelToViews->Delete(selectedIndex); + } + if(selectedIndexGetCount()) + { lstAddModelToViews->SetSelection(selectedIndex,TRUE); - } - else - { + } + else + { lstAddModelToViews->SetSelection(lstAddModelToViews->GetCount()-1,TRUE); - } + } } void ViewsDialog::OnbtRemoveModelFromViewClick(wxCommandEvent& event) { - int selectedIndex = lstModelsInView->GetSelection(); - if(selectedIndex != wxNOT_FOUND) - { - lstAddModelToViews->Append(lstModelsInView->GetString(selectedIndex)); - lstModelsInView->Delete(selectedIndex); + int selectedIndex = lstModelsInView->GetSelection(); + if(selectedIndex != wxNOT_FOUND) + { + lstAddModelToViews->Append(lstModelsInView->GetString(selectedIndex)); + lstModelsInView->Delete(selectedIndex); } - if(selectedIndexGetCount()) - { + if(selectedIndexGetCount()) + { lstModelsInView->SetSelection(selectedIndex,TRUE); - } - else - { + } + else + { lstModelsInView->SetSelection(lstModelsInView->GetCount()-1,TRUE); - } + } } void ViewsDialog::OnbtnUpdateViewClick(wxCommandEvent& event) -{ - wxXmlNode* e; - if(lstViews->GetSelection() != wxNOT_FOUND) - { - wxString viewModels=""; - for(int i=0;iGetCount();i++) - { - if (iGetCount()-1) - { - viewModels += lstModelsInView->GetString(i) + ","; - } - else - { - viewModels += lstModelsInView->GetString(i); - } - } - lstViews->SetString(lstViews->GetSelection(),Text_ViewName->GetValue()); - e=(wxXmlNode*)(lstViews->GetClientData(lstViews->GetSelection())); - e->DeleteAttribute("name"); - e->AddAttribute("name",Text_ViewName->GetValue()); - e->DeleteAttribute("models"); - e->AddAttribute("models",viewModels); - } +{ + wxXmlNode* e; + if(lstViews->GetSelection() != wxNOT_FOUND) + { + wxString viewModels=""; + for(int i=0;iGetCount();i++) + { + if (iGetCount()-1) + { + viewModels += lstModelsInView->GetString(i) + ","; + } + else + { + viewModels += lstModelsInView->GetString(i); + } + } + lstViews->SetString(lstViews->GetSelection(),Text_ViewName->GetValue()); + e=(wxXmlNode*)(lstViews->GetClientData(lstViews->GetSelection())); + e->DeleteAttribute("name"); + e->AddAttribute("name",Text_ViewName->GetValue()); + e->DeleteAttribute("models"); + e->AddAttribute("models",viewModels); + } } void ViewsDialog::OnText_ViewNameTextEnter(wxCommandEvent& event) -{ +{ } void ViewsDialog::OnBtAddViewClick(wxCommandEvent& event) -{ - wxArrayString arrModels; - wxXmlNode* e=new wxXmlNode(wxXML_ELEMENT_NODE, "view"); - e->AddAttribute("name", "New View"); - e->AddAttribute("models", ""); - views->AddChild(e); - lstViews->Append("New View",e); - lstViews->SetSelection(lstViews->GetCount()-1); - Text_ViewName->SetValue("New View"); - PopulateUnusedModels(arrModels); +{ + wxArrayString arrModels; + wxXmlNode* e=new wxXmlNode(wxXML_ELEMENT_NODE, "view"); + e->AddAttribute("name", "New View"); + e->AddAttribute("models", ""); + views->AddChild(e); + lstViews->Append("New View",e); + lstViews->SetSelection(lstViews->GetCount()-1); + Text_ViewName->SetValue("New View"); + PopulateUnusedModels(arrModels); } void ViewsDialog::OnBtRemoveViewClick(wxCommandEvent& event) -{ - if(lstViews->GetSelection() != wxNOT_FOUND) - { - wxXmlNode* e=(wxXmlNode*)(lstViews->GetClientData(lstViews->GetSelection())); - views->RemoveChild(e); - lstViews->Delete(lstViews->GetSelection()); +{ + if(lstViews->GetSelection() != wxNOT_FOUND) + { + wxXmlNode* e=(wxXmlNode*)(lstViews->GetClientData(lstViews->GetSelection())); + views->RemoveChild(e); + lstViews->Delete(lstViews->GetSelection()); } } void ViewsDialog::OnbtCloseViewsClick(wxCommandEvent& event) -{ +{ this->EndModal(wxID_OK); } diff --git a/xLights/nccdll/dllmain.cpp b/xLights/nccdll/dllmain.cpp index 8a4edd3105..69b58914b3 100644 --- a/xLights/nccdll/dllmain.cpp +++ b/xLights/nccdll/dllmain.cpp @@ -1,19 +1,19 @@ -// dllmain.cpp : Defines the entry point for the DLL application. -#include "stdafx.h" - -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - +// dllmain.cpp : Defines the entry point for the DLL application. +#include "stdafx.h" + +BOOL APIENTRY DllMain( HMODULE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + diff --git a/xLights/nccdll/nccdll.cpp b/xLights/nccdll/nccdll.cpp index dec1abdb1a..f5a5ff4a71 100644 --- a/xLights/nccdll/nccdll.cpp +++ b/xLights/nccdll/nccdll.cpp @@ -1,22 +1,22 @@ -// nccdll.cpp : Defines the exported functions for the DLL application. -// - -#include "stdafx.h" -#include "nccdll.h" - - -// This is an example of an exported variable -NCCDLL_API int nnccdll=0; - -// This is an example of an exported function. -NCCDLL_API int fnnccdll(void) -{ - return 42; -} - -// This is the constructor of a class that has been exported. -// see nccdll.h for the class definition -Cnccdll::Cnccdll() -{ - return; -} +// nccdll.cpp : Defines the exported functions for the DLL application. +// + +#include "stdafx.h" +#include "nccdll.h" + + +// This is an example of an exported variable +NCCDLL_API int nnccdll=0; + +// This is an example of an exported function. +NCCDLL_API int fnnccdll(void) +{ + return 42; +} + +// This is the constructor of a class that has been exported. +// see nccdll.h for the class definition +Cnccdll::Cnccdll() +{ + return; +} diff --git a/xLights/nccdll/nccdll.h b/xLights/nccdll/nccdll.h index e9ec92487c..a5d036c2b9 100644 --- a/xLights/nccdll/nccdll.h +++ b/xLights/nccdll/nccdll.h @@ -1,22 +1,22 @@ -// The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the NCCDLL_EXPORTS -// symbol defined on the command line. This symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// NCCDLL_API functions as being imported from a DLL, whereas this DLL sees symbols -// defined with this macro as being exported. -#ifdef NCCDLL_EXPORTS -#define NCCDLL_API __declspec(dllexport) -#else -#define NCCDLL_API __declspec(dllimport) -#endif - -// This class is exported from the nccdll.dll -class NCCDLL_API Cnccdll { -public: - Cnccdll(void); - // TODO: add your methods here. -}; - -extern NCCDLL_API int nnccdll; - -NCCDLL_API int fnnccdll(void); +// The following ifdef block is the standard way of creating macros which make exporting +// from a DLL simpler. All files within this DLL are compiled with the NCCDLL_EXPORTS +// symbol defined on the command line. This symbol should not be defined on any project +// that uses this DLL. This way any other project whose source files include this file see +// NCCDLL_API functions as being imported from a DLL, whereas this DLL sees symbols +// defined with this macro as being exported. +#ifdef NCCDLL_EXPORTS +#define NCCDLL_API __declspec(dllexport) +#else +#define NCCDLL_API __declspec(dllimport) +#endif + +// This class is exported from the nccdll.dll +class NCCDLL_API Cnccdll { +public: + Cnccdll(void); + // TODO: add your methods here. +}; + +extern NCCDLL_API int nnccdll; + +NCCDLL_API int fnnccdll(void); diff --git a/xLights/nccdll/nccdll.sln b/xLights/nccdll/nccdll.sln index ae90717e18..50c05e4047 100644 --- a/xLights/nccdll/nccdll.sln +++ b/xLights/nccdll/nccdll.sln @@ -1,20 +1,20 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nccdll", "nccdll.vcxproj", "{4935F45E-3CD8-4672-A4BD-09B8EADD6248}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4935F45E-3CD8-4672-A4BD-09B8EADD6248}.Debug|Win32.ActiveCfg = Debug|Win32 - {4935F45E-3CD8-4672-A4BD-09B8EADD6248}.Debug|Win32.Build.0 = Debug|Win32 - {4935F45E-3CD8-4672-A4BD-09B8EADD6248}.Release|Win32.ActiveCfg = Release|Win32 - {4935F45E-3CD8-4672-A4BD-09B8EADD6248}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nccdll", "nccdll.vcxproj", "{4935F45E-3CD8-4672-A4BD-09B8EADD6248}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4935F45E-3CD8-4672-A4BD-09B8EADD6248}.Debug|Win32.ActiveCfg = Debug|Win32 + {4935F45E-3CD8-4672-A4BD-09B8EADD6248}.Debug|Win32.Build.0 = Debug|Win32 + {4935F45E-3CD8-4672-A4BD-09B8EADD6248}.Release|Win32.ActiveCfg = Release|Win32 + {4935F45E-3CD8-4672-A4BD-09B8EADD6248}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/xLights/nccdll/nccdll.vcxproj b/xLights/nccdll/nccdll.vcxproj index d2b8b664a3..d66977917b 100644 --- a/xLights/nccdll/nccdll.vcxproj +++ b/xLights/nccdll/nccdll.vcxproj @@ -1,126 +1,126 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {4935F45E-3CD8-4672-A4BD-09B8EADD6248} - Win32Proj - nccdll - - - - DynamicLibrary - true - Unicode - - - DynamicLibrary - false - true - Unicode - - - - - - - - - - - - - true - C:\wxWidgets-3.0.0vc\lib\vc_lib\mswud;C:\wxWidgets-3.0.0vc\include;$ProjectDir);..;$(IncludePath) - C:\wxWidgets-3.0.0vc\lib\vc_lib;$(LibraryPath) - - - false - C:\wxWidgets-3.0.0vc\lib\vc_lib\mswu;C:\wxWidgets-3.0.0vc\include;$(IncludePath) - C:\wxWidgets-3.0.0vc\lib\vc_lib;$(LibraryPath) - - - - Use - Level3 - Disabled - NCCDLLIMPL;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;NCCDLL_EXPORTS;%(PreprocessorDefinitions) - stdafx.h - - - Windows - true - wxbase30ud.lib;wxmsw30ud_core.lib;wxregexud.lib;wxpngd.lib;wxzlibd.lib;comctl32.lib;rpcrt4.lib;winmm.lib;advapi32.lib;wsock32.lib;%(AdditionalDependencies) - - - - - Level3 - NotUsing - MaxSpeed - true - true - WIN32;NDEBUG;_WINDOWS;_USRDLL;NCCDLL_EXPORTS;NCCDLLIMPL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - 4244;4305;4101;4018;%(DisableSpecificWarnings) - - - Windows - true - true - true - wxbase30u.lib;wxmsw30u_core.lib;wxregexu.lib;wxpng.lib;wxzlib.lib;comctl32.lib;rpcrt4.lib;winmm.lib;advapi32.lib;wsock32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - false - - - - - - Create - Create - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + + {4935F45E-3CD8-4672-A4BD-09B8EADD6248} + Win32Proj + nccdll + + + + DynamicLibrary + true + Unicode + + + DynamicLibrary + false + true + Unicode + + + + + + + + + + + + + true + C:\wxWidgets-3.0.0vc\lib\vc_lib\mswud;C:\wxWidgets-3.0.0vc\include;$ProjectDir);..;$(IncludePath) + C:\wxWidgets-3.0.0vc\lib\vc_lib;$(LibraryPath) + + + false + C:\wxWidgets-3.0.0vc\lib\vc_lib\mswu;C:\wxWidgets-3.0.0vc\include;$(IncludePath) + C:\wxWidgets-3.0.0vc\lib\vc_lib;$(LibraryPath) + + + + Use + Level3 + Disabled + NCCDLLIMPL;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;NCCDLL_EXPORTS;%(PreprocessorDefinitions) + stdafx.h + + + Windows + true + wxbase30ud.lib;wxmsw30ud_core.lib;wxregexud.lib;wxpngd.lib;wxzlibd.lib;comctl32.lib;rpcrt4.lib;winmm.lib;advapi32.lib;wsock32.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;NCCDLL_EXPORTS;NCCDLLIMPL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + 4244;4305;4101;4018;%(DisableSpecificWarnings) + + + Windows + true + true + true + wxbase30u.lib;wxmsw30u_core.lib;wxregexu.lib;wxpng.lib;wxzlib.lib;comctl32.lib;rpcrt4.lib;winmm.lib;advapi32.lib;wsock32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + false + + + + + + Create + Create + + + + + \ No newline at end of file diff --git a/xLights/nccdll/nccdll.vcxproj.filters b/xLights/nccdll/nccdll.vcxproj.filters index 8faa8da070..39ae9e0c56 100644 --- a/xLights/nccdll/nccdll.vcxproj.filters +++ b/xLights/nccdll/nccdll.vcxproj.filters @@ -1,102 +1,102 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + \ No newline at end of file diff --git a/xLights/nccdll/stdafx.cpp b/xLights/nccdll/stdafx.cpp index 8b1faa31bc..e4a8256c93 100644 --- a/xLights/nccdll/stdafx.cpp +++ b/xLights/nccdll/stdafx.cpp @@ -1,8 +1,8 @@ -// stdafx.cpp : source file that includes just the standard includes -// nccdll.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file +// stdafx.cpp : source file that includes just the standard includes +// nccdll.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/xLights/nccdll/stdafx.h b/xLights/nccdll/stdafx.h index e432351e03..7a260f0024 100644 --- a/xLights/nccdll/stdafx.h +++ b/xLights/nccdll/stdafx.h @@ -1,22 +1,22 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include - - -// TODO: reference additional headers your program requires here - -#include -#include -#include - -#pragma warning( disable : 4244 4305 4101 4018) - +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include + + +// TODO: reference additional headers your program requires here + +#include +#include +#include + +#pragma warning( disable : 4244 4305 4101 4018) + diff --git a/xLights/nccdll/targetver.h b/xLights/nccdll/targetver.h index 90e767bfce..87c0086de7 100644 --- a/xLights/nccdll/targetver.h +++ b/xLights/nccdll/targetver.h @@ -1,8 +1,8 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include