Skip to content

Commit

Permalink
improvments to dock etc, see change logs
Browse files Browse the repository at this point in the history
  • Loading branch information
KeithDHedger committed Apr 23, 2024
1 parent c913bee commit e4fe5fa
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 20 deletions.
1 change: 1 addition & 0 deletions LFSDock/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
0.2.0
Added use end caps ( optional ) when setting BG image.
Better display of transparent BG image.
Added optional background image to dock.
Fixed finding desktop files.
Expand Down
10 changes: 8 additions & 2 deletions LFSDock/LFSDock/src/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ int dockGravity=PANELSOUTH;
std::string dockTextColour="";
std::string dockBGColour="";
std::string dockBGImage="";
std::string dockBGImageLS="";
std::string dockBGImageRS="";
bool useBG=false;

int queueID;
Expand All @@ -61,6 +63,10 @@ LFSTK_listGadgetClass *popActionList=NULL;
bool inSomeWindow=false;
bool gotLaunchers=false;
int popActionWindowYOffset=1;
LFSTK_buttonClass *bgrs=NULL;
LFSTK_buttonClass *bgls=NULL;
int sidewid=0;
int sidehite=0;

//atoms
Atom WM_STATE=None;
Expand Down Expand Up @@ -330,8 +336,8 @@ void resizeDock(int wid,int hite)
{
dockWindow->LFSTK_resizeWindow(wid,hite,true);
dockBGWindow->LFSTK_resizeWindow(wid,hite,true);
//dockBGWindow->LFSTK_clearWindow(true);
//dockWindow->LFSTK_clearWindow(true);
if(bgrs!=NULL)
bgrs->LFSTK_moveGadget(wid-sidewid,0);
}

void moveDock(int extra)
Expand Down
6 changes: 6 additions & 0 deletions LFSDock/LFSDock/src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ extern int dockGravity;
extern std::string dockTextColour;
extern std::string dockBGColour;
extern std::string dockBGImage;
extern std::string dockBGImageLS;
extern std::string dockBGImageRS;
extern bool useBG;

extern int queueID;
Expand All @@ -112,6 +114,10 @@ extern LFSTK_windowClass *popActionWindow;
extern LFSTK_listGadgetClass *popActionList;
extern bool inSomeWindow;
extern int popActionWindowYOffset;
extern LFSTK_buttonClass *bgrs;
extern LFSTK_buttonClass *bgls;
extern int sidewid;
extern int sidehite;

//atoms
extern Atom WM_STATE;
Expand Down
52 changes: 41 additions & 11 deletions LFSDock/LFSDock/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ int main(int argc,char **argv)
win->windowType=apc->appAtomsHashed.at(LFSTK_UtilityClass::LFSTK_hashFromKey("_NET_WM_WINDOW_TYPE_DOCK"));
win->level=ABOVEALL;
win->decorated=false;
apc->LFSTK_addWindow(win,"DOCK");
//win->className="LFSDOCK";
apc->LFSTK_addWindow(win,"LFSDock");

dockWindow=apc->mainWindow;
dockWindow->LFSTK_initDnD(true);
Expand Down Expand Up @@ -323,24 +324,53 @@ int main(int argc,char **argv)
dockBGWindow=apc->windows->back().window;
apc->windows->back().showing=true;
dockBGWindow->LFSTK_setTile(dockBGImage.c_str(),-1);
//dockBGWindow->LFSTK_setWindowPixmap(apc->globalLib->LFSTK_getWindowPixmap(apc->display,apc->rootWindow),10000,24);

moveDock(0);
resizeDock(psize,iconWidth+extraSpace);

//max hite for end caps should be 120

if(useBG==true)
{
//dockWindow->LFSTK_setTile(dockBGImage.c_str(),-1);
cairo_status_t st;
cairo_surface_t *tsfc;
std::string suffix=LFSTK_UtilityClass::LFSTK_deleteSuffix(&dockBGImage);

dockBGImageLS=dockBGImage+"-ls."+suffix;
dockBGImageRS=dockBGImage+"-rs."+suffix;
dockBGWindow->LFSTK_showWindow(true);
//dockBGWindow->LFSTK_setKeepAbove(true);
//dockWindow->LFSTK_setKeepAbove(true);
}
//else
// dockWindow->LFSTK_setTile(NULL,0);

