Skip to content

Commit 7762b9c

Browse files
committed
カーブの仕様を変更
1 parent d61020f commit 7762b9c

26 files changed

+1474
-1172
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ AviUtlを起動後、メインウィンドウの「表示」メニューから
4242
エディタパネルに表示されているグラフは、マウスの中央ボタンを押してドラッグすることで移動することができ、マウスホイールを回転または`Ctrl`キーを押しながら中央ボタンを押してドラッグすることで縮尺を変更することができます。
4343

4444
また、`Shift``Ctrl``Alt`のキーを押しながらハンドルをドラッグすると次のような操作をすることができます。(現在Valueモードのみ)
45+
この辺りの仕様はFlowとほぼ同じです。
46+
4547
| `Shift` | `Alt` | `Ctrl` | `Shift`+`Ctrl` |
4648
| :---: | :---: | :---: | :---: |
4749
| 制御点をグラフ上下の辺にスナップ | ハンドルの角度を固定 | ハンドルの長さを固定 | 2つの制御点を同時に動かす |

curve_editor/ce_bitmap_buffer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void ce::Bitmap_Buffer::init(HWND hw)
2626
//---------------------------------------------------------------------
2727
// 終了
2828
//---------------------------------------------------------------------
29-
void ce::Bitmap_Buffer::exit()
29+
void ce::Bitmap_Buffer::exit() const
3030
{
3131
DeleteDC(hdc_memory);
3232
DeleteObject(bitmap);
@@ -37,11 +37,11 @@ void ce::Bitmap_Buffer::exit()
3737
//---------------------------------------------------------------------
3838
// ビットマップをバッファから画面に転送
3939
//---------------------------------------------------------------------
40-
void ce::Bitmap_Buffer::transfer(LPRECT rect)
40+
void ce::Bitmap_Buffer::transfer(const RECT& rect) const
4141
{
4242
PAINTSTRUCT ps;
4343
HDC hdc = BeginPaint(hwnd, &ps);
44-
BitBlt(hdc, 0, 0, rect->right, rect->bottom, hdc_memory, 0, 0, SRCCOPY);
44+
BitBlt(hdc, 0, 0, rect.right, rect.bottom, hdc_memory, 0, 0, SRCCOPY);
4545
EndPaint(hwnd, &ps);
4646
DeleteDC(hdc);
4747
}

curve_editor/ce_classes.hpp

Lines changed: 58 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -28,45 +28,37 @@ namespace ce {
2828

2929

3030
//---------------------------------------------------------------------
31-
// カーブ(Valueモード)
31+
// カーブ
3232
//---------------------------------------------------------------------
33-
class Curve_Value {
33+
class Curve {
34+
private:
35+
void set_handle_position(const Point_Address& pt_address, const POINT& pt_graph, double length, bool use_angle, double angle);
36+
void correct_handle(const Point_Address& pt_address, double angle);
37+
double get_handle_angle(const Point_Address& pt_address);
38+
void set_handle_angle(const Point_Address& pt_address, double angle, bool use_length, double lgth);
39+
3440
public:
35-
POINT ctpt[2];
41+
ce::Static_Array<Curve_Points, CE_POINT_MAX> ctpts;
42+
Mode mode;
3643

37-
Curve_Value() { init(); }
44+
// 共通
45+
void initialize();
46+
void initialize(Mode md);
47+
void clear();
48+
void pt_in_ctpt(const POINT& pt_client, Point_Address* pt_address);
49+
void reverse_curve();
3850

39-
void init();
40-
int point_in_ctpts(POINT cl_pt);
41-
void move_point(int index, POINT gr_pt);
51+
// Valueモード用
4252
int create_value_1d();
4353
std::string create_value_4d();
4454
void read_value_1d(int value);
45-
};
46-
47-
4855

49-
//---------------------------------------------------------------------
50-
// カーブ(IDモード)
51-
//---------------------------------------------------------------------
52-
class Curve_ID {
53-
public:
54-
ce::Static_Array<Points_ID, CE_POINT_MAX> ctpts;
55-
56-
Curve_ID() { init(); }
57-
58-
void init();
59-
void add_point(POINT cl_pt);
60-
void delete_point(POINT cl_pt);
61-
void clear();
62-
POINT get_point(Point_Address address);
63-
void move_point(Point_Address address, POINT gr_pt, BOOL reset);
64-
Point_Address pt_in_ctpt(POINT cl_pt);
65-
double get_handle_angle(Point_Address address);
66-
void correct_handle(Point_Address address, double angle);
67-
void set_handle_angle(Point_Address address, double angle, BOOL bLength, double lgth);
68-
void reverse_curve();
69-
double get_value(double ratio, double st, double ed);
56+
// IDモード用
57+
void add_point(const POINT& pt_client);
58+
void delete_point(const POINT& pt_client);
59+
void move_point(int index, const POINT& pt_graph, bool init);
60+
void move_handle(const Point_Address& pt_address, const POINT& pt_graph, bool init);
61+
double id_create_result(double ratio, double st, double ed);
7062
};
7163

7264

@@ -82,8 +74,8 @@ namespace ce {
8274
HDC hdc_memory;
8375

8476
void init(HWND hw);
85-
void exit();
86-
void transfer(LPRECT rect);
77+
void exit() const;
78+
void transfer(const RECT& rect) const;
8779
};
8880

8981

@@ -98,12 +90,12 @@ namespace ce {
9890
public:
9991
HWND hwnd;
10092

101-
virtual BOOL create(HWND hwnd_parent, LPTSTR class_name, WNDPROC wndproc, LONG style, LPRECT rect);
102-
virtual void move(LPRECT rect);
103-
void redraw();
104-
BOOL close();
105-
BOOL show();
106-
BOOL hide();
93+
virtual BOOL create(HWND hwnd_parent, LPTSTR class_name, WNDPROC wndproc, LONG style, const RECT& rect);
94+
virtual void move(const RECT& rect) const;
95+
void redraw() const;
96+
BOOL close() const;
97+
BOOL show() const;
98+
BOOL hide() const;
10799
virtual LRESULT wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
108100
};
109101

@@ -116,23 +108,17 @@ namespace ce {
116108
public:
117109
HWND hwnd;
118110
LPTSTR name;
119-
Curve_Value curve_value;
120-
Curve_ID curve_id;
111+
Curve curve;
121112
time_t unix_time;
122-
const int val_or_id, def_or_user;
123-
int index;
113+
const int val_or_id;
124114

125-
Preset(int v_i, Curve_Value c_value, Curve_ID c_id, LPTSTR n, int d_u) : name(n), val_or_id(v_i), def_or_user(d_u)
115+
Preset(int v_i, Curve cv, LPTSTR n) : name(n), curve(cv), val_or_id(v_i)
126116
{
127-
if (v_i == 1)
128-
curve_id = c_id;
129-
else
130-
curve_value = c_value;
131-
time(&unix_time);
117+
::time(&unix_time);
132118
}
133119

134120
BOOL create(HWND hwnd_parent);
135-
void move(int width);
121+
void move(int panel_width, int index);
136122
LRESULT wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
137123
};
138124

@@ -160,8 +146,8 @@ namespace ce {
160146
int edge_flag;
161147
ID2D1SolidColorBrush* brush;
162148

163-
void draw(COLORREF bg, LPRECT rect_wnd, LPTSTR content);
164-
void set_font(LPRECT rect_wnd, LPTSTR font_name);
149+
void draw(COLORREF bg, RECT& rect_wnd, LPTSTR content);
150+
void set_font(const RECT& rect_wnd, LPTSTR font_name);
165151

166152
public:
167153
int id;
@@ -175,7 +161,7 @@ namespace ce {
175161
LPTSTR ico_res_light,
176162
LPTSTR lb,
177163
int ct_id,
178-
LPRECT rect,
164+
const RECT& rect,
179165
int flag
180166
);
181167
virtual LRESULT wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
@@ -230,12 +216,12 @@ namespace ce {
230216
public:
231217
RECT rect;
232218

233-
void set(RECT rc);
234-
void set(int left, int top, int right, int bottom);
235-
void set_margin(int left, int top, int right, int bottom);
236-
void divide(LPRECT* rects_child, float* weights, int n);
237-
void client_to_screen(HWND hwnd);
238-
void screen_to_client(HWND hwnd);
219+
void set(const RECT& rc);
220+
void set(int left, int top, int right, int bottom);
221+
void set_margin(int left, int top, int right, int bottom);
222+
void divide(LPRECT rects_child[], float weights[], int n) const;
223+
void client_to_screen(HWND hwnd);
224+
void screen_to_client(HWND hwnd);
239225
};
240226

241227

@@ -255,13 +241,13 @@ namespace ce {
255241
// オブジェクト設定ダイアログのクライアント座標
256242
Rectangle rect_button;
257243

258-
void init(HWND hwnd) { hwnd_obj = hwnd; }
259-
BOOL is_hovered() { return id >= 0; }
244+
void init(HWND hwnd) { hwnd_obj = hwnd; }
245+
BOOL is_hovered() const { return id >= 0; }
260246

261-
int update(POINT pt_sc, LPRECT old_rect);
262-
void click();
263-
void highlight();
264-
void invalidate(LPRECT rect);
247+
int update(LPPOINT pt_sc, LPRECT old_rect);
248+
void click();
249+
void highlight() const;
250+
void invalidate(const LPRECT rect) const;
265251
};
266252

267253

@@ -274,18 +260,18 @@ namespace ce {
274260
Float_Point origin;
275261
Double_Point scale;
276262

277-
void fit(LPRECT rect)
263+
void fit(const RECT& rect)
278264
{
279265
origin.x = CE_GR_PADDING;
280-
scale.x = ((double)rect->right - (int)(2 * CE_GR_PADDING)) / (double)CE_GR_RESOLUTION;
266+
scale.x = ((double)rect.right - (int)(2 * CE_GR_PADDING)) / (double)CE_GR_RESOLUTION;
281267

282-
if (rect->right <= rect->bottom) {
283-
origin.y = (rect->bottom + rect->right) * 0.5f - CE_GR_PADDING;
268+
if (rect.right <= rect.bottom) {
269+
origin.y = (rect.bottom + rect.right) * 0.5f - CE_GR_PADDING;
284270
scale.y = scale.x;
285271
}
286-
else if (rect->bottom > CE_GR_PADDING * 2 + CE_GR_RESOLUTION * CE_GR_SCALE_MIN) {
287-
origin.y = (float)(rect->bottom - CE_GR_PADDING);
288-
scale.y = ((double)rect->bottom - (int)(2 * CE_GR_PADDING)) / (double)CE_GR_RESOLUTION;
272+
else if (rect.bottom > CE_GR_PADDING * 2 + CE_GR_RESOLUTION * CE_GR_SCALE_MIN) {
273+
origin.y = (float)(rect.bottom - CE_GR_PADDING);
274+
scale.y = ((double)rect.bottom - (int)(2 * CE_GR_PADDING)) / (double)CE_GR_RESOLUTION;
289275
}
290276
}
291277
};

curve_editor/ce_control.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//---------------------------------------------------------------------
1212
// コントロールを作成
1313
//---------------------------------------------------------------------
14-
BOOL ce::Button::create(HWND hwnd_p, LPTSTR name, LPTSTR desc, int ic_or_str, LPTSTR ico_res_dark, LPTSTR ico_res_light, LPTSTR lb, int ct_id, LPRECT rect, int flag)
14+
BOOL ce::Button::create(HWND hwnd_p, LPTSTR name, LPTSTR desc, int ic_or_str, LPTSTR ico_res_dark, LPTSTR ico_res_light, LPTSTR lb, int ct_id, const RECT& rect, int flag)
1515
{
1616
WNDCLASSEX tmp;
1717
id = ct_id;
@@ -49,9 +49,9 @@ BOOL ce::Button::create(HWND hwnd_p, LPTSTR name, LPTSTR desc, int ic_or_str, LP
4949
name,
5050
NULL,
5151
WS_CHILD | WS_VISIBLE,
52-
rect->left, rect->top,
53-
rect->right - rect->left,
54-
rect->bottom - rect->top,
52+
rect.left, rect.top,
53+
rect.right - rect.left,
54+
rect.bottom - rect.top,
5555
hwnd_p,
5656
NULL,
5757
g_fp->dll_hinst,
@@ -68,9 +68,9 @@ BOOL ce::Button::create(HWND hwnd_p, LPTSTR name, LPTSTR desc, int ic_or_str, LP
6868
//---------------------------------------------------------------------
6969
// コントロール描画用の関数
7070
//---------------------------------------------------------------------
71-
void ce::Button::draw(COLORREF bg, LPRECT rect_wnd, LPTSTR content)
71+
void ce::Button::draw(COLORREF bg, RECT& rect_wnd, LPTSTR content)
7272
{
73-
d2d_setup(&bitmap_buffer, rect_wnd, TO_BGR(bg));
73+
d2d_setup(bitmap_buffer, rect_wnd, TO_BGR(bg));
7474

7575
::SetBkColor(bitmap_buffer.hdc_memory, bg);
7676

@@ -81,7 +81,7 @@ void ce::Button::draw(COLORREF bg, LPRECT rect_wnd, LPTSTR content)
8181
bitmap_buffer.hdc_memory,
8282
content,
8383
strlen(content),
84-
rect_wnd,
84+
&rect_wnd,
8585
DT_CENTER | DT_VCENTER | DT_NOCLIP | DT_SINGLELINE
8686
);
8787
::DeleteObject(font);
@@ -90,8 +90,8 @@ void ce::Button::draw(COLORREF bg, LPRECT rect_wnd, LPTSTR content)
9090
else {
9191
::DrawIcon(
9292
bitmap_buffer.hdc_memory,
93-
(rect_wnd->right - CE_ICON_SIZE) / 2,
94-
(rect_wnd->bottom - CE_ICON_SIZE) / 2,
93+
(rect_wnd.right - CE_ICON_SIZE) / 2,
94+
(rect_wnd.bottom - CE_ICON_SIZE) / 2,
9595
g_config.theme ? icon_light : icon_dark
9696
);
9797
}
@@ -187,7 +187,7 @@ LRESULT ce::Button::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
187187

188188
::SetTextColor(bitmap_buffer.hdc_memory, g_theme[g_config.theme].bt_tx);
189189

190-
draw(bg, &rect_wnd, label);
190+
draw(bg, rect_wnd, label);
191191
return 0;
192192
}
193193

@@ -278,7 +278,7 @@ LRESULT ce::Button_Switch::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lp
278278
::SetTextColor(bitmap_buffer.hdc_memory, g_theme[g_config.theme].bt_tx);
279279
}
280280

281-
draw(bg, &rect_wnd, label);
281+
draw(bg, rect_wnd, label);
282282
return 0;
283283
}
284284

@@ -336,7 +336,7 @@ LRESULT ce::Button_Value::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
336336

337337
::SetTextColor(bitmap_buffer.hdc_memory, g_theme[g_config.theme].bt_tx);
338338

339-
draw(bg, &rect_wnd, value_4d);
339+
draw(bg, rect_wnd, value_4d);
340340
return 0;
341341
}
342342

@@ -353,7 +353,7 @@ LRESULT ce::Button_Value::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpa
353353
LRESULT ce::Button_ID::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
354354
{
355355
RECT rect_wnd;
356-
POINT cl_pt = { GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam) };
356+
POINT pt_client = { GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam) };
357357

358358
::GetClientRect(hwnd, &rect_wnd);
359359

@@ -373,13 +373,13 @@ LRESULT ce::Button_ID::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam
373373

374374
::SetTextColor(bitmap_buffer.hdc_memory, g_theme[g_config.theme].bt_tx);
375375

376-
draw(bg, &rect_wnd, id_text);
376+
draw(bg, rect_wnd, id_text);
377377
return 0;
378378
}
379379

380380
// 左クリックがされたとき
381381
case WM_LBUTTONDOWN:
382-
pt_lock = cl_pt;
382+
pt_lock = pt_client;
383383
id_buffer = g_config.current_id;
384384
::SetCursor(LoadCursor(NULL, IDC_HAND));
385385

@@ -395,10 +395,10 @@ LRESULT ce::Button_ID::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam
395395

396396
// カーソルが動いたとき
397397
case WM_MOUSEMOVE:
398-
if (clicked && g_config.mode == ce::Config::ID) {
398+
if (clicked && g_config.mode == ce::Mode_ID) {
399399
is_scrolling = TRUE;
400400
::SetCursor(LoadCursor(NULL, IDC_SIZEWE));
401-
g_config.current_id = MINMAXLIM(id_buffer + (cl_pt.x - pt_lock.x) / coef_move, 0, CE_CURVE_MAX - 1);
401+
g_config.current_id = MINMAXLIM(id_buffer + (pt_client.x - pt_lock.x) / coef_move, 0, CE_CURVE_MAX - 1);
402402
g_curve_id_previous = g_curve_id[g_config.current_id];
403403
::SendMessage(g_window_editor.hwnd, WM_COMMAND, CE_CM_REDRAW, 0);
404404
}
@@ -410,7 +410,7 @@ LRESULT ce::Button_ID::wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam
410410
return 0;
411411

412412
case WM_LBUTTONUP:
413-
if (!is_scrolling && clicked && g_config.mode == ce::Config::ID) {
413+
if (!is_scrolling && clicked && g_config.mode == ce::Mode_ID) {
414414
::DialogBox(g_fp->dll_hinst, MAKEINTRESOURCE(IDD_ID), hwnd, dialogproc_id);
415415
}
416416
is_scrolling = FALSE;

0 commit comments

Comments
 (0)