Skip to content

Commit 7d46802

Browse files
committed
add: use floatctrl instead of slider for rotate
1 parent 39a2290 commit 7d46802

File tree

1 file changed

+49
-13
lines changed

1 file changed

+49
-13
lines changed

src/PicProcessorRotate.cpp

+49-13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "myConfig.h"
55
#include "gimage_parse.h"
66
#include "gimage_process.h"
7+
#include "myFloatCtrl.h"
78
#include "util.h"
89
#include "undo.xpm"
910
#include "run.xpm"
@@ -279,7 +280,8 @@ class RotatePanel: public PicProcPanel
279280
r45 = new wxRadioButton(this, ROTATE45, _("Rotate < 45:"));
280281
b->Add(r45 , 0, wxALIGN_LEFT | wxALL, 1);
281282

282-
rotate = new rotateSlider(this, wxID_ANY, initialvalue);
283+
//rotate = new rotateSlider(this, wxID_ANY, initialvalue);
284+
rotate = new myFloatCtrl(this, wxID_ANY, "", 0.0);
283285
b->Add(rotate , 0, wxALIGN_LEFT | wxALL, 1);
284286

285287

@@ -311,7 +313,10 @@ class RotatePanel: public PicProcPanel
311313
else if ((int) initialvalue == 90) r90->SetValue(true);
312314
else if ((int) initialvalue == 180) r180->SetValue(true);
313315
else if ((int) initialvalue == 270) r270->SetValue(true);
314-
else r45->SetValue(true);
316+
else {
317+
r45->SetValue(true);
318+
rotate->SetFloatValue(initialvalue);
319+
}
315320

316321
rotateSelection();
317322
SetSizerAndFit(b);
@@ -328,6 +333,8 @@ class RotatePanel: public PicProcPanel
328333
q->getCommandTree()->Bind(wxEVT_TREE_SEL_CHANGED, &RotatePanel::OnCommandtreeSelChanged, this);
329334
Bind(wxEVT_TIMER, &RotatePanel::OnTimer, this);
330335
Bind(wxEVT_CHAR_HOOK, &RotatePanel::OnKey, this);
336+
Bind(myFLOATCTRL_CHANGE, &RotatePanel::floatParamChanged, this);
337+
Bind(myFLOATCTRL_UPDATE, &RotatePanel::floatParamUpdated, this);
331338
Thaw();
332339
}
333340

@@ -375,15 +382,43 @@ class RotatePanel: public PicProcPanel
375382
void OnTimer(wxTimerEvent& event)
376383
{
377384
if (autocrop->GetValue())
378-
q->setParams(wxString::Format("%2.1f,autocrop",rotate->GetValue()/10.0));
385+
q->setParams(wxString::Format("%2.1f,autocrop",rotate->GetFloatValue()));
379386
else
380-
q->setParams(wxString::Format("%2.1f",rotate->GetValue()/10.0));
387+
q->setParams(wxString::Format("%2.1f",rotate->GetFloatValue()));
381388
q->processPic();
382389
DeletePendingEvents();
383390
t.Stop();
384391
event.Skip();
385392
}
386393

394+
void floatParamChanged(wxCommandEvent& event)
395+
{
396+
preview->setAutocrop(autocrop->GetValue());
397+
preview->Rotate(rotate->GetFloatValue());
398+
if (thumb) {
399+
thumb = false;
400+
}
401+
else {
402+
t.Start(500,wxTIMER_ONE_SHOT);
403+
Refresh();
404+
Update();
405+
}
406+
}
407+
408+
void floatParamUpdated(wxCommandEvent& event)
409+
{
410+
preview->setAutocrop(autocrop->GetValue());
411+
preview->Rotate(rotate->GetFloatValue());
412+
if (thumb) {
413+
thumb = false;
414+
}
415+
else {
416+
t.Start(500,wxTIMER_ONE_SHOT);
417+
Refresh();
418+
Update();
419+
}
420+
}
421+
387422
void rotateSelection()
388423
{
389424
double rotation;
@@ -397,7 +432,7 @@ class RotatePanel: public PicProcPanel
397432
//preview->Show(true);
398433

399434
preview->setAutocrop(autocrop->GetValue());
400-
rotation = rotate->GetValue()/10.0;
435+
rotation = rotate->GetFloatValue();
401436
if (autocrop->GetValue())
402437
q->setParams(wxString::Format("%2.1f,autocrop",rotation));
403438
else
@@ -433,7 +468,7 @@ class RotatePanel: public PicProcPanel
433468
void OnChanged(wxCommandEvent& event)
434469
{
435470
preview->setAutocrop(autocrop->GetValue());
436-
preview->Rotate(rotate->GetValue()/10.0);
471+
preview->Rotate(rotate->GetFloatValue());
437472
if (thumb) {
438473
thumb = false;
439474
}
@@ -448,7 +483,7 @@ class RotatePanel: public PicProcPanel
448483
void OnThumbTrack(wxCommandEvent& event)
449484
{
450485
thumb = true;
451-
preview->Rotate(rotate->GetValue()/10.0);
486+
preview->Rotate(rotate->GetFloatValue());
452487
event.Skip();
453488
Refresh();
454489
Update();
@@ -458,9 +493,9 @@ class RotatePanel: public PicProcPanel
458493
{
459494
preview->setAutocrop(autocrop->GetValue());
460495
if (autocrop->GetValue())
461-
q->setParams(wxString::Format("%2.1f,autocrop",rotate->GetValue()/10.0));
496+
q->setParams(wxString::Format("%2.1f,autocrop",rotate->GetFloatValue()));
462497
else
463-
q->setParams(wxString::Format("%2.1f",rotate->GetValue()/10.0));
498+
q->setParams(wxString::Format("%2.1f",rotate->GetFloatValue()));
464499
event.Skip();
465500
q->processPic();
466501
thumb = true;
@@ -469,11 +504,11 @@ class RotatePanel: public PicProcPanel
469504
void OnButton(wxCommandEvent& event)
470505
{
471506
double resetval = atof(myConfig::getConfig().getValueOrDefault("tool.rotate.initialvalue","0.0").c_str());
472-
rotate->SetValue(resetval);
507+
rotate->SetFloatValue(resetval);
473508
if (autocrop->GetValue())
474-
q->setParams(wxString::Format("%2.1f,autocrop",rotate->GetValue()/10.0));
509+
q->setParams(wxString::Format("%2.1f,autocrop",rotate->GetFloatValue()));
475510
else
476-
q->setParams(wxString::Format("%2.1f",rotate->GetValue()/10.0));
511+
q->setParams(wxString::Format("%2.1f",rotate->GetFloatValue()));
477512
preview->Rotate(0.0);
478513
Refresh();
479514
q->processPic();
@@ -484,7 +519,8 @@ class RotatePanel: public PicProcPanel
484519
private:
485520
wxCheckBox *autocrop, *enablebox;
486521
wxRadioButton *r45, *r90, *r180, *r270, *rH, *rV;
487-
rotateSlider *rotate;
522+
//rotateSlider *rotate;
523+
myFloatCtrl *rotate;
488524
wxTimer t;
489525
RotatePreview *preview;
490526
bool thumb;

0 commit comments

Comments
 (0)