Skip to content

Commit

Permalink
Buttons to select colors now change appearance when focused.
Browse files Browse the repository at this point in the history
+ Now uses `::PostMessageW()` instead of `::SendMessageW()` to update previews.
  • Loading branch information
sigma-axis committed Apr 20, 2024
1 parent 7b7ce38 commit 71d0c1c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion color_loupe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,7 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved)
// 看板.
////////////////////////////////
#define PLUGIN_NAME "色ルーペ"
#define PLUGIN_VERSION "v2.10-beta6"
#define PLUGIN_VERSION "v2.10-pre1"
#define PLUGIN_AUTHOR "sigma-axis"
#define PLUGIN_INFO_FMT(name, ver, author) (name##" "##ver##" by "##author)
#define PLUGIN_INFO PLUGIN_INFO_FMT(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
Expand Down
Binary file modified color_loupe.rc
Binary file not shown.
36 changes: 28 additions & 8 deletions dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ class tip_drag_format : public dialog_base {
void on_change_coord(CoordFormat data_new) { drag.coord_fmt = data_new; }
void update_view() {
if (update_target != nullptr && update_target->hwnd != nullptr)
::SendMessageW(update_target->hwnd, PrvMsg::UpdateView, {}, {});
::PostMessageW(update_target->hwnd, PrvMsg::UpdateView, {}, {});
}

protected:
Expand Down Expand Up @@ -848,6 +848,7 @@ class tip_drag_metrics : public dialog_base {
on_change_##field(get_spin_value(::GetDlgItem(hwnd, IDC_SPIN##id)));\
goto update
populate_field(invoke_on_change);
#undef invoke_on_change
#undef populate_field

update:
Expand Down Expand Up @@ -1063,7 +1064,7 @@ class toast_functions : public dialog_base {
void on_change_scale_format(ScaleFormat data_new) { toast.scale_format = data_new; }
void update_view() {
if (update_target != nullptr && update_target->hwnd != nullptr)
::SendMessageW(update_target->hwnd, PrvMsg::UpdateView, {}, {});
::PostMessageW(update_target->hwnd, PrvMsg::UpdateView, {}, {});
}

protected:
Expand Down Expand Up @@ -1212,8 +1213,7 @@ class toast_metrics : public dialog_base {

auto font = dialogs::ExtFunc::CreateUprightFont(toast.font_name, toast.font_size);
dialogs::ExtFunc::DrawToast(cvs.hdc(), cvs.sz(),
sample.size() <= 1 ? ((reinterpret_cast<int>(hwnd) & 0x40) == 0) ? L"(>~<)" : L"¯\\_(ツ)_/¯"
: sample.c_str(),
sample.size() > 0 ? sample.c_str() : ((reinterpret_cast<int>(hwnd) & 0x40) == 0) ? L"(>~<)" : L"\u00af\\_(ツ)_/\u00af",
font, toast, color_scheme);
::DeleteObject(font);

Expand Down Expand Up @@ -1252,6 +1252,7 @@ class toast_metrics : public dialog_base {
on_change_##field(get_spin_value(::GetDlgItem(hwnd, IDC_SPIN##id)));\
goto update
populate_field(invoke_on_change);
#undef invoke_on_change
#undef populate_field

case IDC_EDIT7:
Expand Down Expand Up @@ -1368,7 +1369,7 @@ class font_settings : public dialog_base {
int8_t& size;
int8_t const min, max;
dialog_base* const update_target;
font_settings(wchar_t(&name)[LF_FACESIZE], int8_t& size, int8_t min, int8_t max,
font_settings(decltype(name) name, int8_t& size, int8_t min, int8_t max,
dialog_base* const update_target)
: name{ name }, size{ size }, min{ min }, max{ max }, update_target{ update_target } {}

Expand All @@ -1379,7 +1380,7 @@ class font_settings : public dialog_base {
void on_change_size(int8_t data_new) { size = std::clamp(data_new, min, max); }
void update_view() {
if (update_target != nullptr && update_target->hwnd != nullptr)
::SendMessageW(update_target->hwnd, PrvMsg::UpdateView, {}, {});
::PostMessageW(update_target->hwnd, PrvMsg::UpdateView, {}, {});
}

protected:
Expand Down Expand Up @@ -1721,6 +1722,26 @@ class color_config : public dialog_base {
return true;
}
break;

// thickening the button edge when focused.
case BN_SETFOCUS:
case BN_KILLFOCUS:
switch (id) {
case IDC_BUTTON1:
case IDC_BUTTON2:
case IDC_BUTTON3:
case IDC_BUTTON4:
case IDC_BUTTON5:
constexpr uint32_t focused_style = WS_EX_CLIENTEDGE, unfocused_style = WS_EX_STATICEDGE;
::SetWindowLongW(ctrl, GWL_EXSTYLE, (::GetWindowLongW(ctrl, GWL_EXSTYLE)
& ~(focused_style | unfocused_style))
| (code == BN_SETFOCUS ? focused_style : unfocused_style));
// as the window style changed, update must be done by ::SetWindowPos().
::SetWindowPos(ctrl, {}, {}, {}, {}, {},
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
return true;
}
break;
}
break;

Expand Down Expand Up @@ -2064,8 +2085,7 @@ class setting_dlg : public dialog_base {

case LBN_SELCHANGE:
if (id == IDC_LIST1) {
auto list = reinterpret_cast<HWND>(lparam);
on_select(get_list_data<tab_kind>(list));
on_select(get_list_data<tab_kind>(reinterpret_cast<HWND>(lparam)));
return true;
}
break;
Expand Down

0 comments on commit 71d0c1c

Please sign in to comment.