Skip to content

Commit

Permalink
Better handling of resizing:
Browse files Browse the repository at this point in the history
 - Playlist switches into and out of 4k mode now
 - Progress bar fill sizes correctly
  • Loading branch information
kbuffington committed May 22, 2021
1 parent c0cc642 commit 05d39fc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions js/CaTRoX_QWR/Panel_Playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,12 @@ function createPlaylistFonts() {
playlistFontsCreated = true;
}

function rescalePlaylist() {
if (playlistFontsCreated && playlistFontsCreated === is_4k) {
/**
* @param {boolean=} forceRescale
* @returns
*/
function rescalePlaylist(forceRescale) {
if (playlistFontsCreated && !forceRescale) {
return; // don't redo fonts
}
createPlaylistFonts();
Expand Down
6 changes: 3 additions & 3 deletions js/georgia-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ function draw_ui(gr) {
drawnInfo = array.join(' | ');
infoSize = gr.MeasureString(drawnInfo, infoFont, 0, 0, 0, 0);
}
if (drawnInfo.length) {
if (drawnInfo.length && maxInfoWidth) {
trackInfoHeight = Math.ceil(infoSize.Height + 1);
gr.DrawString(drawnInfo, infoFont, col.artist, infoLeft, geo.top_bg_h - trackInfoHeight - scaleForDisplay(15), maxInfoWidth, trackInfoHeight, StringFormat(2));
gr.SetTextRenderingHint(TextRenderingHint.AntiAliasGridFit);
Expand Down Expand Up @@ -966,8 +966,8 @@ window.RepaintRect = (x, y, w, h, force = undefined) => {
let rotatedCdIndex = 0; // global index of current cdartArray img to draw
function setupRotationTimer() {
clearInterval(cdartRotationTimer);
console.log(`creating ${pref.spinCdArtImageCount} rotated cd images, shown every ${pref.spinCdArtRedrawInterval}ms`);
if (pref.display_cdart && cdart && fb.IsPlaying && !fb.IsPaused && pref.spinCdart && !displayLibrary && !displayPlaylist) {
console.log(`creating ${pref.spinCdArtImageCount} rotated cd images, shown every ${pref.spinCdArtRedrawInterval}ms`);
cdartRotationTimer = setInterval(() => {
rotatedCdIndex++;
rotatedCdIndex %= pref.spinCdArtImageCount;
Expand Down Expand Up @@ -1429,7 +1429,7 @@ function on_size() {
if (fb.IsPlaying) {
loadCountryFlags(); // wrong size flag gets loaded on 4k systems
}
rescalePlaylist();
rescalePlaylist(true);
initPlaylist();
volume_btn = new VolumeBtn();
sizeInitialized = true;
Expand Down
1 change: 1 addition & 0 deletions js/ui-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class ProgressBar {
this.y = 0;
this.w = 0.95 * windowWidth;
this.h = geo.prog_bar_h;
this.progressMoved = true;
}

on_mouse_lbtn_down(x, y) {
Expand Down

0 comments on commit 05d39fc

Please sign in to comment.