Skip to content

Commit

Permalink
Add dark mode support to FCL import errors window
Browse files Browse the repository at this point in the history
This adds dark mode support to the window that appears when there were errors importing an FCL file.
  • Loading branch information
reupen committed Apr 14, 2023
1 parent 50356c3 commit 7531ea8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 30 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
[#688](https://github.com/reupen/columns_ui/pull/688) (contributed by
[@marc2k3](https://github.com/marc2k3)),
[#689](https://github.com/reupen/columns_ui/pull/689),
[#692](https://github.com/reupen/columns_ui/pull/692)]
[#692](https://github.com/reupen/columns_ui/pull/692),
[#695](https://github.com/reupen/columns_ui/pull/695)]

- Dark menus were enabled on Windows 11 build 22624.
[[#680](https://github.com/reupen/columns_ui/pull/680), contributed by
Expand Down
33 changes: 12 additions & 21 deletions foo_ui_columns/fcl.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "pch.h"
#include "fcl.h"

#include "core_dark_list_view.h"
#include "dark_mode_dialog.h"
#include "main_window.h"

Expand Down Expand Up @@ -209,7 +210,8 @@ class ImportResultsDialog {
static HWND s_open(HWND parent_wnd, PanelInfoList items, bool aborted)
{
auto dialog = std::make_shared<ImportResultsDialog>(std::move(items), aborted);
const auto wnd = uih::modeless_dialog_box(IDD_RESULTS, parent_wnd,
const cui::dark::DialogDarkModeConfig dark_mode_config{.button_ids = {IDOK}};
const auto wnd = modeless_dialog_box(IDD_RESULTS, dark_mode_config, parent_wnd,
[dialog](auto&&... args) { return dialog->handle_dialog_message(std::forward<decltype(args)>(args)...); });
ShowWindow(wnd, SW_SHOWNORMAL);
return wnd;
Expand All @@ -222,36 +224,24 @@ class ImportResultsDialog {
case WM_INITDIALOG: {
modeless_dialog_manager::g_add(wnd);
SetWindowText(wnd, L"FCL import results");
HWND wnd_lv = GetDlgItem(wnd, IDC_LIST);
uih::list_view_set_explorer_theme(wnd_lv);

SetWindowText(GetDlgItem(wnd, IDC_CAPTION),
m_aborted ? L"The layout import was aborted because the following required panels are not installed:"
: L"Some parts of the layout may not have imported because the following panels are not "
L"installed:");

LVCOLUMN lvc{};
lvc.mask = LVCF_TEXT | LVCF_WIDTH;

uih::list_view_insert_column_text(wnd_lv, 0, L"Name", 150);
uih::list_view_insert_column_text(wnd_lv, 1, L"GUID", 300);
m_list_view.create(wnd, {7, 21, 443, 192}, true);
m_list_view.set_columns({{"Name", 200_spx}, {"GUID", 300_spx}});

SendMessage(wnd_lv, WM_SETREDRAW, FALSE, 0);
const auto items = ranges::views::transform(m_items, [](auto&& item) {
return uih::ListView::InsertItem{{item.name, pfc::print_guid(item.guid)}, {}};
}) | ranges::to_vector;

LVITEM lvi{};
lvi.mask = LVIF_TEXT;
const auto count = gsl::narrow<int>(m_items.get_count());
for (int i = 0; i < count; i++) {
pfc::string8 temp;
uih::list_view_insert_item_text(wnd_lv, i, 0, m_items[i].name, false);
uih::list_view_insert_item_text(wnd_lv, i, 1, pfc::print_guid(m_items[i].guid), true);
}
SendMessage(wnd_lv, WM_SETREDRAW, TRUE, 0);
RedrawWindow(wnd_lv, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW);
m_list_view.insert_items(0, items.size(), items.data());
ShowWindow(m_list_view.get_wnd(), SW_SHOWNORMAL);
} break;
case WM_COMMAND:
switch (wp) {
case IDCANCEL:
case IDOK:
DestroyWindow(wnd);
return 0;
}
Expand All @@ -269,6 +259,7 @@ class ImportResultsDialog {

PanelInfoList m_items;
bool m_aborted{};
cui::helpers::CoreDarkListView m_list_view{true};
};

PFC_DECLARE_EXCEPTION(exception_fcl_dependentpanelmissing, pfc::exception, "Missing dependent panel(s)")
Expand Down
15 changes: 7 additions & 8 deletions foo_ui_columns/foo_ui_columns.rc
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,13 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,185,151,50,14
END

IDD_RESULTS DIALOGEX 0, 0, 457, 239
IDD_RESULTS DIALOGEX 0, 0, 457, 249
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU
CAPTION "Generic results template"
FONT 8, "Segoe UI", 400, 0, 0x0
BEGIN
PUSHBUTTON "Close",IDCANCEL,391,219,60,14
CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,6,23,445,190
LTEXT "Static",IDC_CAPTION,6,8,445,10
PUSHBUTTON "Close",IDOK,390,228,60,14
LTEXT "Static",IDC_CAPTION,7,7,443,10
END

IDD_FCL_EXPORT DIALOGEX 0, 0, 242, 200
Expand Down Expand Up @@ -823,10 +822,10 @@ BEGIN

IDD_RESULTS, DIALOG
BEGIN
LEFTMARGIN, 6
RIGHTMARGIN, 451
TOPMARGIN, 8
BOTTOMMARGIN, 233
LEFTMARGIN, 7
RIGHTMARGIN, 450
TOPMARGIN, 7
BOTTOMMARGIN, 242
END

IDD_FCL_EXPORT, DIALOG
Expand Down

0 comments on commit 7531ea8

Please sign in to comment.