Skip to content

Commit f054917

Browse files
committed
ポイントが範囲外にも置けるバグを修正
1 parent 57bc4de commit f054917

16 files changed

+77
-38
lines changed

curve_editor/ce_classes.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,20 @@ namespace ce {
161161
//---------------------------------------------------------------------
162162
class Control {
163163
private:
164-
int icon;
164+
LPTSTR icon_res;
165165
Bitmap_Canvas canvas;
166166
HWND hwnd_parent;
167167
BOOL hovered, clicked;
168168
TRACKMOUSEEVENT tme;
169+
HICON icon;
169170

170171
static LRESULT CALLBACK wndproc_static(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
171172

172173
public:
173174
HWND hwnd;
174175
int id;
175176

176-
BOOL create(HWND hwnd_p, LPSTR name, int ico, int ct_id, LPRECT rect);
177+
BOOL create(HWND hwnd_p, LPSTR name, LPTSTR ico_res, int ct_id, LPRECT rect);
177178
void move(LPRECT rect);
178179
virtual LRESULT wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
179180
};

curve_editor/ce_control.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
//---------------------------------------------------------------------
1212
// コントロールを作成
1313
//---------------------------------------------------------------------
14-
BOOL ce::Control::create(HWND hwnd_p, LPSTR name, int ico, int ct_id, LPRECT rect)
14+
BOOL ce::Control::create(HWND hwnd_p, LPSTR name, LPTSTR ico_res, int ct_id, LPRECT rect)
1515
{
1616
WNDCLASSEX tmp;
1717
id = ct_id;
18-
icon = ico;
18+
icon_res = ico_res;
1919

2020
tmp.cbSize = sizeof(tmp);
2121
tmp.style = CS_HREDRAW | CS_VREDRAW;
@@ -96,7 +96,7 @@ LRESULT CALLBACK ce::Control::wndproc_static(HWND hwnd, UINT msg, WPARAM wparam,
9696
//---------------------------------------------------------------------
9797
LRESULT ce::Control::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
9898
{
99-
RECT rect_wnd;
99+
RECT rect_wnd;
100100

101101
GetClientRect(hwnd, &rect_wnd);
102102

@@ -106,6 +106,8 @@ LRESULT ce::Control::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
106106

107107
hwnd_parent = GetParent(hwnd);
108108

109+
110+
109111
tme.cbSize = sizeof(tme);
110112
tme.dwFlags = TME_LEAVE;
111113
tme.hwndTrack = hwnd;
@@ -115,6 +117,7 @@ LRESULT ce::Control::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
115117
canvas.exit();
116118
return 0;
117119

120+
// 描画
118121
case WM_PAINT:
119122
{
120123
COLORREF bg;
@@ -136,36 +139,41 @@ LRESULT ce::Control::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
136139
}
137140

138141
canvas.transfer(&rect_wnd);
142+
return 0;
139143
}
140-
return 0;
141144

145+
// マウスが動いたとき
142146
case WM_MOUSEMOVE:
143147
SetCursor(LoadCursor(NULL, IDC_HAND));
144148
hovered = TRUE;
145149
InvalidateRect(hwnd, NULL, FALSE);
146150
TrackMouseEvent(&tme);
147151
return 0;
148152

153+
// 左クリックがされたとき
149154
case WM_LBUTTONDOWN:
150155
SetCursor(LoadCursor(NULL, IDC_HAND));
151156
clicked = TRUE;
152157
InvalidateRect(hwnd, NULL, FALSE);
153158
TrackMouseEvent(&tme);
154159
return 0;
155160

161+
// 左クリックが終わったとき
156162
case WM_LBUTTONUP:
157163
SetCursor(LoadCursor(NULL, IDC_HAND));
158164
clicked = FALSE;
159165
InvalidateRect(hwnd, NULL, FALSE);
160166
SendMessage(hwnd_parent, WM_COMMAND, id, 0);
161167
return 0;
162168

169+
// マウスがウィンドウから離れたとき
163170
case WM_MOUSELEAVE:
164171
clicked = FALSE;
165172
hovered = FALSE;
166173
InvalidateRect(hwnd, NULL, FALSE);
167174
return 0;
168175

176+
// コマンド
169177
case WM_COMMAND:
170178
switch (wparam) {
171179
case CE_CM_REDRAW:

curve_editor/ce_curve_id.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ void ce::Curve_ID::add_point(POINT gr_pt)
3737
int index = 0;
3838
Point_Address tmp;
3939
if (ctpts.size >= CE_POINT_MAX) return;
40+
if (!ISINRANGE2(gr_pt.x, 0, CE_GR_RESOLUTION)) return;
4041
for (int i = 0; i < (int)ctpts.size; i++) {
4142
if (ctpts[i].pt_center.x == gr_pt.x)
4243
return;
@@ -233,6 +234,7 @@ void ce::Curve_ID::move_point(Point_Address address, POINT gr_pt, BOOL bReset)
233234
}
234235

235236

237+
236238
//---------------------------------------------------------------------
237239
// 指定した座標がポイント・ハンドルの内部に存在しているか
238240
//---------------------------------------------------------------------
@@ -271,6 +273,7 @@ ce::Point_Address ce::Curve_ID::pt_in_ctpt(POINT cl_pt)
271273
}
272274

273275

276+
274277
//---------------------------------------------------------------------
275278
// ハンドルの角度を取得
276279
//---------------------------------------------------------------------
@@ -304,6 +307,7 @@ double ce::Curve_ID::get_handle_angle(Point_Address address)
304307
}
305308

306309

310+
307311
//---------------------------------------------------------------------
308312
// ハンドルの角度を設定
309313
//---------------------------------------------------------------------
@@ -335,6 +339,7 @@ void ce::Curve_ID::set_handle_angle(Point_Address address, double angle, BOOL bL
335339
}
336340

337341

342+
338343
//---------------------------------------------------------------------
339344
// 指定したアドレスのハンドル(右か左)が,前または次の制御点群の中央の点を超えている場合に,
340345
// ハンドルの角度を保ちながら修正する関数
@@ -371,6 +376,7 @@ void ce::Curve_ID::correct_handle(Point_Address address, double angle)
371376
}
372377

373378

379+
374380
//---------------------------------------------------------------------
375381
// カーブを反転
376382
//---------------------------------------------------------------------
@@ -397,6 +403,7 @@ void ce::Curve_ID::reverse_curve()
397403
}
398404

399405

406+
400407
//---------------------------------------------------------------------
401408
// Get Value
402409
//---------------------------------------------------------------------

curve_editor/ce_header.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ce::Float_Point subtract_length(ce::Float_Point st, ce::Float_Point ed, float l
6161
void apply_config_to_menu(HMENU menu, MENUITEMINFO minfo);
6262

6363
// RECTを分割
64-
void divide_rect(LPRECT rect_parent, LPRECT* rects_child, int n);
64+
void divide_rect(LPRECT rect_parent, LPRECT* rects_child, int n);
6565

6666
//子ウィンドウを作成
6767
HWND create_child(

curve_editor/ce_macro.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
#define MINLIM(value,minv) (((value) < (minv))? (minv): (value))
154154
#define MINMAXLIM(value,minv,maxv) (((value) < (minv))? (minv): (((value) > (maxv))? (maxv): (value)))
155155
#define ISINRANGE(value,minv,maxv) (((value) >= (minv))? (((value) <= (maxv))? 1 : 0) : 0)
156+
#define ISINRANGE2(value,minv,maxv) (((value) > (minv))? (((value) < (maxv))? 1 : 0) : 0)
156157
#define ISMORETHAN(value,vl) (((value) >= (vl))? 1 : 0)
157158
#define ISLESSTHAN(value,vl) (((value) <= (vl))? 1 : 0)
158159
#define BRIGHTEN(ref,num) (RGB(MINMAXLIM(GetRValue(ref) + num, 0, 255), MINMAXLIM(GetGValue(ref) + num, 0, 255), MINMAXLIM(GetBValue(ref) + num, 0, 255)))

curve_editor/ce_wndproc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Visual C++ 2022
55
//----------------------------------------------------------------------------------
66

7-
#include "ce_wndproc.hpp"
7+
#include "ce_header.hpp"
88

99

1010

curve_editor/ce_wndproc.hpp

Lines changed: 0 additions & 25 deletions
This file was deleted.

curve_editor/curve_editor.rc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,24 @@ END
235235

236236
IDC_DRAGGING CURSOR "cur_drag.cur"
237237

238+
239+
/////////////////////////////////////////////////////////////////////////////
240+
//
241+
// Icon
242+
//
243+
244+
// Icon with lowest ID value placed first to ensure application icon
245+
// remains consistent on all systems.
246+
IDI_COPY ICON "icon_copy.ico"
247+
248+
IDI_READ ICON "icon_read.ico"
249+
250+
IDI_SAVE ICON "icon_save.ico"
251+
252+
IDI_CLEAR ICON "icon_clear.ico"
253+
254+
IDI_FIT ICON "icon_fit.ico"
255+
238256
#endif // ���{�� (���{) resources
239257
/////////////////////////////////////////////////////////////////////////////
240258

curve_editor/curve_editor.vcxproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ copy $(TargetPath) "C:\Users\njotn\UserDirectory\AviUtl_Plugins&amp;Scripts\Curv
216216
<ClInclude Include="ce_header.hpp" />
217217
<ClInclude Include="ce_macro.hpp" />
218218
<ClInclude Include="ce_structs.hpp" />
219-
<ClInclude Include="ce_wndproc.hpp" />
220219
<ClInclude Include="framework.hpp" />
221220
<ClInclude Include="resource.h" />
222221
</ItemGroup>
@@ -227,6 +226,14 @@ copy $(TargetPath) "C:\Users\njotn\UserDirectory\AviUtl_Plugins&amp;Scripts\Curv
227226
<ItemGroup>
228227
<ResourceCompile Include="curve_editor.rc" />
229228
</ItemGroup>
229+
<ItemGroup>
230+
<Image Include="..\..\..\..\..\OneDrive\画像\icon_copy.png" />
231+
<Image Include="icon_clear.ico" />
232+
<Image Include="icon_copy.ico" />
233+
<Image Include="icon_fit.ico" />
234+
<Image Include="icon_read.ico" />
235+
<Image Include="icon_save.ico" />
236+
</ItemGroup>
230237
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
231238
<ImportGroup Label="ExtensionTargets">
232239
</ImportGroup>

curve_editor/curve_editor.vcxproj.filters

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@
5656
<ClInclude Include="ce_macro.hpp">
5757
<Filter>ヘッダー ファイル</Filter>
5858
</ClInclude>
59-
<ClInclude Include="ce_wndproc.hpp">
60-
<Filter>ヘッダー ファイル</Filter>
61-
</ClInclude>
6259
<ClInclude Include="framework.hpp">
6360
<Filter>ヘッダー ファイル</Filter>
6461
</ClInclude>
@@ -82,4 +79,24 @@
8279
<Filter>リソース ファイル</Filter>
8380
</ResourceCompile>
8481
</ItemGroup>
82+
<ItemGroup>
83+
<Image Include="icon_clear.ico">
84+
<Filter>リソース ファイル</Filter>
85+
</Image>
86+
<Image Include="icon_copy.ico">
87+
<Filter>リソース ファイル</Filter>
88+
</Image>
89+
<Image Include="icon_fit.ico">
90+
<Filter>リソース ファイル</Filter>
91+
</Image>
92+
<Image Include="icon_read.ico">
93+
<Filter>リソース ファイル</Filter>
94+
</Image>
95+
<Image Include="icon_save.ico">
96+
<Filter>リソース ファイル</Filter>
97+
</Image>
98+
<Image Include="..\..\..\..\..\OneDrive\画像\icon_copy.png">
99+
<Filter>リソース ファイル</Filter>
100+
</Image>
101+
</ItemGroup>
85102
</Project>

0 commit comments

Comments
 (0)