Skip to content

Commit 958752e

Browse files
committed
エディタのwebviewをグローバルで管理するようにした
1 parent 47f1e42 commit 958752e

15 files changed

+46
-74
lines changed

curve_editor/dialog_curve_code.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace cved {
4848
if (std::regex_match(buffer, regex_code)) {
4949
try {
5050
if (p_curve->decode(std::stoi(buffer))) {
51-
::SendMessageA(global::fp->hwnd, WM_COMMAND, (WPARAM)WindowCommand::UpdateHandlePos, NULL);
51+
global::webview_main.post_message(L"editor-graph", L"updateHandlePos");
5252
::EndDialog(hwnd, 1);
5353
break;
5454
}

curve_editor/dialog_modifier.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ namespace cved {
122122
case IDCANCEL:
123123
// モディファイアの状態を編集前に戻す
124124
p_curve->set_modifiers(modifiers_prev);
125-
//global::window_grapheditor.redraw();
125+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
126126
::EndDialog(hwnd, IDCANCEL);
127127
return TRUE;
128128

@@ -155,7 +155,7 @@ namespace cved {
155155
update_list(p_curve);
156156
::SendMessageA(hwnd_list_modifier_, LB_SETCURSEL, ::SendMessageA(hwnd_list_modifier_, LB_GETCOUNT, NULL, NULL) - 1, NULL);
157157
update_buttons(p_curve);
158-
//global::window_grapheditor.redraw();
158+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
159159
}
160160
return TRUE;
161161
}
@@ -202,7 +202,7 @@ namespace cved {
202202
p_curve->remove_modifier(idx);
203203
update_list(p_curve);
204204
update_buttons(p_curve);
205-
//global::window_grapheditor.redraw();
205+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
206206
}
207207
}
208208
return TRUE;
@@ -215,7 +215,7 @@ namespace cved {
215215
auto p_modifier = p_curve->get_modifier(idx);
216216
if (p_modifier) {
217217
p_modifier->set_enabled(::SendMessageA(hwnd_check_bypass_, BM_GETCHECK, NULL, NULL) == BST_UNCHECKED);
218-
//global::window_grapheditor.redraw();
218+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
219219
}
220220
}
221221
return TRUE;

curve_editor/dialog_modifier_discretization.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ namespace cved {
4646
p_mod_discretization->set_sampling_resolution((uint32_t)value);
4747
}
4848
::SetWindowTextA(hwnd_static_sampling_, std::to_string(value).c_str());
49-
//global::window_grapheditor.redraw();
49+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
5050
}
5151
else if (lparam == (LPARAM)hwnd_slider_quantization_) {
5252
int value = (int)::SendMessageA(hwnd_slider_quantization_, TBM_GETPOS, NULL, NULL);
5353
if (p_mod_discretization) {
5454
p_mod_discretization->set_quantization_resolution((uint32_t)value);
5555
}
5656
::SetWindowTextA(hwnd_static_quantization_, std::to_string(value).c_str());
57-
//global::window_grapheditor.redraw();
57+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
5858
}
5959
return TRUE;
6060

@@ -67,7 +67,7 @@ namespace cved {
6767
case IDCANCEL:
6868
if (p_mod_discretization) {
6969
*p_mod_discretization = mod_discretization_prev;
70-
//global::window_grapheditor.redraw();
70+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
7171
}
7272
::EndDialog(hwnd, IDCANCEL);
7373
return TRUE;

curve_editor/dialog_modifier_noise.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace cved {
6666
p_mod_noise->set_amplitude(value);
6767
}
6868
::SetWindowTextA(hwnd_static_amplitude_, std::format("{:.2f}", value).c_str());
69-
//global::window_grapheditor.redraw();
69+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
7070
}
7171
else if (lparam == (LPARAM)hwnd_slider_frequency_) {
7272
double value = static_cast<double>(::SendMessageA(hwnd_slider_frequency_, TBM_GETPOS, NULL, NULL)) * 0.1;
@@ -75,15 +75,15 @@ namespace cved {
7575
p_mod_noise->update();
7676
}
7777
::SetWindowTextA(hwnd_static_frequency_, std::format("{:.1f}", value).c_str());
78-
//global::window_grapheditor.redraw();
78+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
7979
}
8080
else if (lparam == (LPARAM)hwnd_slider_phase_) {
8181
double value = static_cast<double>(::SendMessageA(hwnd_slider_phase_, TBM_GETPOS, NULL, NULL) - 1000) * 0.01;
8282
if (p_mod_noise) {
8383
p_mod_noise->set_phase(value);
8484
}
8585
::SetWindowTextA(hwnd_static_phase_, std::format("{:.2f}", value).c_str());
86-
//global::window_grapheditor.redraw();
86+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
8787
}
8888
else if (lparam == (LPARAM)hwnd_slider_octaves_) {
8989
int32_t value = ::SendMessageA(hwnd_slider_octaves_, TBM_GETPOS, NULL, NULL);
@@ -92,15 +92,15 @@ namespace cved {
9292
p_mod_noise->update();
9393
}
9494
::SetWindowTextA(hwnd_static_octaves_, std::to_string(value).c_str());
95-
//global::window_grapheditor.redraw();
95+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
9696
}
9797
else if (lparam == (LPARAM)hwnd_slider_decay_sharpness_) {
9898
double value = static_cast<double>(::SendMessageA(hwnd_slider_decay_sharpness_, TBM_GETPOS, NULL, NULL)) * 0.1;
9999
if (p_mod_noise) {
100100
p_mod_noise->set_decay_sharpness(value);
101101
}
102102
::SetWindowTextA(hwnd_static_decay_sharpness_, std::format("{:.1f}", value).c_str());
103-
//global::window_grapheditor.redraw();
103+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
104104
}
105105
return TRUE;
106106

@@ -109,7 +109,7 @@ namespace cved {
109109
case IDCANCEL:
110110
if (p_mod_noise) {
111111
*p_mod_noise = mod_noise_prev;
112-
//global::window_grapheditor.redraw();
112+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
113113
}
114114
[[fallthrough]];
115115
case IDOK:
@@ -129,7 +129,7 @@ namespace cved {
129129
catch (std::invalid_argument&) {}
130130
catch (std::out_of_range&) {}
131131
}
132-
//global::window_grapheditor.redraw();
132+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
133133
}
134134
return TRUE;
135135
}