//dockWindow->LFSTK_showWindow(true);
//dockWindow->LFSTK_setKeepAbove(true);
//dockBGWindow->LFSTK_setKeepAbove(true);
tsfc=apc->globalLib->LFSTK_lib::LFSTK_createSurfaceFromPath(dockBGImageLS.c_str());
if(tsfc!=NULL)
{
//fprintf(stderr,"dock hite=%i\n",iconWidth+extraSpace);
//fprintf(stderr,"sfc=%p\n",tsfc);
//fprintf(stderr,"hite===%i\n",cairo_image_surface_get_height(tsfc));
//fprintf(stderr,"wid===%i\n",cairo_image_surface_get_width(tsfc));
sidehite=cairo_image_surface_get_height(tsfc);
sidewid=cairo_image_surface_get_width(tsfc);
cairo_surface_destroy (tsfc);

bgls=new LFSTK_buttonClass(dockBGWindow,"",0,0,sidewid,sidehite);
setGadgetDetails(bgls);
st=bgls->LFSTK_setImageFromPath(dockBGImageLS,LEFT,false);
if(st!=CAIRO_STATUS_SUCCESS)
{
dockBGWindow->LFSTK_deleteGadget(bgls);
bgls=NULL;
}

bgrs=new LFSTK_buttonClass(dockBGWindow,"",psize-sidewid,0,sidewid,sidehite,NorthWestGravity);
setGadgetDetails(bgrs);
st=bgrs->LFSTK_setImageFromPath(dockBGImageRS,RIGHT,false);
if(st!=CAIRO_STATUS_SUCCESS)
{
dockBGWindow->LFSTK_deleteGadget(bgrs);
bgrs=NULL;
}
}

}

if(useTaskBar==true)
updateTaskBar(true);
Expand Down
10 changes: 8 additions & 2 deletions LFSDock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ where month is between 0 - 11 ( 0=January, 11=December ), date is 1- however man
The calendar and slider gadgets are toggles and so need to be clicked on to make the appropriate window appear/disappear.<br>
Gadgets can be in any order you wish.<br>
<br>
If you set a backround image, it will be tiled over the width of the window and should be at least double the height of the dock, this is a hack for now and will be fixed later.<br>
Transparencies are not yet working in the BG image.<br>
If you set a backround image, it will be tiled over the window<br>
<PNG's should be used if you want to use end caps<br>
End caps can be optionally set and fshould be in the same folder and be the same format as the main tile image with the filenames being for instance:<br>
/home/keithhedger/Backgrounds/rage.png << main tile, only this path needs be set in the config file ( plaease use the lfsdockprefs app ).<br>
/home/keithhedger/Backgrounds/rage-ls.png << left end cap.<br>
/home/keithhedger/Backgrounds/rage-rs.png <<right end cap.<br>
Images can be (semi-)transparent.<br>
The main tile can be any size but the end caps height shoud be at least 120, the width can be any size>=1.<br>
<br>
More gadgets to come and improvements to the graphics.<br>
The dock looks best with a transparent background at the bottom.<br>
Expand Down
1 change: 1 addition & 0 deletions LFSToolKit/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
0.6.1
Added some extras functions to LFSTK_UtilityClass.
Vairous build files tweaks.
Added mouse enter/exit call backs to image class.
Fixed cairo surface sizes.
Expand Down
1 change: 1 addition & 0 deletions LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ void LFSTK_gadgetClass::drawImage()

cairo_save(this->cr);
cairo_reset_clip (this->cr);
//if((xoffset!=0) && (yoffset!=0))
cairo_translate(this->cr,xoffset,yoffset);
cairo_set_source_surface(this->cr,this->cImage,0,0);
cairo_set_operator(this->cr,CAIRO_OPERATOR_OVER);
Expand Down
2 changes: 1 addition & 1 deletion LFSToolKit/LFSToolKit/lfstk/LFSTKGadget.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class LFSTK_gadgetClass
cairo_t *cr=NULL;
cairo_surface_t *sfc=NULL;
cairo_pattern_t *pattern=NULL;
unsigned pad;

private:
void initGadget(void);
Expand All @@ -196,7 +197,6 @@ class LFSTK_gadgetClass
void drawIndicator(gadgetStruct* details);
bevelType getActiveBevel(void);

unsigned pad;
geometryStruct gadgetGeom;

