Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a compact UI mode. #80

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/discord/LocalSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ bool LocalSettings::Load()
if (j.contains("EnableTLSVerification"))
m_bEnableTLSVerification = j["EnableTLSVerification"];

if (j.contains("ReducePadding"))
m_bReducePadding = j["ReducePadding"];

if (m_bSaveWindowSize)
{
if (j.contains("WindowWidth"))
Expand Down Expand Up @@ -119,6 +122,7 @@ bool LocalSettings::Save()
j["SaveWindowSize"] = m_bSaveWindowSize;
j["CheckUpdates"] = m_bCheckUpdates;
j["EnableTLSVerification"] = m_bEnableTLSVerification;
j["ReducePadding"] = m_bReducePadding;
j["RemindUpdateCheckOn"] = (long long)(m_remindUpdatesOn);
if (m_bSaveWindowSize) {
j["WindowWidth"] = m_width;
Expand Down
7 changes: 7 additions & 0 deletions src/discord/LocalSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class LocalSettings
bool GetSaveWindowSize() const {
return m_bSaveWindowSize;
}
void SetReducePadding(bool b) {
m_bReducePadding = b;
}
bool GetReducePadding() const {
return m_bReducePadding;
}
void SetStartMaximized(bool b) {
m_bStartMaximized = b;
}
Expand Down Expand Up @@ -106,6 +112,7 @@ class LocalSettings
bool m_bCheckUpdates = false;
bool m_bAskToCheckUpdates = true;
bool m_bEnableTLSVerification = true;
bool m_bReducePadding = false;
time_t m_remindUpdatesOn = 0;
int m_width = 1000;
int m_height = 700;
Expand Down
4 changes: 2 additions & 2 deletions src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@
#define IDC_ICON_WARN_CONNECT 868
#define IDC_ICON_WARN_WEBSOCKETSTUFF 869
#define IDC_ICON_WARN_WEBSOCKETSTUFF2 870
#define IDC_CHECK1 871
#define IDC_ENABLE_TLS_CHECKS 871
#define IDC_CHECK_UPDATES 872
#define IDC_REDUCE_PADDING 873
#define ID_FILE_PREFERENCES 1001
#define ID_FILE_STOPALLSPEECH 1002
#define ID_FILE_EXIT 1003
Expand Down Expand Up @@ -359,7 +359,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 73
#define _APS_NEXT_COMMAND_VALUE 1069
#define _APS_NEXT_CONTROL_VALUE 873
#define _APS_NEXT_CONTROL_VALUE 874
#define _APS_NEXT_SYMED_VALUE 40000
#endif
#endif
10 changes: 6 additions & 4 deletions src/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,11 @@ BEGIN
CONTROL "Gradient",IDC_RADIO_GRADIENT,"Button",BS_AUTORADIOBUTTON,12,78,43,10
CONTROL "Flat Color 1",IDC_RADIO_FLAT_1,"Button",BS_AUTORADIOBUTTON,12,91,53,10
CONTROL "Flat Color 2",IDC_RADIO_FLAT_2,"Button",BS_AUTORADIOBUTTON,12,104,53,10
GROUPBOX "Window Settings",IDC_STATIC,6,127,245,38
CONTROL "Save window size",IDC_SAVE_WINDOW_SIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,138,72,10
CONTROL "Start maximized",IDC_START_MAXIMIZED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,150,67,10
GROUPBOX "Window Settings",IDC_STATIC,6,127,245,50
CONTROL "Save window size",IDC_SAVE_WINDOW_SIZE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,138,230,10
CONTROL "Start maximized",IDC_START_MAXIMIZED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,150,229,10
CONTROL "Reduce UI padding (for smaller screens)",IDC_REDUCE_PADDING,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,163,228,10
END

IDD_DIALOG_PROFILE_POPOUT DIALOGEX 0, 0, 228, 218
Expand Down Expand Up @@ -593,7 +595,7 @@ BEGIN
LEFTMARGIN, 6
RIGHTMARGIN, 251
TOPMARGIN, 7
BOTTOMMARGIN, 192
BOTTOMMARGIN, 234
END

IDD_DIALOG_PROFILE_POPOUT, DIALOG
Expand Down
46 changes: 26 additions & 20 deletions src/windows/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ void ProperlySizeControls(HWND hWnd)
GetClientRect(hWnd, &rect);
rcClient = rect;

int scaled10 = ScaleByDPI(10);
int borderSize = ScaleByDPI(GetLocalSettings()->GetReducePadding() ? 5 : 10);

rect.left += scaled10;
rect.top += scaled10;
rect.right -= scaled10;
rect.bottom -= scaled10;
rect.left += borderSize;
rect.top += borderSize;
rect.right -= borderSize;
rect.bottom -= borderSize;

HWND hWndMsg = g_pMessageList->m_hwnd;
HWND hWndChv = g_pChannelView->m_hwnd;
Expand Down Expand Up @@ -235,40 +235,40 @@ void ProperlySizeControls(HWND hWnd)
bool bRepaint = true;

// Create a message list
rect.left += g_ChannelViewListWidth + scaled10 + g_GuildListerWidth + scaled10;
rect.bottom -= g_MessageEditorHeight + g_pMessageEditor->ExpandedBy() + scaled10;
rect.top += g_GuildHeaderHeight;
if (g_bMemberListVisible) rect.right -= g_MemberListWidth + scaled10;
rect.left += g_ChannelViewListWidth + borderSize + g_GuildListerWidth + borderSize;
rect.bottom -= g_MessageEditorHeight + g_pMessageEditor->ExpandedBy() + borderSize;
rect.top += g_GuildHeaderHeight + borderSize;
if (g_bMemberListVisible) rect.right -= g_MemberListWidth + borderSize;
MoveWindow(hWndMsg, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint);

rect.left = rect.right + scaled10;
rect.left = rect.right + borderSize;
rect.right = rect.left + g_MemberListWidth;
rect.bottom = rect2.bottom;
MoveWindow(hWndMel, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint);
rect = rect2;

rect.left += g_GuildListerWidth + scaled10;
rect.left += g_GuildListerWidth + borderSize;
rect.right = rect.left + g_ChannelViewListWidth;
rect.bottom -= g_BottomBarHeight;
rect.top += g_GuildHeaderHeight;
rect.top += g_GuildHeaderHeight + borderSize;
MoveWindow(hWndChv, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint);
rect = rect2;

rect.left += g_GuildListerWidth + scaled10;
rect.top = rect.bottom - g_BottomBarHeight + scaled10;
rect.left += g_GuildListerWidth + borderSize;
rect.top = rect.bottom - g_BottomBarHeight + borderSize;
rect.right = rect.left + g_ChannelViewListWidth;
MoveWindow(hWndPfv, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint);
rect = rect2;

rect.left = g_ChannelViewListWidth + scaled10 + scaled10 + g_GuildListerWidth + scaled10;
rect.left = g_ChannelViewListWidth + borderSize + borderSize + g_GuildListerWidth + borderSize;
rect.top = rect.bottom - g_MessageEditorHeight - g_pMessageEditor->ExpandedBy();
if (g_bMemberListVisible) rect.right -= g_MemberListWidth + scaled10;
if (g_bMemberListVisible) rect.right -= g_MemberListWidth + borderSize;
int textInputHeight = rect.bottom - rect.top, textInputWidth = rect.right - rect.left;
MoveWindow(hWndTin, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bRepaint);
rect = rect2;

rect.left += g_GuildListerWidth + scaled10;
rect.bottom = rect.top + g_GuildHeaderHeight - scaled10;
rect.left += g_GuildListerWidth + borderSize;
rect.bottom = rect.top + g_GuildHeaderHeight;
MoveWindow(hWndGuh, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, FALSE);
rect = rect2;

Expand Down Expand Up @@ -650,13 +650,19 @@ LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
case WM_REPAINTMSGLIST:
{
InvalidateRect(g_pMessageList->m_hwnd, NULL, false);
InvalidateRect(g_pMessageList->m_hwnd, NULL, FALSE);
break;
}
case WM_MSGLISTUPDATEMODE:
{
g_pMessageList->UpdateBackgroundBrush();
InvalidateRect(g_pMessageList->m_hwnd, NULL, false);
InvalidateRect(g_pMessageList->m_hwnd, NULL, TRUE);
break;
}
case WM_REPOSITIONEVERYTHING:
{
ProperlySizeControls(hWnd);
InvalidateRect(hWnd, NULL, TRUE);
break;
}
case WM_RECALCMSGLIST:
Expand Down
2 changes: 1 addition & 1 deletion src/windows/Measurements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#define PROFILE_PICTURE_SIZE_DEF 36
#define CHANNEL_VIEW_LIST_WIDTH 200
#define GUILD_HEADER_HEIGHT 40
#define GUILD_HEADER_HEIGHT 30
#define GUILD_HEADER_RIGHT_WIDTH 150
#define GUILD_LISTER_WIDTH (PROFILE_PICTURE_SIZE_DEF + 16)
#define MEMBER_LIST_WIDTH 200
Expand Down
Loading