Skip to content

Commit

Permalink
Merge pull request #96 from abhra0897/master
Browse files Browse the repository at this point in the history
BUGFIX: vol slider tooltip disappearing
  • Loading branch information
rexim authored Mar 2, 2024
2 parents da2dbc1 + 91fdb59 commit 366fe92
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,9 @@ static void end_tooltip_frame(void)
DrawTextEx(p->font, p->tooltip_buffer, position, fontSize, spacing, COLOR_TOOLTIP_FOREGROUND);
}

static void tooltip(Rectangle boundary, const char *text, Side align)
static void tooltip(Rectangle boundary, const char *text, Side align, bool persists)
{
if (!CheckCollisionPointRec(GetMousePosition(), boundary)) return;
if (!(CheckCollisionPointRec(GetMousePosition(), boundary) || persists)) return;
p->tooltip_show = true;
// TODO: this may not work properly if text contains UTF-8
snprintf(p->tooltip_buffer, sizeof(p->tooltip_buffer), "%s", text);
Expand Down Expand Up @@ -922,9 +922,9 @@ static int fullscreen_button_with_loc(const char *file, int line, Rectangle full
DrawTexturePro(assets_texture("./resources/icons/fullscreen.png"), source, dest, CLITERAL(Vector2){0}, 0, ColorBrightness(WHITE, -0.10));

if (p->fullscreen) {
tooltip(fullscreen_button_boundary, "Collapse [F]", SIDE_TOP);
tooltip(fullscreen_button_boundary, "Collapse [F]", SIDE_TOP, false);
} else {
tooltip(fullscreen_button_boundary, "Expand [F]", SIDE_TOP);
tooltip(fullscreen_button_boundary, "Expand [F]", SIDE_TOP, false);
}

return state;
Expand Down Expand Up @@ -1057,8 +1057,7 @@ static bool volume_slider_with_location(const char *file, int line, Rectangle vo
if (volume > 1) volume = 1;
SetMasterVolume(volume);

// TODO: if while dragging the volume slider you hoverout of it, the tooltip disappears
tooltip(slider_boundary, TextFormat("Volume %d%%", (int)floorf(volume*100.0f)), SIDE_TOP);
tooltip(slider_boundary, TextFormat("Volume %d%%", (int)floorf(volume*100.0f)), SIDE_TOP, dragging);
}

// Toggle mute
Expand All @@ -1082,9 +1081,9 @@ static bool volume_slider_with_location(const char *file, int line, Rectangle vo
}

if (volume <= 0.0) {
tooltip(volume_icon_boundary, "Unmute [M]", SIDE_TOP);
tooltip(volume_icon_boundary, "Unmute [M]", SIDE_TOP, false);
} else {
tooltip(volume_icon_boundary, "Mute [M]", SIDE_TOP);
tooltip(volume_icon_boundary, "Mute [M]", SIDE_TOP, false);
}

return dragging || updated;
Expand Down Expand Up @@ -1158,9 +1157,9 @@ static int play_button_with_location(const char *file, int line, Track *track, R
DrawTexturePro(assets_texture("./resources/icons/play.png"), source, dest, CLITERAL(Vector2){0}, 0, ColorBrightness(WHITE, -0.10));

if (IsMusicStreamPlaying(track->music)) {
tooltip(boundary, "Pause [SPACE]", SIDE_TOP);
tooltip(boundary, "Pause [SPACE]", SIDE_TOP, false);
} else {
tooltip(boundary, "Play [SPACE]", SIDE_TOP);
tooltip(boundary, "Play [SPACE]", SIDE_TOP, false);
}

return state;
Expand Down Expand Up @@ -1189,7 +1188,7 @@ static int render_button_with_location(const char *file, int line, Rectangle bou
Rectangle source = {icon_size*icon_index, 0, icon_size, icon_size};
DrawTexturePro(assets_texture("./resources/icons/render.png"), source, dest, CLITERAL(Vector2){0}, 0, ColorBrightness(WHITE, -0.10));

tooltip(boundary, "Render [R]", SIDE_TOP);
tooltip(boundary, "Render [R]", SIDE_TOP, false);

return state;
}
Expand Down

0 comments on commit 366fe92

Please sign in to comment.