From 05dd2bb703ec97e3217d0dcd3429a32af1ad6e8c Mon Sep 17 00:00:00 2001 From: K D Hedger Date: Sun, 19 Nov 2023 16:46:18 +0000 Subject: [PATCH] fixed toggle cbs etc --- LFSDock/LFSDock/src/clock.cpp | 13 ++--- LFSDock/LFSDock/src/slider.cpp | 53 ++++++++++++++++--- LFSToolKit/ChangeLog | 1 + .../LFSToolKit/lfstk/LFSTKToggleButton.cpp | 12 +++++ LFSToolKit/examples/toggle.cpp | 12 +++++ 5 files changed, 73 insertions(+), 18 deletions(-) diff --git a/LFSDock/LFSDock/src/clock.cpp b/LFSDock/LFSDock/src/clock.cpp index 05ead85..5d94bda 100644 --- a/LFSDock/LFSDock/src/clock.cpp +++ b/LFSDock/LFSDock/src/clock.cpp @@ -38,21 +38,14 @@ void updateClock(void) strftime(clockbuffer,255,"%I:%M:%S",timeinfo); clockButton->LFSTK_setLabel(clockbuffer); - //clockButton->drawLabelBG=true; - //clockButton->autoLabelBGColour=true; -// clockButton->LFSTK_clearWindow(); -//clockButton->LFSTK_setLabelBGColour(1.0,1,1.0,1.0); -// clockButton->drawLabelBG=true; -// //clockButton->autoLabelBGColour=true; -clockButton->LFSTK_clearWindow(); - XFlush(apc->display); - + clockButton->LFSTK_clearWindow(); + XFlush(apc->display); } int addClock(int x,int y,int grav) { int xpos=0; - int width=iconSize; + int width=iconSize; int retval=width; if(clockButton!=NULL) diff --git a/LFSDock/LFSDock/src/slider.cpp b/LFSDock/LFSDock/src/slider.cpp index 9ef96f7..68c51c4 100644 --- a/LFSDock/LFSDock/src/slider.cpp +++ b/LFSDock/LFSDock/src/slider.cpp @@ -35,6 +35,7 @@ char *iconL=NULL; char *iconZ=NULL; int oldVolVal=-1; char label[32]; +bool isUp=false; void setLabel(void) { @@ -161,22 +162,58 @@ void updateSlider(void)//TODO//when large icon } } +bool volExitCB(LFSTK_gadgetClass*p,void* ud) +{ + geometryStruct geom2; + int adj; + + if(volumeButton->LFSTK_getValue()==1) + return(true); + adj=extraSpace*posMultiplier; + p->LFSTK_getGeom(&geom2); + p->LFSTK_moveGadget(geom2.x,geom2.y+adj); + isUp=false; + return(true); +} + +bool volMoveCB(LFSTK_gadgetClass*p,void* ud) +{ + geometryStruct geom; + int adj; + + if(isUp==true) + return(true); + + adj=extraSpace*posMultiplier; + p->LFSTK_getGeom(&geom); + p->LFSTK_moveGadget(geom.x,geom.y-adj); + isUp=true; + return(true); +} + int addSlider(int x,int y,int grav,bool fromleft) { - int xpos=x; - int ypos=y; - int width=0; - int height=0; - int thisgrav=grav; - int iconsize=16; - char *label=mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print \"%s \" $4}'|tr -d '[]'",SLIDERLABEL); + int xpos=x; + int ypos=y; + int width=0; + int height=0; + int thisgrav=grav; + int iconsize=16; + int adj; + char *label=mainwind->globalLib->LFSTK_oneLiner("amixer get Master|tail -n1|awk '{print \"%s \" $4}'|tr -d '[]'",SLIDERLABEL); + + if(posMultiplier==-1) + adj=0; + else + adj=extraSpace; getAlsaVolume(false,-1); setSizes(&xpos,&ypos,&width,&height,&iconsize,&thisgrav,fromleft); - volumeButton=new LFSTK_toggleButtonClass(mainwind,label,xpos,ypos,iconSize,iconSize+extraSpace,thisgrav); + volumeButton=new LFSTK_toggleButtonClass(mainwind,label,xpos,ypos+adj,iconSize,iconSize,thisgrav); volumeButton->LFSTK_setToggleStyle(TOGGLENORMAL); volumeButton->LFSTK_setMouseCallBack(NULL,sliderCB,(void*)volumeButton->LFSTK_getLabel()); + volumeButton->LFSTK_setMouseMoveCallBack(volMoveCB,volExitCB,USERDATA(0)); setGadgetDetails(volumeButton); volumeButton->LFSTK_setAlpha(1.0); diff --git a/LFSToolKit/ChangeLog b/LFSToolKit/ChangeLog index 6702f3b..928a081 100644 --- a/LFSToolKit/ChangeLog +++ b/LFSToolKit/ChangeLog @@ -1,4 +1,5 @@ 0.6.0 +Fixed mouse enter/exit callbacks in toggle. Fixed segfault in image class. Removed some old 'c' code. Minor menu stack fix. diff --git a/LFSToolKit/LFSToolKit/lfstk/LFSTKToggleButton.cpp b/LFSToolKit/LFSToolKit/lfstk/LFSTKToggleButton.cpp index d207232..f15d2a4 100644 --- a/LFSToolKit/LFSToolKit/lfstk/LFSTKToggleButton.cpp +++ b/LFSToolKit/LFSToolKit/lfstk/LFSTKToggleButton.cpp @@ -99,6 +99,8 @@ LFSTK_toggleButtonClass::LFSTK_toggleButtonClass(LFSTK_windowClass* parentwc,con */ bool LFSTK_toggleButtonClass::mouseEnter(XButtonEvent *e) { + bool retval=true; + if((this->callBacks.runTheCallback==false) || (this->isActive==false)) return(true); @@ -114,6 +116,10 @@ bool LFSTK_toggleButtonClass::mouseEnter(XButtonEvent *e) } this->inWindow=true; + + if((this->callBacks.validCallbacks & MOUSEENTERCB) && (this->noRunCB==false)) + retval=this->callBacks.mouseEnterCallback(this,this->callBacks.mouseMoveUserData); + LFSTK_gadgetClass::LFSTK_clearWindow(); return(true); } @@ -125,6 +131,8 @@ bool LFSTK_toggleButtonClass::mouseEnter(XButtonEvent *e) */ bool LFSTK_toggleButtonClass::mouseExit(XButtonEvent *e) { + bool retval=true; + if((this->callBacks.runTheCallback==false) || (this->isActive==false)) return(true); @@ -144,6 +152,10 @@ bool LFSTK_toggleButtonClass::mouseExit(XButtonEvent *e) } this->inWindow=false; + + if((this->callBacks.validCallbacks & MOUSEEXITCB) && (this->noRunCB==false)) + retval=this->callBacks.mouseExitCallback(this,this->callBacks.mouseMoveUserData); + LFSTK_gadgetClass::LFSTK_clearWindow(); return(true); } diff --git a/LFSToolKit/examples/toggle.cpp b/LFSToolKit/examples/toggle.cpp index ac9f1ea..eb92af0 100755 --- a/LFSToolKit/examples/toggle.cpp +++ b/LFSToolKit/examples/toggle.cpp @@ -84,6 +84,17 @@ bool buttonCB(void *p,void* ud) return(true); } +bool enterCB(LFSTK_gadgetClass*p,void* ud) +{ + printf(">>>Mouse Enter<<<\n"); + return(true); +} + +bool exitCB(LFSTK_gadgetClass*p,void* ud) +{ + printf(">>>Mouse Exit<<<\n"); + return(true); +} int main(int argc, char **argv) { @@ -112,6 +123,7 @@ int main(int argc, char **argv) //toggle button toggle=new LFSTK_toggleButtonClass(wc,"Toggle",DIALOGMIDDLE-HALFGADGETWIDTH,sy,GADGETWIDTH,GADGETWIDTH); toggle->LFSTK_setMouseCallBack(NULL,buttonCB,(void*)toggle->LFSTK_getLabel()); + toggle->LFSTK_setMouseMoveCallBack(enterCB,exitCB,USERDATA(0)); toggle->LFSTK_setToggleStyle(TOGGLENORMAL); toggle->userData=USERDATA(1);