diff --git a/.gitattributes b/.gitattributes index c96bc4b..a943bf8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,7 +3,6 @@ ############################################################################### * text=auto *.ini text working-tree-encoding=UTF-8 eol=crlf -*.rc diff=astextplain ############################################################################### # Set default behavior for command prompt diff. diff --git a/color_loupe.cpp b/color_loupe.cpp index 76410f9..9451315 100644 --- a/color_loupe.cpp +++ b/color_loupe.cpp @@ -1927,7 +1927,7 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved) // 看板. //////////////////////////////// #define PLUGIN_NAME "色ルーペ" -#define PLUGIN_VERSION "v2.21" +#define PLUGIN_VERSION "v2.22-beta1" #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) diff --git a/color_loupe.rc b/color_loupe.rc index 31ced36..1b84d20 100644 Binary files a/color_loupe.rc and b/color_loupe.rc differ diff --git a/dialogs.cpp b/dialogs.cpp index 355f2d0..abce352 100644 --- a/dialogs.cpp +++ b/dialogs.cpp @@ -828,9 +828,9 @@ class tip_drag_metrics : public dialog_base { { // suppress notifications from controls. auto sc = suppress_callback(); -#define set_spin(id, field) init_spin(::GetDlgItem(hwnd, IDC_SPIN##id), drag.field, Settings::TipDrag::field##_min, Settings::TipDrag::field##_max) + #define set_spin(id, field) init_spin(::GetDlgItem(hwnd, IDC_SPIN##id), drag.field, Settings::TipDrag::field##_min, Settings::TipDrag::field##_max) populate_field(set_spin); -#undef set_spin + #undef set_spin std::srand(reinterpret_cast(hwnd)); return false; @@ -843,13 +843,12 @@ class tip_drag_metrics : public dialog_base { switch (auto id = 0xffff & wparam, code = wparam >> 16; code) { case EN_CHANGE: switch (id) { -#define invoke_on_change(id, field) \ + #define invoke_on_change(id, field) \ case IDC_EDIT##id:\ 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 + #undef invoke_on_change update: update_view(); @@ -879,6 +878,7 @@ class tip_drag_metrics : public dialog_base { } return false; } +#undef populate_field }; @@ -1316,9 +1316,9 @@ class toast_metrics : public dialog_base { { // suppress notifications from controls. auto sc = suppress_callback(); -#define set_spin(id, field) init_spin(::GetDlgItem(hwnd, IDC_SPIN##id), toast.field, Settings::Toast::field##_min, Settings::Toast::field##_max) + #define set_spin(id, field) init_spin(::GetDlgItem(hwnd, IDC_SPIN##id), toast.field, Settings::Toast::field##_min, Settings::Toast::field##_max) populate_field(set_spin); -#undef set_spin + #undef set_spin ::SendMessageW(::GetDlgItem(hwnd, IDC_EDIT7), WM_SETTEXT, {}, reinterpret_cast(res_str::get(IDS_DLG_TOAST_SAMPLE))); @@ -1334,13 +1334,12 @@ class toast_metrics : public dialog_base { switch (auto id = 0xffff & wparam, code = wparam >> 16; code) { case EN_CHANGE: switch (id) { -#define invoke_on_change(id, field) \ + #define invoke_on_change(id, field) \ case IDC_EDIT##id:\ 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 + #undef invoke_on_change case IDC_EDIT7: update: @@ -1362,6 +1361,7 @@ class toast_metrics : public dialog_base { } return false; } +#undef populate_field }; @@ -1448,22 +1448,26 @@ class grid_options : public dialog_base { // フォントの設定. //////////////////////////////// class font_settings : public dialog_base { - using Pivot = Settings::WheelZoom::Pivot; - using ClickActions = Settings::ClickActions; - public: - wchar_t (&name)[LF_FACESIZE]; + wchar_t(&name)[LF_FACESIZE]; int8_t& size; int8_t const min, max; dialog_base* const update_target; font_settings(decltype(name) name, int8_t& size, int8_t min, int8_t max, - dialog_base* const update_target) + dialog_base* update_target) : name{ name }, size{ size }, min{ min }, max{ max }, update_target{ update_target } {} private: - void on_change_name(HWND ctrl) { + void on_edit_name(HWND ctrl) { ::SendMessageW(ctrl, WM_GETTEXT, std::size(name), reinterpret_cast(name)); } + void on_select_name(HWND ctrl) { + size_t idx = ::SendMessageW(ctrl, CB_GETCURSEL, {}, {}); + if (idx == CB_ERR) return; + if (size_t len = ::SendMessageW(ctrl, CB_GETLBTEXTLEN, idx, {}); + len == CB_ERR || std::size(name) <= len) return; + ::SendMessageW(ctrl, CB_GETLBTEXT, idx, reinterpret_cast(name)); + } 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) @@ -1488,11 +1492,13 @@ class font_settings : public dialog_base { return TRUE; }, reinterpret_cast(combo)); ::ReleaseDC(nullptr, hdc); - ::SendMessageW(combo, CB_SELECTSTRING, -1, reinterpret_cast(name)); + ::SendMessageW(combo, WM_SETTEXT, {}, reinterpret_cast(name)); // font size. init_spin(::GetDlgItem(hwnd, IDC_SPIN1), size, min, max); + ::SendMessageW(::GetDlgItem(hwnd, IDC_EDIT2), WM_SETTEXT, + {}, reinterpret_cast(res_str::get(IDS_DESC_FONT_STYLE))); return false; } @@ -1502,10 +1508,18 @@ class font_settings : public dialog_base { switch (message) { case WM_COMMAND: switch (auto id = 0xffff & wparam, code = wparam >> 16; code) { + case CBN_EDITCHANGE: + switch (id) { + case IDC_COMBO1: + on_edit_name(ctrl); + update_view(); + return true; + } + break; case CBN_SELCHANGE: switch (id) { case IDC_COMBO1: - on_change_name(ctrl); + on_select_name(ctrl); update_view(); return true; } diff --git a/resource.h b/resource.h index de39d0f..bd354ca 100644 --- a/resource.h +++ b/resource.h @@ -77,21 +77,22 @@ #define IDS_DESC_EXEDIT_FAKE 173 #define IDS_DESC_GRID_KINDS 174 #define IDS_DESC_CLIPBOARD_FMT 175 -#define IDS_DESC_CMD_NONE 176 -#define IDS_DESC_CMD_SWAP_ZOOM 177 -#define IDS_DESC_CMD_COPY_COLOR 178 -#define IDS_DESC_CMD_COPY_COORD 179 -#define IDS_DESC_CMD_FOLLOW 180 -#define IDS_DESC_CMD_CENTRALIZE 181 -#define IDS_DESC_CMD_GRID 182 -#define IDS_DESC_CMD_ZOOM_UP 183 -#define IDS_DESC_CMD_ZOOM_DOWN 184 -#define IDS_DESC_CMD_BRING_CENTER 185 -#define IDS_DESC_CMD_CXT_MENU 186 -#define IDS_DESC_CMD_SETTINGS 187 -#define IDS_DLG_TOAST_SAMPLE 188 -#define IDS_COLOR_THEME_LIGHT 189 -#define IDS_COLOR_THEME_DARK 190 +#define IDS_DESC_FONT_STYLE 176 +#define IDS_DESC_CMD_NONE 177 +#define IDS_DESC_CMD_SWAP_ZOOM 178 +#define IDS_DESC_CMD_COPY_COLOR 179 +#define IDS_DESC_CMD_COPY_COORD 180 +#define IDS_DESC_CMD_FOLLOW 181 +#define IDS_DESC_CMD_CENTRALIZE 182 +#define IDS_DESC_CMD_GRID 183 +#define IDS_DESC_CMD_ZOOM_UP 184 +#define IDS_DESC_CMD_ZOOM_DOWN 185 +#define IDS_DESC_CMD_BRING_CENTER 186 +#define IDS_DESC_CMD_CXT_MENU 187 +#define IDS_DESC_CMD_SETTINGS 188 +#define IDS_DLG_TOAST_SAMPLE 189 +#define IDS_COLOR_THEME_LIGHT 190 +#define IDS_COLOR_THEME_DARK 191 #define IDD_VSCROLLFORM 800 #define IDD_SETTINGS 801 #define IDD_SETTINGS_FORM_CLICK_ACTION 802 diff --git a/settings.hpp b/settings.hpp index f5b247f..e794664 100644 --- a/settings.hpp +++ b/settings.hpp @@ -287,21 +287,21 @@ inline constinit struct Settings { return static_cast( ::GetPrivateProfileIntA(section, key, static_cast(def), ini_file)); }; -#define load_gen(section, tgt, read, write) section.tgt = read(read_raw(write(section.tgt), #section, #tgt)) -#define load_int(section, tgt) load_gen(section, tgt, \ - [&](auto y) { return std::clamp(y, section.tgt##_min, section.tgt##_max); }, /*id*/) -#define load_bool(section, tgt) load_gen(section, tgt, \ - [](auto y) { return y != 0; }, [](auto x) { return x ? 1 : 0; }) -#define load_enum(section, tgt) load_gen(section, tgt, \ - [](auto y) { return static_cast(y); }, [](auto x) { return static_cast(x); }) -#define load_color(section, tgt) load_gen(section, tgt, \ - [](auto y) { return Color::fromARGB(y); }, [](auto x) { return x.to_formattable(); }) -#define load_zoom(section, header) \ + #define load_gen(section, tgt, read, write) section.tgt = read(read_raw(write(section.tgt), #section, #tgt)) + #define load_int(section, tgt) \ + load_gen(section, tgt, [&](auto y) { return std::clamp(y, section.tgt##_min, section.tgt##_max); }, /*id*/) + #define load_bool(section, tgt) \ + load_gen(section, tgt, [](auto y) { return y != 0; }, [](auto x) { return x ? 1 : 0; }) + #define load_enum(section, tgt) \ + load_gen(section, tgt, [](auto y) { return static_cast(y); }, [](auto x) { return static_cast(x); }) + #define load_color(section, tgt) \ + load_gen(section, tgt, [](auto y) { return Color::fromARGB(y); }, [](auto x) { return x.to_formattable(); }) + #define load_zoom(section, header) \ load_bool(section, header##enabled);\ load_bool(section, header##reversed);\ load_int(section, header##num_steps);\ load_enum(section, header##pivot) -#define load_drag(section) \ + #define load_drag(section) \ load_enum(section, keys.button);\ load_enum(section, keys.ctrl);\ load_enum(section, keys.shift);\ @@ -402,13 +402,13 @@ inline constinit struct Settings { load_enum(commands, copy_color_fmt); load_enum(commands, copy_coord_fmt); -#undef load_drag -#undef load_zoom -#undef load_color -#undef load_enum -#undef load_bool -#undef load_int -#undef load_gen + #undef load_drag + #undef load_zoom + #undef load_color + #undef load_enum + #undef load_bool + #undef load_int + #undef load_gen } // saving to .ini file. @@ -420,16 +420,16 @@ inline constinit struct Settings { ::WritePrivateProfileStringA(section, key, buf, ini_file); }; -#define save_gen(section, tgt, write, col) save_raw(static_cast(write(section.tgt)), #section, #tgt, col) -#define save_dec(section, tgt) save_gen(section, tgt, /* id */, false) -#define save_color(section, tgt) save_gen(section, tgt, [](auto y) { return y.to_formattable(); }, true) -#define save_bool(section, tgt) ::WritePrivateProfileStringA(#section, #tgt, section.tgt ? "1" : "0", ini_file) -#define save_zoom(section, header) \ + #define save_gen(section, tgt, write, col) save_raw(static_cast(write(section.tgt)), #section, #tgt, col) + #define save_dec(section, tgt) save_gen(section, tgt, /* id */, false) + #define save_color(section, tgt) save_gen(section, tgt, [](auto y) { return y.to_formattable(); }, true) + #define save_bool(section, tgt) ::WritePrivateProfileStringA(#section, #tgt, section.tgt ? "1" : "0", ini_file) + #define save_zoom(section, header) \ save_bool(section, header##enabled);\ save_bool(section, header##reversed);\ save_dec(section, header##num_steps);\ save_dec(section, header##pivot) -#define save_drag(section) \ + #define save_drag(section) \ save_dec(section, keys.button);\ save_dec(section, keys.ctrl);\ save_dec(section, keys.shift);\ @@ -531,11 +531,11 @@ inline constinit struct Settings { // lines commented out are setting items that threre're no means to change at runtime. (all cleared now.) -#undef save_drag -#undef save_zoom -#undef save_bool -#undef save_color -#undef save_dec -#undef save_gen + #undef save_drag + #undef save_zoom + #undef save_bool + #undef save_color + #undef save_dec + #undef save_gen } } settings;