//font and label stuff
Expand Down
2 changes: 1 addition & 1 deletion LFSToolKit/LFSToolKit/lfstk/LFSTKLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ cairo_surface_t *LFSTK_lib::LFSTK_createSurfaceFromPath(const char *path)
{
cairo_status_t cs=CAIRO_STATUS_SUCCESS;
cairo_surface_t *tempimage=NULL;
char *suffix=NULL;
char *suffix=NULL;

if(path==NULL)
tempimage=NULL;
Expand Down
27 changes: 27 additions & 0 deletions LFSToolKit/LFSToolKit/lfstk/LFSTKUtilityClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,33 @@ bool LFSTK_UtilityClass::LFSTK_hasSuffix(std::string haystack,std::string suffix
return(false);
}

/**
* Get suffix of string, and return suffix.
* \param std::string str haystack.
* \return std::string suffix.
*/
std::string LFSTK_UtilityClass::LFSTK_getSuffix(std::string haystack)
{
std::string::size_type found=haystack.find_last_of(".");
return(haystack.substr(found+1));
}

/**
* Delete suffix of string, and return suffix.
* \param std::string str &haystack.
* \return std::string suffix.
*/
std::string LFSTK_UtilityClass::LFSTK_deleteSuffix(std::string *haystack)
{
std::string suffix="";

std::string::size_type found=haystack->find_last_of(".");

suffix=haystack->substr(found+1);
haystack->erase(found,std::string::npos);
return(suffix);
}

/**
* Read desktop file into std::map<unsigned long,std::vector<std::string>>
* \param std::string filepath.
Expand Down
2 changes: 2 additions & 0 deletions LFSToolKit/LFSToolKit/lfstk/LFSTKUtilityClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class LFSTK_UtilityClass
static std::vector<std::string> LFSTK_strTok(std::string str,std::string delimiter);
static std::string LFSTK_strStr(std::string haystack,std::string needle,bool caseinsensitive=false);
static bool LFSTK_hasSuffix(std::string haystack,std::string suffix);
static std::string LFSTK_getSuffix(std::string haystack);
static std::string LFSTK_deleteSuffix(std::string *haystack);
static std::string LFSTK_strStrip(std::string haystack,std::string whitespace="\t \r\n");
static std::string LFSTK_strReplaceAllStr(std::string haystack,std::string needle,std::string newneedle,bool erase=false);
static std::string LFSTK_strReplaceAllChar(std::string haystack,std::string needle,std::string newneedle,bool erase=false);
Expand Down
2 changes: 1 addition & 1 deletion LFSToolKit/examples/RunExamples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi

(
cd ..
make ${MAKEFLAGS:--j4}
make ${MAKEFLAGS:--j4} --output-sync
)

APPNAME=$(basename $0 .cpp)
Expand Down
9 changes: 7 additions & 2 deletions LFSToolKit/examples/geticonpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ bool getPath(void *p,void* ud)
iconpath=apc->globalLib->LFSTK_findThemedIcon(apc->iconThemeName,mimeEdit->LFSTK_getBuffer(),"");
if(iconpath.length()>1)
{
printf("iconpath=%s\n",iconpath.c_str());
printf("Icon Path=%s\n",iconpath.c_str());
std::cout<<"Suffix for icon path="<<LFSTK_UtilityClass::LFSTK_getSuffix(iconpath.c_str())<<std::endl;
LFSTK_UtilityClass::LFSTK_deleteSuffix(&iconpath);
std::cout<<"Path no suffix="<<iconpath<<std::endl;
}
else
printf("No icon found for '%s' in '%s'\n",mimeEdit->LFSTK_getCStr(),fileInfoEdit->LFSTK_getCStr());
Expand All @@ -59,8 +62,10 @@ bool getPath(void *p,void* ud)
if(fileinfo.isValid==true)
{
std::cout<<"Info for file "<<fileInfoEdit->LFSTK_getCStr()<<":"<<std::endl;
std::cout<<"Suffix for file="<<LFSTK_UtilityClass::LFSTK_getSuffix(fileInfoEdit->LFSTK_getBuffer())<<std::endl;
std::cout<<"Mimetype="<<fileinfo.mimeType<<std::endl;
std::cout<<"Icon file="<<fileinfo.iconPath<<std::endl;
std::cout<<"Suffix for Icon file="<<LFSTK_UtilityClass::LFSTK_getSuffix(fileinfo.iconPath)<<std::endl;
std::cout<<"Icon theme="<<fileinfo.themeName<<std::endl;
std::cout<<"File size="<<fileinfo.fileSize<<std::endl;
std::cout<<"isLink="<<fileinfo.isLink<<std::endl;
Expand Down Expand Up @@ -99,7 +104,7 @@ int main(int argc, char **argv)
label=new LFSTK_labelClass(wc,"File Information For",BORDER,sy,DIALOGWIDTH-BORDER-BORDER,GADGETHITE);
label->LFSTK_setCairoFontDataParts("B");
sy+=GADGETHITE;
fileInfoEdit=new LFSTK_lineEditClass(wc,"index.html",BORDER,sy,DIALOGWIDTH-BORDER-BORDER,GADGETHITE,BUTTONGRAV);
fileInfoEdit=new LFSTK_lineEditClass(wc,"geticonpath.cpp",BORDER,sy,DIALOGWIDTH-BORDER-BORDER,GADGETHITE,BUTTONGRAV);
sy+=YSPACING;

//get path to icon
Expand Down

0 comments on commit e4fe5fa

Please sign in to comment.