Skip to content

Commit

Permalink
Add support for a regular mode at 800x675
Browse files Browse the repository at this point in the history
  • Loading branch information
Aemony committed May 16, 2024
1 parent 488c53c commit 5b9cd22
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 41 deletions.
32 changes: 11 additions & 21 deletions src/SKIF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ ImVec2 SKIF_vecHorizonModeAdjusted = SKIF_vecHorizonModeDefault; // Adjusted fo
ImVec2 SKIF_vecCurrentPosition = ImVec2 (0.0f, 0.0f); // Gets updated after ImGui::EndFrame()
ImVec2 SKIF_vecCurrentMode = ImVec2 (0.0f, 0.0f); // Gets updated after ImGui::EndFrame()
ImVec2 SKIF_vecCurrentModeNext = ImVec2 (0.0f, 0.0f); // Holds the new expected size
ImVec2 SKIF_vecAlteredSize = ImVec2 (0.0f, 0.0f);
float SKIF_fStatusBarHeight = 31.0f; // Status bar enabled // 33 ?
float SKIF_fStatusBarDisabled = 8.0f; // Status bar disabled
float SKIF_fStatusBarHeightTips = 18.0f; // Disabled tooltips (two-line status bar)
Expand Down Expand Up @@ -1940,11 +1939,20 @@ wWinMain ( _In_ HINSTANCE hInstance,
}
}
}

SKIF_vecServiceMode = SKIF_vecServiceModeDefault * SKIF_ImGui_GlobalDPIScale;
SKIF_vecHorizonMode = SKIF_vecHorizonModeAdjusted * SKIF_ImGui_GlobalDPIScale;
SKIF_vecRegularMode = SKIF_vecRegularModeAdjusted * SKIF_ImGui_GlobalDPIScale;


// Add support for an even smaller regular mode, at 800x675, but only if the regular size 1000x944 can't be used
if (//ImGui::GetFrameCount() > 2 &&
(SKIF_vecRegularMode.x > monitor_extent.GetWidth () ||
SKIF_vecRegularMode.y > monitor_extent.GetHeight()))
{
SKIF_vecRegularMode.x = 800.0f;
SKIF_vecRegularMode.y = 675.0f;
}

//SKIF_vecHorizonMode.y -= SKIF_vecAlteredSize.y;
//SKIF_vecRegularMode.y -= SKIF_vecAlteredSize.y;