curve_editor/dialog_modifier_sine_wave.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "dialog_modifier_sine_wave.hpp"
2+
#include "global.hpp"
23
#include "resource.h"
34
#include <Commctrl.h>
45
#include <format>
@@ -51,23 +52,23 @@ namespace cved {
5152
p_mod_sinewave->set_amplitude(value);
5253
}
5354
::SetWindowTextA(hwnd_static_amplitude_, std::format("{:.2f}", value).c_str());
54-
//global::window_grapheditor.redraw();
55+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
5556
}
5657
else if (lparam == (LPARAM)hwnd_slider_frequency_) {
5758
double value = static_cast<double>(::SendMessageA(hwnd_slider_frequency_, TBM_GETPOS, NULL, NULL)) * 0.1;
5859
if (p_mod_sinewave) {
5960
p_mod_sinewave->set_frequency(value);
6061
}
6162
::SetWindowTextA(hwnd_static_frequency_, std::format("{:.1f}", value).c_str());
62-
//global::window_grapheditor.redraw();
63+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
6364
}
6465
else if (lparam == (LPARAM)hwnd_slider_phase_) {
6566
double value = static_cast<double>(::SendMessageA(hwnd_slider_phase_, TBM_GETPOS, NULL, NULL) - 1000) * 0.01;
6667
if (p_mod_sinewave) {
6768
p_mod_sinewave->set_phase(value);
6869
}
6970
::SetWindowTextA(hwnd_static_phase_, std::format("{:.2f}", value).c_str());
70-
//global::window_grapheditor.redraw();
71+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
7172
}
7273
return TRUE;
7374

@@ -76,6 +77,7 @@ namespace cved {
7677
case IDCANCEL:
7778
if (p_mod_sinewave) {
7879
*p_mod_sinewave = mod_sinewave_prev;
80+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
7981
}
8082
[[fallthrough]];
8183
case IDOK:

curve_editor/dialog_modifier_square_wave.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "dialog_modifier_square_wave.hpp"
2+
#include "global.hpp"
23
#include "resource.h"
34
#include <Commctrl.h>
45
#include <format>
@@ -51,23 +52,23 @@ namespace cved {
5152
p_mod_square_wave->set_amplitude(value);
5253
}
5354
::SetWindowTextA(hwnd_static_amplitude_, std::format("{:.2f}", value).c_str());
54-
//global::window_grapheditor.redraw();
55+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
5556
}
5657
else if (lparam == (LPARAM)hwnd_slider_frequency_) {
5758
double value = static_cast<double>(::SendMessageA(hwnd_slider_frequency_, TBM_GETPOS, NULL, NULL)) * 0.1;
5859
if (p_mod_square_wave) {
5960
p_mod_square_wave->set_frequency(value);
6061
}
6162
::SetWindowTextA(hwnd_static_frequency_, std::format("{:.1f}", value).c_str());
62-
//global::window_grapheditor.redraw();
63+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
6364
}
6465
else if (lparam == (LPARAM)hwnd_slider_phase_) {
6566
double value = static_cast<double>(::SendMessageA(hwnd_slider_phase_, TBM_GETPOS, NULL, NULL) - 1000) * 0.01;
6667
if (p_mod_square_wave) {
6768
p_mod_square_wave->set_phase(value);
6869
}
6970
::SetWindowTextA(hwnd_static_phase_, std::format("{:.2f}", value).c_str());
70-
//global::window_grapheditor.redraw();
71+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
7172
}
7273
return TRUE;
7374

