Skip to content

Commit

Permalink
significant performance-fix for realtime sliders
Browse files Browse the repository at this point in the history
  • Loading branch information
coderofsalvation committed Nov 28, 2024
1 parent 750f400 commit ffb9c7c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
45 changes: 27 additions & 18 deletions src/tracker/DialogSliders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ DialogSliders::DialogSliders(PPScreen *parentScreen, DialogResponder *toolHandle
{
needUpdate = false;
preview = false;
clicked = false;
valueChanged = false;
numSliders = sliders;
responder = toolHandlerResponder;
screen = parentScreen;
Expand Down Expand Up @@ -107,24 +109,31 @@ pp_int32 DialogSliders::handleEvent(PPObject* sender, PPEvent* event)
{
char v[255];
pp_uint32 id = reinterpret_cast<PPControl*>(sender)->getID();
if( id >= MESSAGEBOX_CONTROL_USER1 && id <= MESSAGEBOX_CONTROL_USER1+numSliders ){
pp_uint32 slider = id-MESSAGEBOX_CONTROL_USER1;
float val = getSlider( slider );
sprintf(v,"%i",(int)val);
listBoxes[slider]->updateItem( 0, PPString(v) );
listBoxes[slider]->commitChanges();
update();
needUpdate = true;
}else if( event->getID() == eCommand && id == PP_MESSAGEBOX_BUTTON_CANCEL ){
sampleEditor->undo();
}
if( event->getID() == eLMouseUp ){
needUpdate = true;
}
if( needUpdate ){
process();
update();
}
pp_uint32 eID = event->getID();

// state management needed (because +/- buttons reflect change after emitting mouseup)
if( eID == eLMouseUp ) clicked = true;
if( eID == eValueChanged ) valueChanged = true;

if( id >= MESSAGEBOX_CONTROL_USER1 && id <= MESSAGEBOX_CONTROL_USER1+numSliders ){
pp_uint32 slider = id-MESSAGEBOX_CONTROL_USER1;
float val = getSlider( slider );
sprintf(v,"%i",(int)val);
listBoxes[slider]->updateItem( 0, PPString(v) );
listBoxes[slider]->commitChanges();
needUpdate = true;
}
if( eID == eCommand && id == PP_MESSAGEBOX_BUTTON_CANCEL ){
sampleEditor->undo();
update();
}else{
if( clicked && valueChanged ){
process();
clicked = false;
valueChanged = false;
}
}
if( needUpdate ) update();
return PPDialogBase::handleEvent(sender, event);
}

Expand Down
2 changes: 2 additions & 0 deletions src/tracker/DialogSliders.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class DialogSliders : public PPDialogBase

bool needUpdate;
bool preview;
bool valueChanged;
bool clicked;

virtual pp_int32 handleEvent(PPObject* sender, PPEvent* event);

Expand Down

0 comments on commit ffb9c7c

Please sign in to comment.