Expand All @@ -1970,9 +1978,6 @@ wWinMain ( _In_ HINSTANCE hInstance,

changedHiDPIScaling = false;

// Reset reduced height
SKIF_vecAlteredSize.y = 0.0f;

// Take the current display into account
HMONITOR monitor =
::MonitorFromWindow (SKIF_ImGui_hWnd, MONITOR_DEFAULTTONEAREST);
Expand Down Expand Up @@ -2165,18 +2170,6 @@ wWinMain ( _In_ HINSTANCE hInstance,
RespectMonBoundaries = true;
}

#if 0
// Automatically engage Horizon mode on smaller displays
static bool autoHorizonFallback = (! _registry.bHorizonMode && _registry.bHorizonModeAuto);
if (false && autoHorizonFallback && ! _registry.bServiceMode && SKIF_vecAlteredSize.y > 50.0f)
{
autoHorizonFallback = false;

_registry.bHorizonMode = newHorizonMode = true;
SKIF_ImGui_AdjustAppModeSize (NULL);
}
#endif

// Apply any changes to the ImGui style
// Do it at the beginning of frames to prevent ImGui::Push... from affecting the styling
// Note that Win11 rounded border color won't be applied until after a restart
Expand Down Expand Up @@ -2408,9 +2401,6 @@ wWinMain ( _In_ HINSTANCE hInstance,
// Only act once at launch or if we are, in fact, on a new display
if (preMonitor != actMonitor || _WantUpdateMonitors)
{
// Reset reduced height
SKIF_vecAlteredSize.y = 0.0f;

// This is only necessary to run once on launch, to account for the startup display DPI
SK_RunOnce (SKIF_ImGui_GlobalDPIScale = (_registry.bDPIScaling) ? ImGui::GetWindowViewport()->DpiScale : 1.0f);

Expand Down
8 changes: 2 additions & 6 deletions src/imgui/imgui_impl_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,6 @@ static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd,
extern ImVec2 SKIF_vecServiceModeDefault;
extern ImVec2 SKIF_vecCurrentMode;
extern ImVec2 SKIF_vecCurrentModeNext;
extern ImVec2 SKIF_vecAlteredSize;
extern HWND SKIF_Notify_hWnd;

extern bool msgDontRedraw;
Expand Down Expand Up @@ -1869,9 +1868,6 @@ static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd,
invalidateFonts;
invalidateFonts = true;

// Reset reduced height
SKIF_vecAlteredSize.y = 0.0f;

POINT ptLeftTop = {
prcNewWindow->left,
prcNewWindow->top
Expand All @@ -1896,8 +1892,8 @@ static LRESULT CALLBACK ImGui_ImplWin32_WndProcHandler_PlatformWindow(HWND hWnd,
(_registry.bHorizonMode) ? SKIF_vecHorizonModeAdjusted :
SKIF_vecRegularModeAdjusted ;

if (tmpCurrentSize.y * SKIF_ImGui_GlobalDPIScale > (WorkSize.y))
SKIF_vecAlteredSize.y = (tmpCurrentSize.y * SKIF_ImGui_GlobalDPIScale - (WorkSize.y)); // (WorkSize.y - 50.0f);
//if (tmpCurrentSize.y * SKIF_ImGui_GlobalDPIScale > (WorkSize.y))
// SKIF_vecAlteredSize.y = (tmpCurrentSize.y * SKIF_ImGui_GlobalDPIScale - (WorkSize.y)); // (WorkSize.y - 50.0f);

// Divide the window size with its associated DPI scale to get the base size, then multiply with the new DPI scale
SKIF_vecCurrentModeNext = (SKIF_vecCurrentMode / SKIF_ImGui_GlobalDPIScale_Last) * SKIF_ImGui_GlobalDPIScale;
Expand Down
6 changes: 4 additions & 2 deletions src/tabs/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ std::wstring dragDroppedFilePathGame = L"";
extern bool allowShortcutCtrlA;
extern ImVec2 SKIF_vecServiceMode;
extern ImVec2 SKIF_vecHorizonMode;
extern ImVec2 SKIF_vecAlteredSize;
extern float SKIF_ImGui_GlobalDPIScale;
extern float SKIF_ImGui_GlobalDPIScale_Last;
extern std::string SKIF_StatusBarHelp;
Expand Down Expand Up @@ -5824,6 +5823,8 @@ SKIF_UI_Tab_DrawLibrary (void)
sizeSK = ImVec2 (600.0f, 900.0f) * SKIF_ImGui_GlobalDPIScale;
sizeSK_small = ImVec2 (220.0f, 330.0f) * SKIF_ImGui_GlobalDPIScale;

extern ImVec2 SKIF_vecRegularMode;

static float arCover = 600.0f / 900.0f;

float horizon_cutoff_height = 550.0f * SKIF_ImGui_GlobalDPIScale; // 750.0f // 650.0f
Expand Down Expand Up @@ -5866,7 +5867,7 @@ SKIF_UI_Tab_DrawLibrary (void)

uiCoverVisible = (_registry._LibHorizonMode)
? (tab_ContentRegionAvail.x > (sizeList.x + sizeDetails.x + sizeSK_small.x * 0.75f)) // When in horizontal mode, large enough to allow 75% of the tiny cover to appear
: (uiDetailsVisible) ? (tab_ContentRegionAvail.x > ( sizeDetails.x + sizeSK.x * 0.75f)) : false; // When in regular mode, large enough to allow 75% of the large cover to appear
: (uiDetailsVisible) ? (tab_ContentRegionAvail.x > (SKIF_vecRegularMode.x * 0.75f)) : false; // When in regular mode, large enough to allow 75% of the large cover to appear // sizeDetails.x + sizeSK.x * 0.75f

if (! uiCoverVisible)
{
Expand Down Expand Up @@ -9203,6 +9204,7 @@ SKIF_UI_Tab_DrawLibrary (void)
}
}

// TODO: Make away with RepopulateGames = true from here -- we shouldn't have to reload all games just to refresh textures
// Trigger a refresh of the list of games, which will reload all icons and the Patreon texture
RepopulateGames = true;
// Trigger a refresh of the cover
Expand Down
14 changes: 2 additions & 12 deletions src/utility/skif_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,10 @@ SKIF_ImGui_AdjustAppModeSize (HMONITOR monitor)
extern ImVec2 SKIF_vecHorizonModeDefault;
extern ImVec2 SKIF_vecHorizonModeAdjusted;
extern ImVec2 SKIF_vecServiceModeDefault;
extern ImVec2 SKIF_vecAlteredSize;
extern float SKIF_fStatusBarHeight;
extern float SKIF_fStatusBarDisabled;
extern float SKIF_fStatusBarHeightTips;

// Reset reduced height
SKIF_vecAlteredSize.y = 0.0f;

// Adjust the large mode size
SKIF_vecRegularModeAdjusted = SKIF_vecRegularModeDefault;
SKIF_vecHorizonModeAdjusted = SKIF_vecHorizonModeDefault;
Expand Down Expand Up @@ -361,8 +357,8 @@ SKIF_ImGui_AdjustAppModeSize (HMONITOR monitor)
(_registry.bHorizonMode) ? SKIF_vecHorizonModeAdjusted :
SKIF_vecRegularModeAdjusted ;

if (tmpCurrentSize.y * SKIF_ImGui_GlobalDPIScale > (WorkSize.y))
SKIF_vecAlteredSize.y = (tmpCurrentSize.y * SKIF_ImGui_GlobalDPIScale - (WorkSize.y));
//if (tmpCurrentSize.y * SKIF_ImGui_GlobalDPIScale > (WorkSize.y))
// SKIF_vecAlteredSize.y = (tmpCurrentSize.y * SKIF_ImGui_GlobalDPIScale - (WorkSize.y));
}
}

Expand Down Expand Up @@ -707,7 +703,6 @@ void SKIF_ImGui_BeginTabChildFrame (void)
{
static SKIF_RegistrySettings& _registry = SKIF_RegistrySettings::GetInstance ( );

//extern ImVec2 SKIF_vecAlteredSize;
extern ImVec2 SKIF_vecRegularModeDefault; // Does not include the status bar
extern ImVec2 SKIF_vecRegularModeAdjusted; // Adjusted for status bar and tooltips
extern ImVec2 SKIF_vecHorizonModeDefault; // Does not include the status bar
Expand All @@ -721,11 +716,6 @@ void SKIF_ImGui_BeginTabChildFrame (void)
? SKIF_vecHorizonModeAdjusted - SKIF_vecHorizonModeDefault
: SKIF_vecRegularModeAdjusted - SKIF_vecRegularModeDefault;

/*
float maxContentHeight = (_registry.bHorizonMode) ? 336.0f + ImGui::GetStyle().WindowBorderSize * 2.0f : 908.0f; // Default height -- 908 is the absolute minimum height that the Library tab can fit into // 2024-01-20: 286 -> 336
maxContentHeight -= (SKIF_vecAlteredSize.y / SKIF_ImGui_GlobalDPIScale);
*/

// DPI-aware
float maxContentHeight = ImGui::GetWindowSize().y - ImGui::GetCursorPosY() - (statusbar_size.y * SKIF_ImGui_GlobalDPIScale);

Expand Down

0 comments on commit 5b9cd22

Please sign in to comment.