2
* colourKeyFrameDialog.cpp - Colour property keyframe selection dialog
3
* Copyright (C) 2013, D Haley
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
// -*- C++ -*- generated by wxGlade 0.6.5 on Fri Sep 14 09:37:57 2012
20
#include "colourKeyFrameDialog.h"
21
#include "common/stringFuncs.h"
23
#include "common/translation.h"
25
#include <wx/colordlg.h>
30
// begin wxGlade: ::extracode
35
ID_TEXT_INITIAL_VALUE,
42
//FIXME: Is currently duplicated from realKeyframeDialog. Needs to be
52
ColourKeyFrameDialog::ColourKeyFrameDialog(wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long style):
53
wxDialog(parent, id, title, pos, size, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxMAXIMIZE_BOX|wxMINIMIZE_BOX)
55
// begin wxGlade: ColourKeyFrameDialog::ColourKeyFrameDialog
56
sizerMainArea_staticbox = new wxStaticBox(this, -1, wxTRANS("Keyframe Data"));
57
labelTransition = new wxStaticText(this, wxID_ANY, wxTRANS("Transition"));
58
//FIXME: THis is declared in animator.h - use that def.
59
const wxString comboTransition_choices[] = {
63
comboTransition = new wxComboBox(this, ID_COMBO_TRANSITION, _(""), wxDefaultPosition, wxDefaultSize, 2, comboTransition_choices, wxCB_DROPDOWN|wxCB_READONLY);
64
labelFrameStart = new wxStaticText(this, wxID_ANY, wxTRANS("Start Frame"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
65
textFrameStart = new wxTextCtrl(this, ID_TEXT_FRAME_START, wxEmptyString);
66
labelFrameEnd = new wxStaticText(this, wxID_ANY, wxTRANS("End Frame"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
67
textFrameEnd = new wxTextCtrl(this, ID_TEXT_FRAME_END, wxEmptyString);
68
verticalLine = new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL);
69
labelStartVal = new wxStaticText(this, wxID_ANY, wxTRANS("Initial Value"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
70
btnStartColour = new wxButton(this, ID_BTN_START_VALUE, wxTRANS("startColour"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
71
labelFinalVal = new wxStaticText(this, wxID_ANY, wxTRANS("Final Value"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
72
btnEndColour = new wxButton(this, ID_BTN_FINAL_VALUE, wxTRANS("endColour"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
73
buttonCancel = new wxButton(this, wxID_CANCEL, wxEmptyString);
74
buttonOK = new wxButton(this, wxID_OK, wxEmptyString);
76
comboTransition->SetSelection(1);
77
transitionMode=TRANSITION_INTERP;
78
endFrameOK=startFrameOK=false;
79
startRed=startGreen=startBlue=0;
80
endRed=endGreen=endBlue=0;
84
updateButtonColours();
92
BEGIN_EVENT_TABLE(ColourKeyFrameDialog, wxDialog)
93
// begin wxGlade: ColourKeyFrameDialog::event_table
94
EVT_COMBOBOX(ID_COMBO_TRANSITION, ColourKeyFrameDialog::OnComboTransition)
95
EVT_TEXT(ID_TEXT_FRAME_START, ColourKeyFrameDialog::OnTextStartFrame)
96
EVT_TEXT(ID_TEXT_FRAME_END, ColourKeyFrameDialog::OnTextEndFrame)
97
EVT_BUTTON(ID_BTN_START_VALUE, ColourKeyFrameDialog::OnBtnStartColour)
98
EVT_BUTTON(ID_BTN_FINAL_VALUE, ColourKeyFrameDialog::OnBtnEndColour)
102
size_t ColourKeyFrameDialog::getStartFrame() const
104
ASSERT(startFrameOK);
108
size_t ColourKeyFrameDialog::getEndFrame() const
114
std::string ColourKeyFrameDialog::getEndValue() const
116
ASSERT(transitionMode!=TRANSITION_STEP);
118
genColString(endRed,endGreen,endBlue,s);
122
std::string ColourKeyFrameDialog::getStartValue() const
125
genColString(startRed,startGreen,startBlue,s);
129
void ColourKeyFrameDialog::OnComboTransition(wxCommandEvent &event)
131
ASSERT(event.GetInt() < TRANSITION_END);
133
transitionMode=event.GetInt();
135
btnEndColour->Enable(transitionMode != TRANSITION_STEP);
136
textFrameEnd->Enable(transitionMode!=TRANSITION_STEP);
139
void ColourKeyFrameDialog::OnTextStartFrame(wxCommandEvent &event)
141
startFrameOK=validateTextAsStream(textFrameStart,startFrame);
146
void ColourKeyFrameDialog::OnTextEndFrame(wxCommandEvent &event)
148
endFrameOK=validateTextAsStream(textFrameEnd,endFrame);
153
void ColourKeyFrameDialog::OnBtnStartColour(wxCommandEvent &event)
156
wxColourDialog *colDg=new wxColourDialog(this->GetParent(),&d);
158
if( colDg->ShowModal() == wxID_OK)
162
c=colDg->GetColourData().GetColour();
165
startGreen=c.Green();
168
updateButtonColours();
173
void ColourKeyFrameDialog::OnBtnEndColour(wxCommandEvent &event)
176
wxColourDialog *colDg=new wxColourDialog(this->GetParent(),&d);
178
if( colDg->ShowModal() == wxID_OK)
182
c=colDg->GetColourData().GetColour();
188
updateButtonColours();
194
void ColourKeyFrameDialog::updateOKButton()
200
//Ensure start frame is > end frame
203
isOK&=(startFrame<endFrame);
206
textFrameStart->SetBackgroundColour(*wxCYAN);
207
textFrameEnd->SetBackgroundColour(*wxCYAN);
211
textFrameStart->SetBackgroundColour(wxNullColour);
212
textFrameEnd->SetBackgroundColour(wxNullColour);
216
buttonOK->Enable(isOK);
219
void ColourKeyFrameDialog::updateButtonColours()
222
colD.Set(startRed,startGreen,startBlue);
223
btnStartColour->SetForegroundColour(colD);
225
colD.Set(endRed,endGreen,endBlue);
226
btnEndColour->SetForegroundColour(colD);
229
// wxGlade: add ColourKeyFrameDialog event handlers
232
void ColourKeyFrameDialog::set_properties()
234
// begin wxGlade: ColourKeyFrameDialog::set_properties
235
SetTitle(wxTRANS("Key Frame : Colour"));
236
comboTransition->SetSelection(-1);
237
btnStartColour->SetToolTip(wxTRANS("Colour at the start of the transtition"));
238
btnEndColour->SetToolTip(wxTRANS("Colour at end of transition"));
243
void ColourKeyFrameDialog::do_layout()
245
// begin wxGlade: ColourKeyFrameDialog::do_layout
246
wxBoxSizer* sizerTop = new wxBoxSizer(wxVERTICAL);
247
wxBoxSizer* sizerBUttons = new wxBoxSizer(wxHORIZONTAL);
248
wxStaticBoxSizer* sizerMainArea = new wxStaticBoxSizer(sizerMainArea_staticbox, wxHORIZONTAL);
249
wxBoxSizer* sizerRight = new wxBoxSizer(wxVERTICAL);
250
wxBoxSizer* sizerRightFinal = new wxBoxSizer(wxHORIZONTAL);
251
wxBoxSizer* sizerRightInitial = new wxBoxSizer(wxHORIZONTAL);
252
wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL);
253
wxBoxSizer* sizerEndFrame = new wxBoxSizer(wxHORIZONTAL);
254
wxBoxSizer* sizerStartFrame = new wxBoxSizer(wxHORIZONTAL);
255
wxBoxSizer* sizerTransition = new wxBoxSizer(wxHORIZONTAL);
256
sizerTop->Add(20, 5, 0, 0, 0);
257
sizerMainArea->Add(10, 20, 0, 0, 0);
258
sizerLeft->Add(20, 10, 0, 0, 0);
259
sizerTransition->Add(labelTransition, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 14);
260
sizerTransition->Add(comboTransition, 1, wxLEFT|wxALIGN_CENTER_VERTICAL, 5);
261
sizerLeft->Add(sizerTransition, 1, wxEXPAND, 0);
262
sizerStartFrame->Add(labelFrameStart, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 5);
263
sizerStartFrame->Add(textFrameStart, 1, wxLEFT|wxALIGN_CENTER_VERTICAL, 4);
264
sizerLeft->Add(sizerStartFrame, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 0);
265
sizerEndFrame->Add(labelFrameEnd, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 12);
266
sizerEndFrame->Add(textFrameEnd, 1, wxLEFT|wxALIGN_CENTER_VERTICAL, 4);
267
sizerLeft->Add(sizerEndFrame, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 0);
268
sizerLeft->Add(20, 10, 0, 0, 0);
269
sizerMainArea->Add(sizerLeft, 2, wxEXPAND, 0);
270
sizerMainArea->Add(verticalLine, 0, wxLEFT|wxRIGHT|wxEXPAND, 5);
271
sizerRight->Add(20, 20, 1, 0, 0);
272
sizerRightInitial->Add(20, 20, 1, 0, 0);
273
sizerRightInitial->Add(labelStartVal, 2, wxRIGHT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 0);
274
sizerRightInitial->Add(btnStartColour, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 3);
275
sizerRightInitial->Add(20, 20, 1, 0, 0);
276
sizerRight->Add(sizerRightInitial, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 0);
277
sizerRightFinal->Add(20, 20, 1, 0, 0);
278
sizerRightFinal->Add(labelFinalVal, 2, wxRIGHT|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 9);
279
sizerRightFinal->Add(btnEndColour, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 3);
280
sizerRightFinal->Add(20, 20, 1, 0, 0);
281
sizerRight->Add(sizerRightFinal, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 0);
282
sizerRight->Add(20, 20, 1, 0, 0);
283
sizerMainArea->Add(sizerRight, 2, wxEXPAND, 0);
284
sizerMainArea->Add(10, 20, 0, 0, 0);
285
sizerTop->Add(sizerMainArea, 1, wxEXPAND, 0);
286
sizerBUttons->Add(20, 20, 1, 0, 0);
287
sizerBUttons->Add(buttonCancel, 0, wxALL, 4);
288
sizerBUttons->Add(buttonOK, 0, wxALL, 4);
289
sizerTop->Add(sizerBUttons, 0, wxEXPAND, 0);