summaryrefslogtreecommitdiff
path: root/app/bin/chotbar.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-19 19:55:58 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-19 19:55:58 +0100
commitd1a8285f818eb7e5c3d6a05709ea21a808490b8c (patch)
tree326578f0505cbed07cfe60de530022822dc237ac /app/bin/chotbar.c
parent16e9630b79f0a7a90c6cedb6781175bb8b337dc1 (diff)
New upstream version 5.1.0upstream/5.1.0
Diffstat (limited to 'app/bin/chotbar.c')
-rw-r--r--app/bin/chotbar.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/app/bin/chotbar.c b/app/bin/chotbar.c
index f138cbb..188ad27 100644
--- a/app/bin/chotbar.c
+++ b/app/bin/chotbar.c
@@ -21,10 +21,13 @@
*/
#include <ctype.h>
-#include "track.h"
-#include "compound.h"
-
#include <stdint.h>
+#include <string.h>
+
+#include "compound.h"
+#include "fileio.h"
+#include "messages.h"
+#include "track.h"
EXPORT DIST_T curBarScale = -1;
EXPORT long hotBarLabels = 0;
@@ -73,7 +76,7 @@ static void HotBarHighlight( int inx )
{
wPos_t x0;
if ( inx >= hotBarCurrStart && inx < hotBarCurrEnd ) {
- x0 = (wPos_t)((hotBarMap(inx).x-hotBarMap((int)hotBarCurrStart).x)*hotBarD.dpi+2);
+ x0 = (wPos_t)((hotBarMap(inx).x-hotBarMap((int)hotBarCurrStart).x)*hotBarD.dpi);
wDrawFilledRectangle( hotBarD.d, x0, 0, (wPos_t)(hotBarMap(inx).w*hotBarD.dpi-2), hotBarHeight, wDrawColorBlack, wDrawOptTemp );
}
}
@@ -101,30 +104,32 @@ static void RedrawHotBar( wDraw_p dd, void * data, wPos_t w, wPos_t h )
}
if ( hotBarLabels && !hotBarFp )
hotBarFp = wStandardFont( F_HELV, FALSE, FALSE );
+ wPos_t textSize = wMessageGetHeight(0L);
for ( inx=hotBarCurrStart; inx < hotBarMap_da.cnt; inx++ ) {
tbm = &hotBarMap(inx);
barScale = tbm->barScale;
- x = tbm->x - hotBarMap(hotBarCurrStart).x + 2.0/hotBarD.dpi;
+ x = tbm->x - hotBarMap(hotBarCurrStart).x;
if ( x + tbm->w > barWidth ) {
break;
}
orig.y = hh/2.0*barScale - tbm->size.y/2.0 - tbm->orig.y;
if ( hotBarLabels ) {
- orig.y += 8/hotBarD.dpi*barScale;
+ orig.y += textSize/hotBarD.dpi*barScale;
if ( tbm->labelW > tbm->objectW ) {
x += (tbm->labelW-tbm->objectW)/2;
}
}
x *= barScale;
- orig.x = x - tbm->orig.x;
+ orig.x = x;
hotBarD.scale = barScale;
hotBarD.size.x = barWidth*barScale;
hotBarD.size.y = barHeight*barScale;
tbm->proc( HB_DRAW, tbm->context, &hotBarD, &orig );
if ( hotBarLabels ) {
- orig.x = x - (tbm->labelW-tbm->objectW)/2*barScale;
- orig.y = 2*barScale/hotBarD.dpi;
- DrawString( &hotBarD, orig, 0.0, tbm->proc( HB_BARTITLE, tbm->context, NULL, NULL ), hotBarFp, hotBarFs*barScale, drawColorBlack );
+ hotBarD.scale = 1.0;
+ orig.x = tbm->x - hotBarMap(hotBarCurrStart).x;
+ orig.y = 2.0/hotBarD.dpi; //Draw Label under icon
+ DrawString( &hotBarD, orig, 0.0, tbm->proc( HB_BARTITLE, tbm->context, NULL, NULL ), hotBarFp, hotBarFs, drawColorBlack );
}
}
hotBarCurrEnd = inx;
@@ -220,7 +225,8 @@ static void SelectHotBar( wDraw_p d, void * context, wAction_t action, wPos_t w,
}
x = w/hotBarD.dpi + hotBarMap(hotBarCurrStart).x;
for ( inx=hotBarCurrStart; inx<hotBarCurrEnd; inx++ ) {
- if ( x < hotBarMap(inx).x + hotBarMap(inx).w ) {
+ if ((x >= hotBarMap(inx).x) && //leave spaces between buttons
+ (x <= hotBarMap(inx).x + hotBarMap(inx).w )) {
break;
}
}
@@ -231,7 +237,7 @@ static void SelectHotBar( wDraw_p d, void * context, wAction_t action, wPos_t w,
px += (wPos_t)(tbm->w*hotBarD.dpi/2);
titleP = tbm->proc( HB_LISTTITLE, tbm->context, NULL, NULL );
px -= wLabelWidth( titleP ) / 2;
- wControlSetBalloon( (wControl_p)hotBarD.d, px, -5, titleP );
+ wControlSetBalloon( (wControl_p)hotBarD.d, px, -20, titleP );
switch (action & 0xff) {
case wActionLDown:
pos.x = mainD.size.x+mainD.orig.x;
@@ -380,7 +386,7 @@ EXPORT void AddHotBarElement(
tbm->w = tbm->labelW;
}
}
- hotBarWidth += tbm->w;
+ hotBarWidth += tbm->w + 2/hotBarD.dpi;
}
@@ -440,8 +446,9 @@ EXPORT void LayoutHotBar( void )
wWinGetSize( mainW, &winWidth, &winHeight );
hotBarHeight = hotBarDrawHeight;
- if ( hotBarLabels)
- hotBarHeight += 8;
+ if ( hotBarLabels) {
+ hotBarHeight += wMessageGetHeight(0L);
+ }
if (hotBarLeftB == NULL) {
wIcon_p bm_p;
if (winWidth < 50)
@@ -450,18 +457,18 @@ EXPORT void LayoutHotBar( void )
hotBarLeftB = wButtonCreate( mainW, 0, 0, "hotBarLeft", (char*)bm_p, BO_ICON, 0, DoHotBarLeft, NULL );
bm_p = wIconCreateBitMap( 16, 16, turnbarr_bits, wDrawColorBlack );
hotBarRightB = wButtonCreate( mainW, 0, 0, "hotBarRight", (char*)bm_p, BO_ICON, 0, DoHotBarRight, NULL );
- hotBarD.d = wDrawCreate( mainW, 0, 0, NULL, BD_NOCAPTURE, 100, hotBarHeight, NULL, RedrawHotBar, SelectHotBar );
+ hotBarD.d = wDrawCreate( mainW, 0, 0, NULL, BD_NOCAPTURE|BD_NOFOCUS, 100, hotBarHeight, NULL, RedrawHotBar, SelectHotBar );
hotBarD.dpi = wDrawGetDPI( hotBarD.d );
hotBarD.scale = 1.0;
initialize = TRUE;
}
buttonWidth = wControlGetWidth((wControl_p)hotBarLeftB);
wControlSetPos( (wControl_p)hotBarLeftB, 0, toolbarHeight );
- wControlSetPos( (wControl_p)hotBarRightB, winWidth-buttonWidth, toolbarHeight );
+ wControlSetPos( (wControl_p)hotBarRightB, winWidth-20-buttonWidth, toolbarHeight );
wControlSetPos( (wControl_p)hotBarD.d, buttonWidth, toolbarHeight );
- wDrawSetSize( hotBarD.d, winWidth-buttonWidth*2, hotBarHeight+2 );
- hotBarD.size.x = ((double)(winWidth-buttonWidth*2))/hotBarD.dpi*hotBarD.scale;
- hotBarD.size.y = (double)hotBarHeight/hotBarD.dpi*hotBarD.scale;
+ wDrawSetSize( hotBarD.d, winWidth-20-buttonWidth*2, hotBarHeight+2 );
+ hotBarD.size.x = ((double)(winWidth-20-buttonWidth*2))/hotBarD.dpi*hotBarD.scale;
+ hotBarD.size.y = (double)hotBarDrawHeight/hotBarD.dpi*hotBarD.scale; //Exclude Label from calc
wControlShow( (wControl_p)hotBarLeftB, TRUE );
wControlShow( (wControl_p)hotBarRightB, TRUE );
wControlShow( (wControl_p)hotBarD.d, TRUE );