mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
- Made scrolling of text in dialog panel smoother
- Added WMGetPanelFont()
This commit is contained in:
@@ -1037,6 +1037,8 @@ void WMSetLabelRelief(WMLabel *lPtr, WMReliefType relief);
|
||||
|
||||
void WMSetLabelText(WMLabel *lPtr, char *text);
|
||||
|
||||
WMFont* WMGetLabelFont(WMLabel *lPtr);
|
||||
|
||||
void WMSetLabelFont(WMLabel *lPtr, WMFont *font);
|
||||
|
||||
void WMSetLabelTextColor(WMLabel *lPtr, WMColor *color);
|
||||
|
||||
@@ -153,6 +153,13 @@ WMSetLabelText(WMLabel *lPtr, char *text)
|
||||
}
|
||||
|
||||
|
||||
WMFont*
|
||||
WMGetLabelFont(WMLabel *lPtr)
|
||||
{
|
||||
return lPtr->font;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
WMSetLabelFont(WMLabel *lPtr, WMFont *font)
|
||||
{
|
||||
|
||||
29
src/dialog.c
29
src/dialog.c
@@ -782,6 +782,7 @@ typedef struct {
|
||||
RImage *icon;
|
||||
RImage *pic;
|
||||
WMPixmap *oldPix;
|
||||
WMFont *oldFont;
|
||||
char *str;
|
||||
int x;
|
||||
#endif
|
||||
@@ -884,6 +885,7 @@ logoPushCallback(void *data)
|
||||
InfoPanel *panel = (InfoPanel*)data;
|
||||
char buffer[512];
|
||||
int i;
|
||||
static int oldi = 0;
|
||||
int len;
|
||||
static int jingobeu[] = {
|
||||
329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
|
||||
@@ -920,8 +922,10 @@ XChangeKeyboardControl(dpy,KBBellPitch|KBBellDuration|KBBellPercent,&kc);
|
||||
WMReleasePixmap(pix);
|
||||
}
|
||||
|
||||
i = panel->cycle%200;
|
||||
/* slow down text a little */
|
||||
i = (int)(panel->cycle * 50.0/85.0)%200;
|
||||
|
||||
if (i != oldi) {
|
||||
len = strlen(panel->str);
|
||||
|
||||
strncpy(buffer, panel->str, i<len ? i : len);
|
||||
@@ -932,8 +936,14 @@ XChangeKeyboardControl(dpy,KBBellPitch|KBBellDuration|KBBellPercent,&kc);
|
||||
if (i >= len)
|
||||
memset(&buffer[len], ' ', i-len);
|
||||
buffer[i]=0;
|
||||
|
||||
WMSetLabelText(panel->versionL, buffer);
|
||||
|
||||
XFlush(WMScreenDisplay(WMWidgetScreen(panel->versionL)));
|
||||
|
||||
oldi = i;
|
||||
}
|
||||
|
||||
panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
|
||||
panel->cycle++;
|
||||
}
|
||||
@@ -1062,6 +1072,7 @@ handleLogoPush(XEvent *event, void *data)
|
||||
clicks++;
|
||||
|
||||
if (!panel->timer && !broken && clicks > 0) {
|
||||
WMFont *font;
|
||||
char *file;
|
||||
char *path;
|
||||
|
||||
@@ -1117,6 +1128,16 @@ handleLogoPush(XEvent *event, void *data)
|
||||
panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
|
||||
panel->cycle = 0;
|
||||
panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL));
|
||||
/* If we don't use a fixed font, scrolling will be jumpy */
|
||||
/* Alternatively we can draw text in a pixmap and scroll it smoothly */
|
||||
if ((panel->oldFont = WMGetLabelFont(panel->versionL))!=NULL)
|
||||
WMRetainFont(panel->oldFont);
|
||||
font = WMCreateFont(WMWidgetScreen(panel->versionL), "-*-fixed-*-*-*-*-14-*-*-*-*-*-*-*");
|
||||
if (font) {
|
||||
WMSetLabelFont(panel->versionL, font);
|
||||
WMReleaseFont(font);
|
||||
}
|
||||
WMSetLabelText(panel->versionL, "");
|
||||
} else if (panel->timer) {
|
||||
char version[20];
|
||||
|
||||
@@ -1129,8 +1150,14 @@ handleLogoPush(XEvent *event, void *data)
|
||||
WMDeleteTimerHandler(panel->timer);
|
||||
panel->timer = NULL;
|
||||
|
||||
WMSetLabelFont(panel->versionL, panel->oldFont);
|
||||
if (panel->oldFont) {
|
||||
WMReleaseFont(panel->oldFont);
|
||||
panel->oldFont = NULL;
|
||||
}
|
||||
sprintf(version, _("Version %s"), VERSION);
|
||||
WMSetLabelText(panel->versionL, version);
|
||||
XFlush(WMScreenDisplay(WMWidgetScreen(panel->versionL)));
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user