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);
|
void WMSetLabelText(WMLabel *lPtr, char *text);
|
||||||
|
|
||||||
|
WMFont* WMGetLabelFont(WMLabel *lPtr);
|
||||||
|
|
||||||
void WMSetLabelFont(WMLabel *lPtr, WMFont *font);
|
void WMSetLabelFont(WMLabel *lPtr, WMFont *font);
|
||||||
|
|
||||||
void WMSetLabelTextColor(WMLabel *lPtr, WMColor *color);
|
void WMSetLabelTextColor(WMLabel *lPtr, WMColor *color);
|
||||||
|
|||||||
@@ -153,6 +153,13 @@ WMSetLabelText(WMLabel *lPtr, char *text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WMFont*
|
||||||
|
WMGetLabelFont(WMLabel *lPtr)
|
||||||
|
{
|
||||||
|
return lPtr->font;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WMSetLabelFont(WMLabel *lPtr, WMFont *font)
|
WMSetLabelFont(WMLabel *lPtr, WMFont *font)
|
||||||
{
|
{
|
||||||
|
|||||||
53
src/dialog.c
53
src/dialog.c
@@ -782,6 +782,7 @@ typedef struct {
|
|||||||
RImage *icon;
|
RImage *icon;
|
||||||
RImage *pic;
|
RImage *pic;
|
||||||
WMPixmap *oldPix;
|
WMPixmap *oldPix;
|
||||||
|
WMFont *oldFont;
|
||||||
char *str;
|
char *str;
|
||||||
int x;
|
int x;
|
||||||
#endif
|
#endif
|
||||||
@@ -884,6 +885,7 @@ logoPushCallback(void *data)
|
|||||||
InfoPanel *panel = (InfoPanel*)data;
|
InfoPanel *panel = (InfoPanel*)data;
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
int i;
|
int i;
|
||||||
|
static int oldi = 0;
|
||||||
int len;
|
int len;
|
||||||
static int jingobeu[] = {
|
static int jingobeu[] = {
|
||||||
329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
|
329, 150, -1, 100, 329, 150, -1, 100, 329, 300, -1, 250,
|
||||||
@@ -920,19 +922,27 @@ XChangeKeyboardControl(dpy,KBBellPitch|KBBellDuration|KBBellPercent,&kc);
|
|||||||
WMReleasePixmap(pix);
|
WMReleasePixmap(pix);
|
||||||
}
|
}
|
||||||
|
|
||||||
i = panel->cycle%200;
|
/* slow down text a little */
|
||||||
|
i = (int)(panel->cycle * 50.0/85.0)%200;
|
||||||
|
|
||||||
len = strlen(panel->str);
|
if (i != oldi) {
|
||||||
|
len = strlen(panel->str);
|
||||||
|
|
||||||
strncpy(buffer, panel->str, i<len ? i : len);
|
strncpy(buffer, panel->str, i<len ? i : len);
|
||||||
if (i >= len)
|
if (i >= len)
|
||||||
memset(&buffer[len], ' ', i-len);
|
memset(&buffer[len], ' ', i-len);
|
||||||
|
|
||||||
strncpy(buffer, panel->str, i<len ? i : len);
|
strncpy(buffer, panel->str, i<len ? i : len);
|
||||||
if (i >= len)
|
if (i >= len)
|
||||||
memset(&buffer[len], ' ', i-len);
|
memset(&buffer[len], ' ', i-len);
|
||||||
buffer[i]=0;
|
buffer[i]=0;
|
||||||
WMSetLabelText(panel->versionL, buffer);
|
|
||||||
|
WMSetLabelText(panel->versionL, buffer);
|
||||||
|
|
||||||
|
XFlush(WMScreenDisplay(WMWidgetScreen(panel->versionL)));
|
||||||
|
|
||||||
|
oldi = i;
|
||||||
|
}
|
||||||
|
|
||||||
panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
|
panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
|
||||||
panel->cycle++;
|
panel->cycle++;
|
||||||
@@ -1062,7 +1072,8 @@ handleLogoPush(XEvent *event, void *data)
|
|||||||
clicks++;
|
clicks++;
|
||||||
|
|
||||||
if (!panel->timer && !broken && clicks > 0) {
|
if (!panel->timer && !broken && clicks > 0) {
|
||||||
char *file;
|
WMFont *font;
|
||||||
|
char *file;
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
panel->x = 0;
|
panel->x = 0;
|
||||||
@@ -1116,7 +1127,17 @@ handleLogoPush(XEvent *event, void *data)
|
|||||||
|
|
||||||
panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
|
panel->timer = WMAddTimerHandler(50, logoPushCallback, panel);
|
||||||
panel->cycle = 0;
|
panel->cycle = 0;
|
||||||
panel->oldPix = WMRetainPixmap(WMGetLabelImage(panel->logoL));
|
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) {
|
} else if (panel->timer) {
|
||||||
char version[20];
|
char version[20];
|
||||||
|
|
||||||
@@ -1129,8 +1150,14 @@ handleLogoPush(XEvent *event, void *data)
|
|||||||
WMDeleteTimerHandler(panel->timer);
|
WMDeleteTimerHandler(panel->timer);
|
||||||
panel->timer = NULL;
|
panel->timer = NULL;
|
||||||
|
|
||||||
|
WMSetLabelFont(panel->versionL, panel->oldFont);
|
||||||
|
if (panel->oldFont) {
|
||||||
|
WMReleaseFont(panel->oldFont);
|
||||||
|
panel->oldFont = NULL;
|
||||||
|
}
|
||||||
sprintf(version, _("Version %s"), VERSION);
|
sprintf(version, _("Version %s"), VERSION);
|
||||||
WMSetLabelText(panel->versionL, version);
|
WMSetLabelText(panel->versionL, version);
|
||||||
|
XFlush(WMScreenDisplay(WMWidgetScreen(panel->versionL)));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user