@@ -76,6 +77,7 @@ namespace cved {
7677
case IDCANCEL:
7778
if (p_mod_square_wave) {
7879
*p_mod_square_wave = mod_square_wave_prev;
80+
global::webview_main.post_message(L"editor-graph", L"updateCurvePath");
7981
}
8082
[[fallthrough]];
8183
case IDOK:

curve_editor/dialog_pref.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ namespace cved {
100100
::SendMessageA(category.hwnd, WM_COMMAND, (WPARAM)WindowCommand::SaveConfig, NULL);
101101
}
102102
global::config.save_json();
103-
::SendMessageA(global::fp->hwnd, WM_COMMAND, (WPARAM)WindowCommand::ApplyPreferences, NULL);
103+
global::webview_main.post_message(L"editor-graph", L"applyPreferences");
104104
}
105105

106106

curve_editor/dialog_pref_appearance.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ namespace cved {
171171
::GetWindowTextA(hwnd_edit_bg_image_path_, buffer, MAX_PATH);
172172
global::config.set_bg_image_path(std::filesystem::path(buffer));
173173
}
174+
global::webview_main.update_color_scheme();
174175
return TRUE;
175176

176177
case IDC_BUTTON_CURVE_COLOR:

curve_editor/enum.hpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,7 @@ namespace cved {
4848
MovePreset = 0x0b15,
4949
LoadConfig = 0x0b18,
5050
SaveConfig = 0x0b19,
51-
Reload = 0x0b1e,
52-
StartDnd = 0x0b1f,
53-
UpdateColorScheme = 0x0b20,
54-
UpdateHandlePos = 0x0b21,
55-
UpdateAxisLabelVisibility = 0x0b22,
56-
UpdateHandleVisibility = 0x0b23,
57-
ApplyPreferences = 0x0b24,
58-
UpdateHandles = 0x0b25
51+
StartDnd = 0x0b1f
5952
};
6053

6154
enum class ThemeId {

curve_editor/filter_wndproc.cpp

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ namespace cved {
2121
using StringId = global::StringTable::StringId;
2222

2323
static ActCtxHelper actctx_helper;
24-
static MyWebView2 my_webview;
2524
static DragAndDrop dnd;
2625
static bool init = false;
2726

@@ -48,25 +47,25 @@ namespace cved {
4847
if (fp->exfunc->is_filter_window_disp(fp) and !init) {
4948
actctx_helper.init(fp->dll_hinst);
5049
init = true;
51-
my_webview.init(hwnd, [](MyWebView2* this_) {
50+
global::webview_main.init(hwnd, [](MyWebView2* this_) {
5251
mkaul::WindowRectangle bounds;
5352
bounds.from_client_rect(this_->get_hwnd());
5453
this_->put_bounds(bounds);
5554
this_->navigate(L"panel_main");
56-
});
55+
});
5756
}
5857
break;
5958

6059
case WM_SIZE:
6160
{
6261
mkaul::WindowRectangle bounds;
6362
bounds.from_client_rect(hwnd);
64-
my_webview.put_bounds(bounds);
63+
global::webview_main.put_bounds(bounds);
6564
break;
6665
}
6766

6867
case WM_MOVE:
69-
my_webview.on_move();
68+
global::webview_main.on_move();
7069
break;
7170

7271
case WM_MOUSEMOVE:
@@ -79,7 +78,7 @@ namespace cved {
7978
if (dnd.is_dragging()) {
8079
::ReleaseCapture();
8180
dnd.drop();
82-
my_webview.execute_script(L"onDrop();");
81+
global::webview_main.execute_script(L"onDrop();");
8382
}
8483
break;
8584

@@ -88,36 +87,11 @@ namespace cved {
8887
case WindowCommand::RedrawAviutl:
8988
return TRUE;
9089

91-
case WindowCommand::Reload:
92-
my_webview.reload();
93-
break;
94-
9590
case WindowCommand::StartDnd:
9691
::SetCapture(hwnd);
9792
::SetCursor(::LoadCursorA(fp->dll_hinst, MAKEINTRESOURCEA(IDC_DRAG)));
9893
dnd.drag();
9994
break;
100-
101-
case WindowCommand::UpdateHandles:
102-
my_webview.post_message(L"editor-graph", L"updateHandles");
103-
break;
104-
105-
case WindowCommand::UpdateHandlePos:
106-
my_webview.post_message(L"editor-graph", L"updateHandlePos");
107-
break;
108-
109-
case WindowCommand::UpdateAxisLabelVisibility:
110-
my_webview.post_message(L"editor-graph", L"updateAxisLabelVisibility");
111-
break;
112-
113-
case WindowCommand::UpdateHandleVisibility:
114-
my_webview.post_message(L"editor-graph", L"updateHandleVisibility");
115-
break;
116-
117-
case WindowCommand::ApplyPreferences:
118-
my_webview.update_color_scheme();
119-
my_webview.post_message(L"editor-graph", L"applyPreferences");
120-
break;
12195
}
12296
break;
12397
}

0 commit comments

Comments
 (0)