• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

JavaScriptを色々あれこれしようとするがひたすら失敗を繰り返している


Commit MetaInfo

Revision32 (tree)
Time2016-11-29 18:45:50
Authortakoyaki_umaaaa

Log Message

・フォーカス表示方法の見直し
・画面表示ループを1ヵ所にまとめた
・アクション適用すると回転状態がキャンセルされる問題の修正
・表示要素をDIV2段構成またはDIV-IMGの2段構成に変更
・マウス入力取得要素から期待する要素まで DOM treeを辿って探すように修正

未対応
・コメントコードの削除
・ファイル保存,読み込み

Change Summary

Incremental Difference

--- HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/css/default.css (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/css/default.css (revision 32)
@@ -51,12 +51,18 @@
5151 }
5252
5353
54+ .DispBase,
5455 .DispObj {
5556 display: inline-block;
56- position:absolute;
57+ position: absolute;
5758 marginj:0; padding:0;
5859 }
60+ .DispObj {
61+ left:0; top:0;
62+ width: 100%; height: 100%;
63+ }
5964
65+
6066 /* パレットグループ要素の定義 */
6167 .palgroup {
6268 display: inline-block;
@@ -106,14 +112,22 @@
106112
107113
108114 /* フォーカス枠と拡大縮小・回転用マーカー定義 */
109- .scaler {
115+ .scaler,
116+ .roller {
117+ position: absolute;
118+ width: 15px; height: 15px;
119+ padding: 0; margin: 0;
110120 border: 2px solid black;
111121 border-radius: 50%;
122+ }
123+ .scaler {
124+ left: 100%; top: 100%;
125+ transform: translateX(-50%) translateY(-50%);
112126 background-color: orange;
113127 }
114128 .roller {
115- border: 2px solid black;
116- border-radius: 50%;
129+ left: 50%; top: 0%;
130+ transform: translateX(-50%) translateY(-50%);
117131 background-color: green;
118132 }
119133
@@ -131,10 +145,37 @@
131145 );
132146 background-size: 8px 8px;
133147 }
134- .focusleft { animation: animForcus1 3s linear infinite; }
135- .focusright { animation: animForcus2 3s linear infinite; }
136- .focustop { animation: animForcus2 3s linear infinite; }
137- .focusbottom { animation: animForcus1 3s linear infinite; }
148+ .focusleft,
149+ .focustop,
150+ .focusright,
151+ .focusbottom{
152+ position: absolute;
153+ padding: 0; margin: 0;
154+ }
155+ .focusleft {
156+ left: 0%; top: 0%;
157+ width: 2px; height: 100%;
158+ transform: translateX(-50%) translateY(0%);
159+ animation: animForcus1 3s linear infinite;
160+ }
161+ .focustop {
162+ left: 0%; top: 0%;
163+ width: 100%; height: 2px;
164+ transform: translateX(0%) translateY(-50%);
165+ animation: animForcus2 3s linear infinite;
166+ }
167+ .focusright {
168+ left: 100%; top: 0%;
169+ width: 2px; height: 100%;
170+ transform: translateX(-50%) translateY(0%);
171+ animation: animForcus2 3s linear infinite;
172+ }
173+ .focusbottom {
174+ left: 0%; top: 100%;
175+ width: 100%; height: 2px;
176+ transform: translateX(0%) translateY(-50%);
177+ animation: animForcus1 3s linear infinite;
178+ }
138179 @keyframes animForcus1 {
139180 0% { background-position:0% 0%}
140181 100% {background-position:100% 100%}
@@ -151,11 +192,6 @@
151192 animation: none;
152193 }
153194
154- #apparea:target img,
155- #apparea:target div {
156- animation: none;
157- background-color:red;
158- }
159195
160196
161197
--- HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/Common.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/Common.js (revision 32)
@@ -4,7 +4,7 @@
44 var DEBUGLOG = true;
55 debuglog = (true==DEBUGLOG)? debugLog : logQuiet;
66
7-function debugLog(str) {
7+function debugLog(str,callerargs) {
88 console.log(str);
99 };
1010 function logQuiet(str) {
@@ -195,14 +195,45 @@
195195 }
196196 }
197197 return null;
198-}
198+};
199199
200200
201201
202202
203+// elementを起点に classNameを持った要素を遡って検索
204+// 見つからなければ nullを返す
205+function findClassNameParent(
206+ className, // 検索対象 CSS class name
207+ element // 検索起点 element
208+) {
209+ let e = element;
210+ if (null != className && null != element) {
211+ let result = false;
212+ do {
213+ result = e.classList.contains(className);
214+ if (true == result) break;
203215
216+ e = e.parent;
217+ } while (null != e);
218+ }
219+ return e;
220+};
204221
205222
223+
224+
225+
226+
227+
228+
229+
230+
231+
232+
233+
234+
235+
236+
206237 // Drop fileから file objectを取得 (同期処理)
207238 // 複数file 非対応。text or image がヒットした時点でcallbackを呼び出す
208239 // callback書式(text,image): function(blob)
@@ -314,3 +345,34 @@
314345 if (null != this.callbackError) this.callbackError(err.message);
315346 };
316347 } // class SaveFile
348+
349+
350+
351+class RenderLoop {
352+ constructor() {
353+ this.renderQue = new Queue();
354+ this.rendering = null; // loop処理呼び出し済み判定用
355+ }
356+
357+
358+ // 描画用callback関数登録要求
359+ // 引数のcallbackを1回呼び出します
360+ // callback: function callback(time)
361+ requestRenderFunc(callback) {
362+ console.log('Request render function = ' + (callback ? callback.name : 'null'));
363+ if (null != callback){
364+ this.renderQue.enqueue(callback);
365+
366+ // 描画loop
367+ (function renderloop(time) {
368+ if (0 < this.renderQue.size()) {
369+ this.renderQue.dequeue()(time);
370+ console.log('render func size=' + this.renderQue.size());
371+ requestAnimationFrame(renderloop.bind(this));
372+ }
373+ }.call(this,window.performance.now()));
374+ }
375+ }
376+}
377+
378+
--- HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/DispObj.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/DispObj.js (revision 32)
@@ -13,23 +13,24 @@
1313 init() {
1414 this.debuglog('init()');
1515 this.ObjID = 0;
16- this.GroupID = 0;
1716 this.type = 0;
1817 this.x = 0.0;
1918 this.y = 0.0;
2019 this.width = 0.0;
2120 this.height = 0.0;
21+ this.originalWidth = 0.0;
22+ this.originalHeight = 0.0;
2223 this.opacity = 1.0;
2324 this.degree = 0;
2425 this.text = null;
2526 this.transformStr = null;
26- this.initDOMobj(); // DOMをクリア
27- this.renderFunc = new Queue();
2827
29- this.originalWidth = 0;
30- this.originalHeight = 0;
28+ // DOMをクリア
29+ this.initDOMobj();
30+// this.renderFunc = new Queue();
3131
32- this.dropinitsize = 100.0;
32+
33+ this.dropinitsize = 100.0; // File dropで作成する Elementの長辺の長さ
3334 }
3435 initDOMobj() {
3536 if (null != this.DOMobject) {
@@ -47,6 +48,7 @@
4748 }
4849
4950
51+
5052 // 操作関数 ------------------------------------
5153
5254 // 破棄
@@ -73,7 +75,7 @@
7375
7476
7577
76-
78+ /*
7779 // ブラウザ上への描画 -------------------------
7880
7981 // コマンド要求実行後の描画共通処理
@@ -84,6 +86,7 @@
8486 renderFunction();
8587 }
8688 }
89+ */
8790
8891 // コマンド実行処理 -----------------------------
8992
@@ -113,14 +116,20 @@
113116 this.originalHeight = this.height;
114117
115118 // 画面に影響しない範囲で作成できるところまで Dom objectを作成する
119+ // DispBase作成
120+ this.DOMbase = document.createElement('div');
121+ this.DOMbase.classList.add('DispBase');
122+ this.DOMbase.dataset.objid = this.ObjID;
123+ this.DOMbase.dataset.degree = 0;
124+ this.DOMbase.addEventListener('mousedown', this.onMouseDown.bind(this), false);
125+ // DispObj作成
116126 let elType = (null != type.match(/imagebox/)) ? 'img' : 'div';
117127 this.DOMobject = document.createElement(elType);
128+ this.DOMbase.appendChild(this.DOMobject); // ひとまず連結
118129 this.DOMobject.classList.add('DispObj');
119130 this.DOMobject.dataset.objid = this.ObjID;
120131 this.DOMobject.dataset.orgwidth = this.originalWidth; // transform: scaleの基準サイズ
121- this.DOMobject.dataset.orgheight = this.originalHeight;
122- this.DOMobject.dataset.degree = 0;
123- this.DOMobject.addEventListener('mousedown', this.onMouseDown.bind(this), false);
132+ this.DOMobject.dataset.orgheight = this.originalHeight; // 画像original sizeなのでこちらで管理
124133 if (null != type.match(/imagebox/)) {
125134 // imageの場合、画像読み込み完了後に描画する必要がある
126135 this.loadImage(opt1);
@@ -131,7 +140,8 @@
131140 }
132141 else {
133142 // 描画呼び出し時に呼び出す関数を登録
134- this.renderFunc.enqueue(this.renderCreate.bind(this));
143+// this.renderFunc.enqueue(this.renderCreate.bind(this));
144+ window.renderLoop.requestRenderFunc(this.renderCreate.bind(this));
135145 }
136146 }
137147 return true;
@@ -143,7 +153,8 @@
143153 reader.onload = function (evt) {
144154 this.text = evt.target.result;
145155 // 描画呼び出し時に呼び出す関数を登録
146- this.renderFunc.enqueue(this.renderCreate.bind(this));
156+// this.renderFunc.enqueue(this.renderCreate.bind(this));
157+ window.renderLoop.requestRenderFunc(this.renderCreate.bind(this));
147158 }.bind(this);
148159 }
149160 loadImage(file) {
@@ -162,9 +173,10 @@
162173 this.originalWidth = this.width;
163174 this.originalHeight = this.height;
164175 this.DOMobject.dataset.orgwidth = this.originalWidth; // transform: scaleの基準サイズ
165- this.DOMobject.dataset.orgheight = this.originalHeight;
176+ this.DOMobject.dataset.orgheight = this.originalHeight; // 画像original sizeなのでこちらで管理
166177 // 表示サイズ取得完了したので画面に表示
167- this.renderFunc.enqueue(this.renderCreate.bind(this));
178+// this.renderFunc.enqueue(this.renderCreate.bind(this));
179+ window.renderLoop.requestRenderFunc(this.renderCreate.bind(this));
168180 }.bind(this);
169181 }.bind(this);
170182 }
@@ -185,27 +197,27 @@
185197 return new rectData(0, 0, destW, destH);
186198 }
187199 renderCreate() {
188-// this.DOMobject.style.position = "absolute"; // DispObj CSS classで指定
189- this.DOMobject.style.left = this.x.toString() + "px";
190- this.DOMobject.style.top = this.y.toString() + "px";
191- this.DOMobject.style.width = this.width.toString() + "px";
192- this.DOMobject.style.height = this.height.toString() + "px";
193200 this.DOMobject.style.border = "1px solid black"; // 指定するI/Fが必要
194201 if (null != this.text) this.DOMobject.innerHTML = this.text;
202+// this.DOMobject.style.position = "absolute"; // DispObj CSS classで指定
195203
196- document.getElementById('DispField').appendChild(this.DOMobject);
204+ this.DOMbase.style.left = this.x.toString() + "px";
205+ this.DOMbase.style.top = this.y.toString() + "px";
206+ this.DOMbase.style.width = this.width.toString() + "px";
207+ this.DOMbase.style.height = this.height.toString() + "px";
208+ document.getElementById('DispField').appendChild(this.DOMbase);
197209
198- this.debuglog("renderCreate() left=" + this.DOMobject.style.left
199- + ", top=" + this.DOMobject.style.top
200- + ", width=" + this.DOMobject.style.width
201- + ", height=" + this.DOMobject.style.height
202- + ", border=" + this.DOMobject.style.border);
210+ this.debuglog("renderCreate() left=" + this.DOMbase.style.left
211+ + ", top=" + this.DOMbase.style.top
212+ + ", width=" + this.DOMbase.style.width
213+ + ", height=" + this.DOMbase.style.height
214+ + ", innerHTML=" + this.DOMobject.innerHTML);
203215 }
204216
205217 createFromElement(ele) {
206218 this.debuglog('createFromElement() ele=' + ele);
207219
208- this.DOMobject = ele;
220+ this.DOMbase = ele;
209221 this.type = (null != ele.nodeName.match(/IMG/)) ? 'imagebox' : 'textbox';
210222 this.x = parseInt(ele.style.left);
211223 this.y = parseInt(ele.style.top);
@@ -215,7 +227,7 @@
215227 this.originalHeight = ele.dataset.orgheight;
216228 this.ObjID = ele.dataset.objid;
217229 this.degree = ele.dataset.degree;
218- this.DOMobject.addEventListener('mousedown', this.onMouseDown.bind(this), false);
230+ this.DOMbase.addEventListener('mousedown', this.onMouseDown.bind(this), false);
219231
220232 // 画像・テキストは既にelementに読み込み済み
221233 // treeにも入っており、更新する必要もないのでこれで完了
@@ -229,20 +241,21 @@
229241 movebox(x, y) {
230242 this.x = x;
231243 this.y = y;
232- this.renderFunc.enqueue(this.rendermove.bind(this));
244+// this.renderFunc.enqueue(this.rendermove.bind(this));
245+ window.renderLoop.requestRenderFunc(this.rendermove.bind(this));
233246
234- this.debuglog("movebox() x=" + this.x + ", y=" + this.y + ", renderFunc size=" + this.renderFunc.size());
247+ this.debuglog("movebox() x=" + this.x + ", y=" + this.y);
235248 }
236249 rendermove() {
237- this.DOMobject.style.left = this.x.toString() + "px";
238- this.DOMobject.style.top = this.y.toString() + "px";
250+ this.DOMbase.style.left = this.x.toString() + "px";
251+ this.DOMbase.style.top = this.y.toString() + "px";
239252 this.DOMobject.style.opacity = this.opacity.toString();
240253
241- this.debuglog("rendermove() left=" + this.DOMobject.style.left
242- + ", top=" + this.DOMobject.style.top
243- + ", width=" + this.DOMobject.style.width
244- + ", height=" + this.DOMobject.style.height
245- + ", border=" + this.DOMobject.style.border);
254+ this.debuglog("rendermove() left=" + this.DOMbase.style.left
255+ + ", top=" + this.DOMbase.style.top
256+ + ", width=" + this.DOMbase.style.width
257+ + ", height=" + this.DOMbase.style.height
258+ + ", opacity=" + this.DOMobject.opacity);
246259 }
247260
248261 scalebox(rect, fontscale) {
@@ -250,14 +263,15 @@
250263 this.y = rect.top;
251264 this.width = rect.right - rect.left;
252265 this.height = rect.bottom - rect.top;
253- this.renderFunc.enqueue(this.renderscalebox.bind(this));
266+// this.renderFunc.enqueue(this.renderscalebox.bind(this));
267+ window.renderLoop.requestRenderFunc(this.renderscalebox.bind(this));
254268 this.fontsize = fontscale;
255269 }
256270 renderscalebox() {
257- this.DOMobject.style.left = this.x.toString() + "px";
258- this.DOMobject.style.top = this.y.toString() + "px";
259- this.DOMobject.style.width = this.width.toString() + "px";
260- this.DOMobject.style.height = this.height.toString() + "px";
271+ this.DOMbase.style.left = this.x.toString() + "px";
272+ this.DOMbase.style.top = this.y.toString() + "px";
273+ this.DOMbase.style.width = this.width.toString() + "px";
274+ this.DOMbase.style.height = this.height.toString() + "px";
261275 this.DOMobject.style.opacity = this.opacity.toString();
262276 this.DOMobject.style.fontSize = this.fontsize + '%';
263277 }
@@ -264,11 +278,12 @@
264278
265279 rollbox(degree) {
266280 this.degree = degree;
267- this.DOMobject.dataset.degree = degree;
268- this.renderFunc.enqueue(this.renderrollbox.bind(this));
281+ this.DOMbase.dataset.degree = degree;
282+// this.renderFunc.enqueue(this.renderrollbox.bind(this));
283+ window.renderLoop.requestRenderFunc(this.renderrollbox.bind(this));
269284 }
270285 renderrollbox() {
271- this.DOMobject.style.transform = 'rotateZ(' + this.degree + 'deg);';
286+ this.DOMbase.style.transform = 'rotateZ(' + this.degree + 'deg);';
272287 }
273288
274289
@@ -288,22 +303,19 @@
288303 return;
289304 }
290305 // Mouse eventをappAreaからScalerに渡してもらうように設定
291- window.appArea.setMouseEventObj(this.mouseMove.bind(this), this.mouseUp.bind(this));
306+ window.appArea.setMouseEventObj('DispBase',this.mouseMove.bind(this), this.mouseUp.bind(this));
292307 evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
293308 evt.preventDefault(); // 要素既定のdefault動作を止める
294309
295-
296- // Focus設定
297- evt.target.dataset.focus = "true";
298310 // 移動元として座標を保持
299311 this.startDragX = evt.pageX;
300312 this.startDragY = evt.pageY;
301313
302314 // Focus表示
303- window.partsFocus.setClingingPartner(this.DOMobject);
315+ window.partsFocus.setClingingPartner(this.DOMbase);
304316
305317 }
306- mouseMove(evt) {
318+ mouseMove(evt, target) {
307319 evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
308320 evt.preventDefault(); // 要素既定のdefault動作を止める
309321
@@ -317,17 +329,18 @@
317329 moveX = this.x + moveX;
318330 moveY = this.y + moveY;
319331
320- this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
332+// this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
333+ window.renderLoop.requestRenderFunc(this.renderMoveDragging.bind(this, moveX, moveY));
321334 }
322335 renderMoveDragging(x, y) {
323- this.DOMobject.style.left = x + "px";
324- this.DOMobject.style.top = y + "px";
336+ this.DOMbase.style.left = x + "px";
337+ this.DOMbase.style.top = y + "px";
325338 this.DOMobject.style.opacity = 0.4;
326339 }
327- mouseUp(evt) {
340+ mouseUp(evt, target) {
328341 this.debuglog("mouseUp");
329342 // Mouse event処理対象をクリア
330- window.appArea.setMouseEventObj(null, null);
343+ window.appArea.setMouseEventObj(null, null, null);
331344 evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
332345 evt.preventDefault(); // 要素既定のdefault動作を止める
333346
--- HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/DisplayField.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/DisplayField.js (revision 32)
@@ -7,7 +7,7 @@
77 class CDisplayField {
88 constructor(dom) {
99 this.DOMobject = dom;
10- this.renderFunc = new Queue();
10+// this.renderFunc = new Queue();
1111 this.mouseMoveFunc = null;
1212 this.mouseUpFunc = null;
1313 }
@@ -39,7 +39,7 @@
3939 let styleaction = document.getElementById('stylepalact');
4040 let cssbg = stylebg.sheet.cssText;
4141 let csstextcol = styletextcol.sheet.cssText;
42- let cssaction = getAnimationCssFromElement(styleaction);
42+ let cssaction = getAnimationCssFromElement(styleaction); // keyframe情報を取得するため、専用関数になっている
4343
4444 // 最終出力
4545 let savestr = '<style id="stylepalbg">' + cssbg + '</style><style id="stylepaltxtcol">' + csstextcol + '</style><style id="stylepalact">' + cssaction + '</style>' + displayInfo;
@@ -51,7 +51,7 @@
5151 }
5252
5353
54-
54+ /*
5555 // ブラウザ上への描画 -------------------------
5656 render() {
5757 while (0 < this.renderFunc.size()) {
@@ -59,9 +59,9 @@
5959 renderFunction();
6060 }
6161 }
62+ */
6263
6364
64-
6565 // Event handler -------------------
6666 // 表示要素の drag & drop禁止
6767 onDragStart(evt) {
--- HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/ObjIDMgr.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/ObjIDMgr.js (revision 32)
@@ -5,7 +5,7 @@
55 // ・DispObjへのobjid割り当て
66 // ・objidから実体への変換
77 // ・DispObjへのcommand処理要求 (振り分け)
8-// ・DispObjの描画関数呼び出し
8+// ×【やめ】DispObjの描画関数呼び出し
99
1010 class CObjIDMgr {
1111 constructor() {
@@ -46,6 +46,7 @@
4646 }
4747 }
4848
49+ /* ★ObjIDMgrは描画には関与しないように変更★
4950 // 管理Elementの描画関数呼び出し
5051 // requestAnimationFrame loop内から呼び出される
5152 renderAll() {
@@ -53,6 +54,7 @@
5354 this.ObjIDarray[i].render();
5455 }
5556 }
57+ */
5658
5759 // 指定されたIDの実体(への参照)を返す
5860 getIDtoDispObj(id) {
--- HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/UI_parts.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/UI_parts.js (revision 32)
@@ -11,14 +11,12 @@
1111 // そのため Focus図形を描く専用の DOMを用意する
1212 class CPartsFocus {
1313 constructor() {
14- this.lineWidth = 2;
15- this.markWidth = 20;
1614 this.num2str = ['focusleft', 'focustop', 'focusright', 'focusbottom'];
1715 this.clingingPartner = null;
1816 this.DOM = [null, null, null, null]; // focus表示用
1917 this.domScaler = null;
2018 this.domRoller = null;
21- this.renderFunc = new Queue();
19+// this.renderFunc = new Queue();
2220 }
2321
2422 debuglog(str) {
@@ -26,7 +24,7 @@
2624 debuglog("【PartsFocus】 focused objid=" + focused + ", " + str);
2725 }
2826
29-
27+/*
3028 // ブラウザ上への描画 -------------------------
3129
3230 // domの淵を囲むように Focus lineを表示する
@@ -36,102 +34,20 @@
3634 let renderFunction = this.renderFunc.dequeue();
3735 renderFunction();
3836 }
39-
40- // Drag & Dropを追いかけるための処理
41- this.renderClinging();
4237 }
43- renderClinging() {
44- if (null == this.clingingPartner) return;
38+*/
4539
46- let originX = parseInt(this.clingingPartner.style.width) / 2;
47- let originY = parseInt(this.clingingPartner.style.height) / 2;
48- // DOM 描画先rect 回転の中心位置
49- this.renderClingingSetPosition(this.DOM[0], this.getRectLeft(), (originX + this.lineWidth / 2) + 'px', '50%');
50- this.renderClingingSetPosition(this.DOM[1], this.getRectTop(), '50%', (originY + this.lineWidth / 2) + 'px');
51- this.renderClingingSetPosition(this.DOM[2], this.getRectRight(), (originX - this.lineWidth / 2) * -1 + 'px', '50%');
52- this.renderClingingSetPosition(this.DOM[3], this.getRectBottom(), '50%', (originY - this.lineWidth / 2) * -1 + 'px');
53- this.renderClingingSetPosition(this.domScaler, this.getRectScaler(), (originX - this.markWidth / 2) * -1 + 'px', (originY - this.markWidth / 2) * -1 + 'px');
54- // this.renderClingingSetPosition( this.domRoller, this.getRectRoller(), (originX - this.markWidth / 2) * -1 + 'px', (originY + this.markWidth / 2) + 'px');
55- this.renderClingingSetPosition(this.domRoller, this.getRectRoller(), '50%', (originY + this.markWidth / 2) + 'px');
56- }
57- renderClingingSetPosition(dom, rect, ox, oy) {
58- dom.style.left = rect.left.toString() + "px";
59- dom.style.top = rect.top.toString() + "px";
60- dom.style.width = (rect.right - rect.left).toString() + "px";
61- dom.style.height = (rect.bottom - rect.top).toString() + "px";
62- // dom.style.border = "1px solid blue";
63- dom.style.transform = this.clingingPartner.style.transform;
64- dom.style.transformOrigin = ox + ' ' + oy + ';'; // 回転の中心を focus対象の中心点に合わせる
65- }
6640
67-
68-
69- // Elementの描画 size取得関数 -------------------------
70-
71- // Focusとして描画する4つのbar それぞれの サイズ取得
72- getRectLeft() {
73- if (null == this.clingingPartner) return new rectData(0, 0, 0, 0);
74- let rect = new rectData();
75- rect.setLTWH(this.clingingPartner.style.left, this.clingingPartner.style.top, this.clingingPartner.style.width, this.clingingPartner.style.height);
76- rect.left -= this.lineWidth / 2; rect.top -= this.lineWidth / 2;
77- rect.right = rect.left + this.lineWidth; rect.bottom += this.lineWidth / 2;
78- return rect;
79- }
80- getRectTop() {
81- if (null == this.clingingPartner) return new rectData(0, 0, 0, 0);
82- let rect = new rectData();
83- rect.setLTWH(this.clingingPartner.style.left, this.clingingPartner.style.top, this.clingingPartner.style.width, this.clingingPartner.style.height);
84- rect.left += this.lineWidth / 2; rect.top -= this.lineWidth / 2;
85- rect.right -= this.lineWidth / 2; rect.bottom = rect.top + this.lineWidth;
86- return rect;
87- }
88- getRectRight() {
89- if (null == this.clingingPartner) return new rectData(0, 0, 0, 0);
90- let rect = new rectData();
91- rect.setLTWH(this.clingingPartner.style.left, this.clingingPartner.style.top, this.clingingPartner.style.width, this.clingingPartner.style.height);
92- rect.right += this.lineWidth / 2; rect.bottom += this.lineWidth / 2;
93- rect.left = rect.right - this.lineWidth; rect.top -= this.lineWidth / 2;
94- return rect;
95- }
96- getRectBottom() {
97- if (null == this.clingingPartner) return new rectData(0, 0, 0, 0);
98- let rect = new rectData();
99- rect.setLTWH(this.clingingPartner.style.left, this.clingingPartner.style.top, this.clingingPartner.style.width, this.clingingPartner.style.height);
100- rect.right -= this.lineWidth / 2; rect.bottom += this.lineWidth / 2;
101- rect.left += this.lineWidth / 2; rect.top = rect.bottom - this.lineWidth;
102- return rect;
103- }
104- // 拡大縮小用 右下マーカーの rect取得
105- getRectScaler() {
106- if (null == this.clingingPartner) return new rectData(0, 0, 0, 0);
107- let centerX = parseInt(this.clingingPartner.style.left) + parseInt(this.clingingPartner.style.width);
108- let centerY = parseInt(this.clingingPartner.style.top) + parseInt(this.clingingPartner.style.height);
109- let rect = new rectData();
110- rect.left = centerX - this.markWidth / 2; rect.top = centerY - this.markWidth / 2;
111- rect.right = centerX + this.markWidth / 2; rect.bottom = centerY + this.markWidth / 2;
112- return rect;
113- }
114- // 回転用 上辺中心部 マーカーの rect取得
115- getRectRoller() {
116- if (null == this.clingingPartner) return new rectData(0, 0, 0, 0);
117- let centerX = parseInt(this.clingingPartner.style.left) + parseInt(this.clingingPartner.style.width) / 2;
118- let centerY = parseInt(this.clingingPartner.style.top);
119- let rect = new rectData();
120- rect.left = centerX - this.markWidth / 2; rect.top = centerY - this.markWidth / 2;
121- rect.right = centerX + this.markWidth / 2; rect.bottom = centerY + this.markWidth / 2;
122- return rect;
123- }
124-
12541 // 表示関数-----------------------------------
12642 // Focus作成
12743 create() {
128- let getRectProperty = [this.getRectLeft.bind(this), this.getRectTop.bind(this), this.getRectRight.bind(this), this.getRectBottom.bind(this)];
12944 for (let cnt = 0; cnt < this.num2str.length; cnt++) {
13045 this.DOM[cnt] = document.createElement('div');
13146 this.DOM[cnt].dataset.objid = this.num2str[cnt];
13247 this.DOM[cnt].classList.add('focusimage');
13348 this.DOM[cnt].classList.add(this.num2str[cnt]);
134- this.renderFunc.enqueue(this.renderCreateOneFocusbar.bind(this, this.DOM[cnt], getRectProperty[cnt]()));
49+// this.renderFunc.enqueue(this.renderCreateOneFocusbar.bind(this, this.DOM[cnt], null));
50+ window.renderLoop.requestRenderFunc(this.renderCreateOneFocusbar.bind(this, this.DOM[cnt], null));
13551 }
13652 // this.debuglog("create() renderFunc size=" + this.renderFunc.size());
13753
@@ -140,13 +56,7 @@
14056 }
14157 renderCreateOneFocusbar(dom, rect) {
14258 dom.style.display = (null == this.clingingPartner) ? "none" : "block";
143- dom.style.position = "absolute";
144- dom.style.left = rect.left.toString() + "px";
145- dom.style.top = rect.top.toString() + "px";
146- dom.style.width = (rect.right - rect.left).toString() + "px";
147- dom.style.height = (rect.bottom - rect.top).toString() + "px";
148- // dom.style.border = "1px solid blue";
149- document.getElementById('DispField').appendChild(dom);
59+ this.clingingPartner.appendChild(dom);
15060 }
15161
15262
@@ -156,17 +66,12 @@
15666 this.domScaler.dataset.objid = 'scaler';
15767 this.domScaler.classList.add('scaler');
15868 this.domScaler.addEventListener('mousedown', this.onMouseDownScale.bind(this), false);
159- this.renderFunc.enqueue(this.renderScaler.bind(this, this.getRectScaler()));
69+// this.renderFunc.enqueue(this.renderScaler.bind(this, null));
70+ window.renderLoop.requestRenderFunc(this.renderScaler.bind(this, null));
16071 }
16172 renderScaler(rect) {
16273 this.domScaler.style.display = (null == this.clingingPartner) ? "none" : "block";
163- this.domScaler.style.position = 'absolute';
164- this.domScaler.style.left = rect.left.toString() + "px";
165- this.domScaler.style.top = rect.top.toString() + "px";
166- this.domScaler.style.width = (rect.right - rect.left).toString() + "px";
167- this.domScaler.style.height = (rect.bottom - rect.top).toString() + "px";
168- // this.domScaler.style.border = "1px solid blue";
169- document.getElementById('DispField').appendChild(this.domScaler);
74+ this.clingingPartner.appendChild(this.domScaler);
17075 }
17176
17277 // 回転操作マーカー作成
@@ -175,17 +80,12 @@
17580 this.domRoller.dataset.objid = 'roller';
17681 this.domRoller.classList.add('roller');
17782 this.domRoller.addEventListener('mousedown', this.onMouseDownRoll.bind(this), false);
178- this.renderFunc.enqueue(this.renderRoller.bind(this, this.getRectRoller()));
83+// this.renderFunc.enqueue(this.renderRoller.bind(this, null));
84+ window.renderLoop.requestRenderFunc(this.renderRoller.bind(this, null));
17985 }
18086 renderRoller(rect) {
18187 this.domRoller.style.display = (null == this.clingingPartner) ? "none" : "block";
182- this.domRoller.style.position = 'absolute';
183- this.domRoller.style.left = rect.left.toString() + "px";
184- this.domRoller.style.top = rect.top.toString() + "px";
185- this.domRoller.style.width = (rect.right - rect.left).toString() + "px";
186- this.domRoller.style.height = (rect.bottom - rect.top).toString() + "px";
187- // this.domRoller.style.border = "1px solid blue";
188- document.getElementById('DispField').appendChild(this.domRoller);
88+ this.clingingPartner.appendChild(this.domRoller);
18989 }
19090
19191 // 操作関数-----------------------------------
@@ -193,11 +93,10 @@
19393 // 非選択: nullを返す
19494 getFocusedObjid() {
19595 this.debuglog("getFocusedObjid().");
196- let ret = null;
197- if (null != this.clingingPartner) {
198- ret = this.clingingPartner.dataset.objid;
199- }
200- return ret;
96+ let eleFocus = this.getFocusdElements();
97+ if (eleFocus < 2) return null;
98+
99+ return eleFocus[0].dataset.objid;
201100 }
202101
203102 // Forcus先 クリア (focus 非表示)
@@ -207,7 +106,7 @@
207106 // requestAnimationFrameでの描画タイミング中は DOM.outerHTMLを変更できないため
208107 // 処理ロジック上のまま削除処理を実行する
209108 // this.renderFunc.enqueue( this.renderClearClingingPartner.bind(this) );
210- this.debuglog("clearClingingPartner() renderFunc size=" + this.renderFunc.size());
109+ this.debuglog("clearClingingPartner()");
211110
212111 this.renderClearClingingPartner();
213112 }
@@ -242,8 +141,23 @@
242141 this.clearClingingPartner();
243142 return;
244143 }
245- // Focus先 変更
246- else if (this.clingingPartner != dom) {
144+
145+ // Focus対象チェック
146+ let result = dom.classList.contains('DispBase');
147+ if (false == result) {
148+ console.error('フォーカス先要素 誤り objid=' + dom.dataset.objid + ', className=' + dom.className);
149+ // 誤って子要素が指定されている可能性があるため、treeを遡って検索
150+ dom = findClassNameParent('DispBase', dom);
151+ if (null == dom) {
152+ console.error('フォーカス先要素 誤り (フォーカス先検索も失敗)');
153+ this.clearClingingPartner();
154+ return;
155+ }
156+ }
157+
158+
159+ // Focus先 変更
160+ if (this.clingingPartner != dom) {
247161 // 現在の情報をクリア
248162 this.clearClingingPartner();
249163 // 新しいFocus先に変更
@@ -256,17 +170,26 @@
256170 // Event handler -------------------------
257171 onMouseDownScale(evt) {
258172 this.debuglog('onMouseDownScale');
173+ let eleFocus = this.getFocusdElements();
174+ if (eleFocus < 2) return;
175+ evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
176+ evt.preventDefault(); // 要素既定のdefault動作を止める
259177
260178 // Mouse eventをappAreaからScalerに渡してもらうように設定
261- window.appArea.setMouseEventObj(this.mouseMoveScale.bind(this), this.mouseUpScale.bind(this));
179+ window.appArea.setMouseEventObj(null, this.mouseMoveScale.bind(this), this.mouseUpScale.bind(this));
262180
263181 // 移動元として座標を保持
264- this.scaleStartWidth = parseInt(this.clingingPartner.style.width);
265- this.scaleStartHeight = parseInt(this.clingingPartner.style.height);
182+ this.scaleStartWidth = parseInt(eleFocus[0].style.width);
183+ this.scaleStartHeight = parseInt(eleFocus[0].style.height);
266184 this.startDragX = evt.pageX;
267185 this.startDragY = evt.pageY;
268186 }
269187 mouseMoveScale(evt) {
188+ let eleFocus = this.getFocusdElements();
189+ if (eleFocus < 2) return;
190+ evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
191+ evt.preventDefault(); // 要素既定のdefault動作を止める
192+
270193 // 画像の仮変形
271194 this.endDragX = evt.pageX;
272195 this.endDragY = evt.pageY;
@@ -276,30 +199,33 @@
276199
277200 switch(1){
278201 case 0: // 領域サイズ変更のみ
279- this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY));
202+// this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY));
203+ window.renderLoop.requestRenderFunc(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY));
280204 break;
281205 case 1: // 縦倍率に合わせfont sizeも変更
282206 {
283- let orgwidth = parseInt(this.clingingPartner.dataset.orgwidth);
284- let orgheight = parseInt(this.clingingPartner.dataset.orgheight);
207+ let orgheight = parseInt(eleFocus[1].dataset.orgheight);
285208 let scaleY = (this.scaleStartHeight + moveY) / orgheight * 100; // ★さらに初期倍率設定値を掛ける必要がある
286- this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY, scaleY));
209+// this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY, scaleY));
210+ window.renderLoop.requestRenderFunc(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY, scaleY));
287211 }
288212 break;
289213 }
290214 }
291215 renderMouseMoveScale(width, height, scalefont) {
292- this.clingingPartner.style.opacity = 0.4;
216+ let eleFocus = this.getFocusdElements();
217+ if (eleFocus < 2) return;
218+ eleFocus[1].style.opacity = 0.4;
293219
294220 switch(1){
295221 case 0:
296- this.clingingPartner.style.width = width + "px";
297- this.clingingPartner.style.height = height + "px";
222+ eleFocus[0].style.width = width + "px";
223+ eleFocus[0].style.height = height + "px";
298224 break;
299225 case 1:
300- this.clingingPartner.style.width = width + "px";
301- this.clingingPartner.style.height = height + "px";
302- this.clingingPartner.style.fontSize = scalefont + '%';
226+ eleFocus[0].style.width = width + "px";
227+ eleFocus[0].style.height = height + "px";
228+ eleFocus[1].style.fontSize = scalefont + '%';
303229 break;
304230 }
305231 }
@@ -306,8 +232,13 @@
306232 mouseUpScale(evt) {
307233 this.debuglog('mouseUpScale');
308234 // Mouse event callback設定をクリア
309- window.appArea.setMouseEventObj(null, null);
235+ window.appArea.setMouseEventObj(null, null, null);
310236
237+ let eleFocus = this.getFocusdElements();
238+ if (eleFocus < 2) return;
239+ evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
240+ evt.preventDefault(); // 要素既定のdefault動作を止める
241+
311242 // 画像の仮変形
312243 this.endDragX = evt.pageX;
313244 this.endDragY = evt.pageY;
@@ -317,7 +248,7 @@
317248
318249 let rectFrom = new rectData();
319250 let rectTo = new rectData();
320- rectFrom.setLTWH(parseInt(this.clingingPartner.style.left), parseInt(this.clingingPartner.style.top), this.scaleStartWidth, this.scaleStartHeight);
251+ rectFrom.setLTWH(parseInt(eleFocus[0].style.left), parseInt(eleFocus[0].style.top), this.scaleStartWidth, this.scaleStartHeight);
321252 rectTo.setLTWH(rectFrom.left, rectFrom.top, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY);
322253
323254 let scaleY = 1.0;
@@ -326,8 +257,8 @@
326257 break;
327258 case 1: // 縦倍率に合わせfont sizeも変更
328259 {
329- let orgwidth = parseInt(this.clingingPartner.dataset.orgwidth);
330- let orgheight = parseInt(this.clingingPartner.dataset.orgheight);
260+ let orgwidth = parseInt(eleFocus[1].dataset.orgwidth);
261+ let orgheight = parseInt(eleFocus[1].dataset.orgheight);
331262 scaleY = (this.scaleStartHeight + moveY) / orgheight * 100; // ★さらに初期倍率設定値を掛ける必要がある
332263 }
333264 break;
@@ -335,7 +266,7 @@
335266
336267 // Scale Command発行
337268 let cmd = new CCommandObj();
338- cmd.createCommand(cmdType.request, cmdAddress.Focus, cmdAddress.ObjIDMgr, cmdCmd.scalebox, this.clingingPartner.dataset.objid, rectFrom, rectTo, scaleY, 5);
269+ cmd.createCommand(cmdType.request, cmdAddress.Focus, cmdAddress.ObjIDMgr, cmdCmd.scalebox, eleFocus[0].dataset.objid, rectFrom, rectTo, scaleY, 5);
339270 this.debuglog("postToWorker");
340271 window.postToWorker.post(cmd);
341272 }
@@ -342,40 +273,75 @@
342273
343274 onMouseDownRoll(evt) {
344275 this.debuglog('onMouseDownRoll');
276+ evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
277+ evt.preventDefault(); // 要素既定のdefault動作を止める
345278
346279 // Mouse eventをappAreaからRollerに渡してもらうように設定
347- window.appArea.setMouseEventObj(this.mouseMoveRoll.bind(this), this.mouseUpRoll.bind(this));
280+ window.appArea.setMouseEventObj(null, this.mouseMoveRoll.bind(this), this.mouseUpRoll.bind(this));
348281 }
349282 mouseMoveRoll(evt) {
350- let x1 = parseInt(this.clingingPartner.style.left) + parseInt(this.clingingPartner.style.width) / 2;
351- let y1 = parseInt(this.clingingPartner.style.top) + parseInt(this.clingingPartner.style.height) / 2;
283+ let eleFocus = this.getFocusdElements();
284+ if (eleFocus < 2) return;
285+ evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
286+ evt.preventDefault(); // 要素既定のdefault動作を止める
287+
288+ let x1 = parseInt(eleFocus[0].style.left) + parseInt(eleFocus[0].style.width) / 2;
289+ let y1 = parseInt(eleFocus[0].style.top) + parseInt(eleFocus[0].style.height) / 2;
352290 let x2 = evt.pageX;
353291 let y2 = evt.pageY;
354292 let degree = angle(x2, y2, x1, y1);
355293
356- this.renderFunc.enqueue(this.renderMouseMoveRoll.bind(this, degree));
294+// this.renderFunc.enqueue(this.renderMouseMoveRoll.bind(this, degree));
295+ window.renderLoop.requestRenderFunc(this.renderMouseMoveRoll.bind(this, degree));
357296 }
358297 renderMouseMoveRoll(degree) {
359- this.clingingPartner.style.transform = 'rotateZ(' + degree + 'deg);';
298+ let eleFocus = this.getFocusdElements();
299+ if (eleFocus < 2) return;
300+
301+ eleFocus[0].style.transform = 'rotateZ(' + degree + 'deg);';
360302 }
361303 mouseUpRoll(evt) {
362304 this.debuglog('mouseUpRoll');
363305 // Mouse event callback設定をクリア
364- window.appArea.setMouseEventObj(null, null);
306+ window.appArea.setMouseEventObj(null, null, null);
307+ let eleFocus = this.getFocusdElements();
308+ if (eleFocus < 2) return;
309+ evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
310+ evt.preventDefault(); // 要素既定のdefault動作を止める
365311
366- let x1 = parseInt(this.clingingPartner.style.left) + parseInt(this.clingingPartner.style.width) / 2;
367- let y1 = parseInt(this.clingingPartner.style.top) + parseInt(this.clingingPartner.style.height) / 2;
312+ let x1 = parseInt(eleFocus[0].style.left) + parseInt(eleFocus[0].style.width) / 2;
313+ let y1 = parseInt(eleFocus[0].style.top) + parseInt(eleFocus[0].style.height) / 2;
368314 let x2 = evt.pageX;
369315 let y2 = evt.pageY;
370316 let degree = angle(x2, y2, x1, y1);
371317 // this.debuglog('■■ x1=' + x1 + ', y1=' + y1 + ',\nx2=' + x2 + ', y2=' + y2 + '\nangle=' + degree);
372- // window.ObjIDMgr.rollbox( this.clingingPartner.dataset.objid, degree ); // debug用 設定情報で直接表示
318+ // window.ObjIDMgr.rollbox( eleFocus[0].dataset.objid, degree ); // debug用 設定情報で直接表示
373319
374320 // Rotate command発行
375321 let cmd = new CCommandObj();
376- cmd.createCommand(cmdType.request, cmdAddress.Focus, cmdAddress.ObjIDMgr, cmdCmd.rollbox, this.clingingPartner.dataset.objid, degree, null, null, 6);
322+ cmd.createCommand(cmdType.request, cmdAddress.Focus, cmdAddress.ObjIDMgr, cmdCmd.rollbox, eleFocus[0].dataset.objid, degree, null, null, 6);
377323 this.debuglog("postToWorker");
378324 window.postToWorker.post(cmd);
379325 }
380326
327+
328+
329+
330+
331+
332+
333+ getFocusdElements() {
334+ let eleBase = this.clingingPartner;
335+ if (null == eleBase) {
336+ console.error('変形処理失敗 操作対象要素が見つからない PartsFocus');
337+ return [];
338+ }
339+ if (eleBase.children.length < 1) {
340+ console.error('変形処理失敗 表示要素が見つからない PartsFocus base element objid=' + eleBalse.dataset.objid + ', className=' + eleBase.className);
341+ return [];
342+ }
343+ let eleDisp = eleBase.children[0];
344+
345+ return [eleBase, eleDisp];
346+ }
381347 } // class CPartsFocus
--- HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/apparea.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/apparea.js (revision 32)
@@ -26,10 +26,27 @@
2626
2727 // 操作関数 -----------------------------------
2828
29- // Mouse eventを処理するObj
30- setMouseEventObj(mouseMove, mouseUp) {
31- this.debuglog('setMouseEventObj callbackMove=' + ((null != mouseMove)? mouseMove.name: 'null') + ', callbackUp=' + ((null != mouseUp)? mouseUp.name: 'null'));
29+ // Mouse eventを拾ったときに通知してほしいときにセット
30+ // 上書きすると前に設定されていた callbackが消えます
31+ // callback: function mouseMove( evt ) move eventの evt.targetは目的のelementでない場合が多いため検索しない
32+ // callback: function mouseUp( evt, strclassElement ) elementが見つからなければ null
33+ setMouseEventObj(
34+ strclass, // mouse up callback 第2引数 targetとして返してほしいelementが持つ css class名
35+ mouseMove, // mouse moveで呼んでほしい関数 or null
36+ mouseUp // mouse upで呼んでほしい関数 or null
37+ ) {
38+ this.debuglog('setMouseEventObj strclass=' + strclass + ', callbackMove=' + ((null != mouseMove)? mouseMove.name: 'null') + ', callbackUp=' + ((null != mouseUp)? mouseUp.name: 'null'));
3239
40+ // Callbackを上書きしてしまう場合はエラー出力し、ひとまず処理を継続
41+ if (null != mouseMove || null != mouseUp) {
42+ if (null != this.mouseMoveFunc || null != this.mouseUpFunc) {
43+ console.error('マウスイベント callback設定上書き \n\
44+Before strclass=' + this.strclass + 'callbackMove=' + (this.mouseMoveFunc ? this.mouseMoveFunc.name : 'null') + ', callbackUp=' + (this.mouseUpFunc ? this.mouseUpFunc.name : 'null') + '\n\
45+After strclass=' + strclass + 'callbackMove=' + ((null != mouseMove) ? mouseMove.name : 'null') + ', callbackUp=' + ((null != mouseUp) ? mouseUp.name : 'null'));
46+ }
47+ }
48+
49+ this.strclass = strclass;
3350 this.mouseMoveFunc = mouseMove;
3451 this.mouseUpFunc = mouseUp;
3552 }
@@ -38,25 +55,27 @@
3855
3956 // ■マウス左ボタン押下 (Drag処理)
4057 onMouseDown(evt) {
58+ this.debuglog('マウスクリック onMouseDown()');
4159 }
4260 // ■ マウス移動 (ドラッグ中)
4361 onMouseMove(evt) {
44- // ★ evt.targetが期待するelementかチェックする必要がある
45- // ★ 期待するelementではない場合、DOM treeを辿って親elementから該当elementを探す必要がある
4662
4763 if (null != this.mouseMoveFunc) {
4864 this.mouseMoveFunc(evt);
49- return;
5065 }
5166 }
67+
5268 // ■ ドロップ処理
5369 onMouseUp(evt) {
54- // ★ evt.targetが期待するelementかチェックする必要がある
55- // ★ 期待するelementではない場合、DOM treeを辿って親elementから該当elementを探す必要がある
70+ this.debuglog('マウスアップ onMouseUp() findClass=' + this.strclass + ', callback move=' + (this.mouseMoveFunc ? this.mouseMoveFunc.name : 'null') + ', Up=' + (this.mouseUpFunc ? this.mouseUpFunc.name : 'null'));
71+ let e = findClassNameParent(this.strclass, evt.target);
72+ if (null == e) {
73+ console.error('マウスアップ 指定要素が見つからない findClass=' + this.strclass + ', callback move=' + (this.mouseMoveFunc ? this.mouseMoveFunc.name : 'null') + ', Up=' + (this.mouseUpFunc ? this.mouseUpFunc.name : 'null'));
74+ // ひとまず処理を継続する
75+ }
5676
5777 if (null != this.mouseUpFunc) {
58- this.mouseUpFunc(evt);
59- return;
78+ this.mouseUpFunc(evt, e);
6079 }
6180 }
6281
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
--- HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/palette.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/palette.js (revision 32)
@@ -10,7 +10,7 @@
1010 constructor() {
1111 this.DOMobject = [];
1212 this.draggingDOM = null;
13- this.renderFunc = new Queue();
13+// this.renderFunc = new Queue();
1414 }
1515
1616 debuglog(str) {
@@ -146,7 +146,7 @@
146146 }
147147 }
148148
149-
149+ /*
150150 // 描画関数 ---------------------
151151
152152 render() {
@@ -155,6 +155,7 @@
155155 renderFunction();
156156 }
157157 }
158+ */
158159
159160 // Event handler -----------------------
160161
@@ -202,8 +203,8 @@
202203 evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
203204 evt.preventDefault(); // 要素既定のdefault動作を止める
204205
205- // Mouse eventをappAreaからCSSPalに渡してもらうように設定
206- window.appArea.setMouseEventObj(this.mouseMove.bind(this), this.mouseUp.bind(this));
206+ // Mouse eventをappAreaからCSSPalに渡してもらうように設定 (evt.targetは必ずpalette要素である前提。子要素なし。)
207+ window.appArea.setMouseEventObj(evt.target.dataset.objid, this.mouseMove.bind(this), this.mouseUp.bind(this));
207208
208209 // Drag対象を保持
209210 this.draggingDOM = evt.target;
@@ -229,7 +230,8 @@
229230 moveX = this.startElementX + moveX;
230231 moveY = this.startElementY + moveY;
231232
232- this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
233+// this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
234+ window.renderLoop.requestRenderFunc(this.renderMoveDragging.bind(this, moveX, moveY));
233235 //this.renderMoveDragging(moveX, moveY);
234236 }
235237 renderMoveDragging(x, y) {
@@ -256,7 +258,7 @@
256258 // Drag中 element情報をクリア
257259 this.draggingDOM = null;
258260 // Mouse event callback設定をクリア
259- window.appArea.setMouseEventObj(null, null);
261+ window.appArea.setMouseEventObj(null, null, null);
260262
261263 // マウス座標直下にある要素を検索
262264 // (evt.targetは自分を指してしまうため)
--- HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/palgroup.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/bin/x64/Debug/AppX/js/palgroup.js (revision 32)
@@ -16,7 +16,7 @@
1616 this.typeAction = 2;
1717
1818 this.DOMobject = []; // bg,text,action
19- this.renderFunc = new Queue();
19+// this.renderFunc = new Queue();
2020 }
2121 debuglog(str) {
2222 debuglog('【PalGroup】 ' + str);
@@ -44,7 +44,7 @@
4444 }
4545
4646
47-
47+ /*
4848 // 描画関数 ---------------------
4949
5050 render() {
@@ -53,14 +53,14 @@
5353 renderFunction();
5454 }
5555 }
56+ */
5657
5758
58-
5959 // Event handler -----------------------
6060
6161 onMouseDown(evt) {
6262 // Mouse eventをappAreaからCSSPalに渡してもらうように設定
63- window.appArea.setMouseEventObj(this.mouseMove.bind(this), null);
63+ window.appArea.setMouseEventObj(null, this.mouseMove.bind(this), null);
6464 evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
6565 evt.preventDefault(); // 要素既定のdefault動作を止める
6666
@@ -88,7 +88,8 @@
8888 moveX = this.startElementX + moveX;
8989 moveY = this.startElementY + moveY;
9090
91- this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
91+// this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
92+ window.renderLoop.requestRenderFunc(this.renderMoveDragging.bind(this, moveX, moveY));
9293 //this.renderMoveDragging(moveX, moveY);
9394 }
9495 renderMoveDragging(x, y) {
@@ -106,7 +107,7 @@
106107 // Drag中 element情報をクリア
107108 this.draggingDOM = null;
108109 // Mouse event callback設定をクリア
109- window.appArea.setMouseEventObj(null, null);
110+ window.appArea.setMouseEventObj(null, null, null);
110111 }
111112
112113
--- HtmlDrawApp/HTMLDrawApp/css/default.css (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/css/default.css (revision 32)
@@ -51,12 +51,18 @@
5151 }
5252
5353
54+ .DispBase,
5455 .DispObj {
5556 display: inline-block;
56- position:absolute;
57+ position: absolute;
5758 marginj:0; padding:0;
5859 }
60+ .DispObj {
61+ left:0; top:0;
62+ width: 100%; height: 100%;
63+ }
5964
65+
6066 /* パレットグループ要素の定義 */
6167 .palgroup {
6268 display: inline-block;
@@ -106,14 +112,22 @@
106112
107113
108114 /* フォーカス枠と拡大縮小・回転用マーカー定義 */
109- .scaler {
115+ .scaler,
116+ .roller {
117+ position: absolute;
118+ width: 15px; height: 15px;
119+ padding: 0; margin: 0;
110120 border: 2px solid black;
111121 border-radius: 50%;
122+ }
123+ .scaler {
124+ left: 100%; top: 100%;
125+ transform: translateX(-50%) translateY(-50%);
112126 background-color: orange;
113127 }
114128 .roller {
115- border: 2px solid black;
116- border-radius: 50%;
129+ left: 50%; top: 0%;
130+ transform: translateX(-50%) translateY(-50%);
117131 background-color: green;
118132 }
119133
@@ -131,10 +145,37 @@
131145 );
132146 background-size: 8px 8px;
133147 }
134- .focusleft { animation: animForcus1 3s linear infinite; }
135- .focusright { animation: animForcus2 3s linear infinite; }
136- .focustop { animation: animForcus2 3s linear infinite; }
137- .focusbottom { animation: animForcus1 3s linear infinite; }
148+ .focusleft,
149+ .focustop,
150+ .focusright,
151+ .focusbottom{
152+ position: absolute;
153+ padding: 0; margin: 0;
154+ }
155+ .focusleft {
156+ left: 0%; top: 0%;
157+ width: 2px; height: 100%;
158+ transform: translateX(-50%) translateY(0%);
159+ animation: animForcus1 3s linear infinite;
160+ }
161+ .focustop {
162+ left: 0%; top: 0%;
163+ width: 100%; height: 2px;
164+ transform: translateX(0%) translateY(-50%);
165+ animation: animForcus2 3s linear infinite;
166+ }
167+ .focusright {
168+ left: 100%; top: 0%;
169+ width: 2px; height: 100%;
170+ transform: translateX(-50%) translateY(0%);
171+ animation: animForcus2 3s linear infinite;
172+ }
173+ .focusbottom {
174+ left: 0%; top: 100%;
175+ width: 100%; height: 2px;
176+ transform: translateX(0%) translateY(-50%);
177+ animation: animForcus1 3s linear infinite;
178+ }
138179 @keyframes animForcus1 {
139180 0% { background-position:0% 0%}
140181 100% {background-position:100% 100%}
@@ -151,11 +192,6 @@
151192 animation: none;
152193 }
153194
154- #apparea:target img,
155- #apparea:target div {
156- animation: none;
157- background-color:red;
158- }
159195
160196
161197
--- HtmlDrawApp/HTMLDrawApp/js/Common.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/js/Common.js (revision 32)
@@ -4,7 +4,7 @@
44 var DEBUGLOG = true;
55 debuglog = (true==DEBUGLOG)? debugLog : logQuiet;
66
7-function debugLog(str) {
7+function debugLog(str,callerargs) {
88 console.log(str);
99 };
1010 function logQuiet(str) {
@@ -195,14 +195,45 @@
195195 }
196196 }
197197 return null;
198-}
198+};
199199
200200
201201
202202
203+// elementを起点に classNameを持った要素を遡って検索
204+// 見つからなければ nullを返す
205+function findClassNameParent(
206+ className, // 検索対象 CSS class name
207+ element // 検索起点 element
208+) {
209+ let e = element;
210+ if (null != className && null != element) {
211+ let result = false;
212+ do {
213+ result = e.classList.contains(className);
214+ if (true == result) break;
203215
216+ e = e.parent;
217+ } while (null != e);
218+ }
219+ return e;
220+};
204221
205222
223+
224+
225+
226+
227+
228+
229+
230+
231+
232+
233+
234+
235+
236+
206237 // Drop fileから file objectを取得 (同期処理)
207238 // 複数file 非対応。text or image がヒットした時点でcallbackを呼び出す
208239 // callback書式(text,image): function(blob)
@@ -314,3 +345,34 @@
314345 if (null != this.callbackError) this.callbackError(err.message);
315346 };
316347 } // class SaveFile
348+
349+
350+
351+class RenderLoop {
352+ constructor() {
353+ this.renderQue = new Queue();
354+ this.rendering = null; // loop処理呼び出し済み判定用
355+ }
356+
357+
358+ // 描画用callback関数登録要求
359+ // 引数のcallbackを1回呼び出します
360+ // callback: function callback(time)
361+ requestRenderFunc(callback) {
362+ console.log('Request render function = ' + (callback ? callback.name : 'null'));
363+ if (null != callback){
364+ this.renderQue.enqueue(callback);
365+
366+ // 描画loop
367+ (function renderloop(time) {
368+ if (0 < this.renderQue.size()) {
369+ this.renderQue.dequeue()(time);
370+ console.log('render func size=' + this.renderQue.size());
371+ requestAnimationFrame(renderloop.bind(this));
372+ }
373+ }.call(this,window.performance.now()));
374+ }
375+ }
376+}
377+
378+
--- HtmlDrawApp/HTMLDrawApp/js/DispObj.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/js/DispObj.js (revision 32)
@@ -13,23 +13,24 @@
1313 init() {
1414 this.debuglog('init()');
1515 this.ObjID = 0;
16- this.GroupID = 0;
1716 this.type = 0;
1817 this.x = 0.0;
1918 this.y = 0.0;
2019 this.width = 0.0;
2120 this.height = 0.0;
21+ this.originalWidth = 0.0;
22+ this.originalHeight = 0.0;
2223 this.opacity = 1.0;
2324 this.degree = 0;
2425 this.text = null;
2526 this.transformStr = null;
26- this.initDOMobj(); // DOMをクリア
27- this.renderFunc = new Queue();
2827
29- this.originalWidth = 0;
30- this.originalHeight = 0;
28+ // DOMをクリア
29+ this.initDOMobj();
30+// this.renderFunc = new Queue();
3131
32- this.dropinitsize = 100.0;
32+
33+ this.dropinitsize = 100.0; // File dropで作成する Elementの長辺の長さ
3334 }
3435 initDOMobj() {
3536 if (null != this.DOMobject) {
@@ -47,6 +48,7 @@
4748 }
4849
4950
51+
5052 // 操作関数 ------------------------------------
5153
5254 // 破棄
@@ -73,7 +75,7 @@
7375
7476
7577
76-
78+ /*
7779 // ブラウザ上への描画 -------------------------
7880
7981 // コマンド要求実行後の描画共通処理
@@ -84,6 +86,7 @@
8486 renderFunction();
8587 }
8688 }
89+ */
8790
8891 // コマンド実行処理 -----------------------------
8992
@@ -113,14 +116,20 @@
113116 this.originalHeight = this.height;
114117
115118 // 画面に影響しない範囲で作成できるところまで Dom objectを作成する
119+ // DispBase作成
120+ this.DOMbase = document.createElement('div');
121+ this.DOMbase.classList.add('DispBase');
122+ this.DOMbase.dataset.objid = this.ObjID;
123+ this.DOMbase.dataset.degree = 0;
124+ this.DOMbase.addEventListener('mousedown', this.onMouseDown.bind(this), false);
125+ // DispObj作成
116126 let elType = (null != type.match(/imagebox/)) ? 'img' : 'div';
117127 this.DOMobject = document.createElement(elType);
128+ this.DOMbase.appendChild(this.DOMobject); // ひとまず連結
118129 this.DOMobject.classList.add('DispObj');
119130 this.DOMobject.dataset.objid = this.ObjID;
120131 this.DOMobject.dataset.orgwidth = this.originalWidth; // transform: scaleの基準サイズ
121- this.DOMobject.dataset.orgheight = this.originalHeight;
122- this.DOMobject.dataset.degree = 0;
123- this.DOMobject.addEventListener('mousedown', this.onMouseDown.bind(this), false);
132+ this.DOMobject.dataset.orgheight = this.originalHeight; // 画像original sizeなのでこちらで管理
124133 if (null != type.match(/imagebox/)) {
125134 // imageの場合、画像読み込み完了後に描画する必要がある
126135 this.loadImage(opt1);
@@ -131,7 +140,8 @@
131140 }
132141 else {
133142 // 描画呼び出し時に呼び出す関数を登録
134- this.renderFunc.enqueue(this.renderCreate.bind(this));
143+// this.renderFunc.enqueue(this.renderCreate.bind(this));
144+ window.renderLoop.requestRenderFunc(this.renderCreate.bind(this));
135145 }
136146 }
137147 return true;
@@ -143,7 +153,8 @@
143153 reader.onload = function (evt) {
144154 this.text = evt.target.result;
145155 // 描画呼び出し時に呼び出す関数を登録
146- this.renderFunc.enqueue(this.renderCreate.bind(this));
156+// this.renderFunc.enqueue(this.renderCreate.bind(this));
157+ window.renderLoop.requestRenderFunc(this.renderCreate.bind(this));
147158 }.bind(this);
148159 }
149160 loadImage(file) {
@@ -162,9 +173,10 @@
162173 this.originalWidth = this.width;
163174 this.originalHeight = this.height;
164175 this.DOMobject.dataset.orgwidth = this.originalWidth; // transform: scaleの基準サイズ
165- this.DOMobject.dataset.orgheight = this.originalHeight;
176+ this.DOMobject.dataset.orgheight = this.originalHeight; // 画像original sizeなのでこちらで管理
166177 // 表示サイズ取得完了したので画面に表示
167- this.renderFunc.enqueue(this.renderCreate.bind(this));
178+// this.renderFunc.enqueue(this.renderCreate.bind(this));
179+ window.renderLoop.requestRenderFunc(this.renderCreate.bind(this));
168180 }.bind(this);
169181 }.bind(this);
170182 }
@@ -185,27 +197,27 @@
185197 return new rectData(0, 0, destW, destH);
186198 }
187199 renderCreate() {
188-// this.DOMobject.style.position = "absolute"; // DispObj CSS classで指定
189- this.DOMobject.style.left = this.x.toString() + "px";
190- this.DOMobject.style.top = this.y.toString() + "px";
191- this.DOMobject.style.width = this.width.toString() + "px";
192- this.DOMobject.style.height = this.height.toString() + "px";
193200 this.DOMobject.style.border = "1px solid black"; // 指定するI/Fが必要
194201 if (null != this.text) this.DOMobject.innerHTML = this.text;
202+// this.DOMobject.style.position = "absolute"; // DispObj CSS classで指定
195203
196- document.getElementById('DispField').appendChild(this.DOMobject);
204+ this.DOMbase.style.left = this.x.toString() + "px";
205+ this.DOMbase.style.top = this.y.toString() + "px";
206+ this.DOMbase.style.width = this.width.toString() + "px";
207+ this.DOMbase.style.height = this.height.toString() + "px";
208+ document.getElementById('DispField').appendChild(this.DOMbase);
197209
198- this.debuglog("renderCreate() left=" + this.DOMobject.style.left
199- + ", top=" + this.DOMobject.style.top
200- + ", width=" + this.DOMobject.style.width
201- + ", height=" + this.DOMobject.style.height
202- + ", border=" + this.DOMobject.style.border);
210+ this.debuglog("renderCreate() left=" + this.DOMbase.style.left
211+ + ", top=" + this.DOMbase.style.top
212+ + ", width=" + this.DOMbase.style.width
213+ + ", height=" + this.DOMbase.style.height
214+ + ", innerHTML=" + this.DOMobject.innerHTML);
203215 }
204216
205217 createFromElement(ele) {
206218 this.debuglog('createFromElement() ele=' + ele);
207219
208- this.DOMobject = ele;
220+ this.DOMbase = ele;
209221 this.type = (null != ele.nodeName.match(/IMG/)) ? 'imagebox' : 'textbox';
210222 this.x = parseInt(ele.style.left);
211223 this.y = parseInt(ele.style.top);
@@ -215,7 +227,7 @@
215227 this.originalHeight = ele.dataset.orgheight;
216228 this.ObjID = ele.dataset.objid;
217229 this.degree = ele.dataset.degree;
218- this.DOMobject.addEventListener('mousedown', this.onMouseDown.bind(this), false);
230+ this.DOMbase.addEventListener('mousedown', this.onMouseDown.bind(this), false);
219231
220232 // 画像・テキストは既にelementに読み込み済み
221233 // treeにも入っており、更新する必要もないのでこれで完了
@@ -229,20 +241,21 @@
229241 movebox(x, y) {
230242 this.x = x;
231243 this.y = y;
232- this.renderFunc.enqueue(this.rendermove.bind(this));
244+// this.renderFunc.enqueue(this.rendermove.bind(this));
245+ window.renderLoop.requestRenderFunc(this.rendermove.bind(this));
233246
234- this.debuglog("movebox() x=" + this.x + ", y=" + this.y + ", renderFunc size=" + this.renderFunc.size());
247+ this.debuglog("movebox() x=" + this.x + ", y=" + this.y);
235248 }
236249 rendermove() {
237- this.DOMobject.style.left = this.x.toString() + "px";
238- this.DOMobject.style.top = this.y.toString() + "px";
250+ this.DOMbase.style.left = this.x.toString() + "px";
251+ this.DOMbase.style.top = this.y.toString() + "px";
239252 this.DOMobject.style.opacity = this.opacity.toString();
240253
241- this.debuglog("rendermove() left=" + this.DOMobject.style.left
242- + ", top=" + this.DOMobject.style.top
243- + ", width=" + this.DOMobject.style.width
244- + ", height=" + this.DOMobject.style.height
245- + ", border=" + this.DOMobject.style.border);
254+ this.debuglog("rendermove() left=" + this.DOMbase.style.left
255+ + ", top=" + this.DOMbase.style.top
256+ + ", width=" + this.DOMbase.style.width
257+ + ", height=" + this.DOMbase.style.height
258+ + ", opacity=" + this.DOMobject.opacity);
246259 }
247260
248261 scalebox(rect, fontscale) {
@@ -250,14 +263,15 @@
250263 this.y = rect.top;
251264 this.width = rect.right - rect.left;
252265 this.height = rect.bottom - rect.top;
253- this.renderFunc.enqueue(this.renderscalebox.bind(this));
266+// this.renderFunc.enqueue(this.renderscalebox.bind(this));
267+ window.renderLoop.requestRenderFunc(this.renderscalebox.bind(this));
254268 this.fontsize = fontscale;
255269 }
256270 renderscalebox() {
257- this.DOMobject.style.left = this.x.toString() + "px";
258- this.DOMobject.style.top = this.y.toString() + "px";
259- this.DOMobject.style.width = this.width.toString() + "px";
260- this.DOMobject.style.height = this.height.toString() + "px";
271+ this.DOMbase.style.left = this.x.toString() + "px";
272+ this.DOMbase.style.top = this.y.toString() + "px";
273+ this.DOMbase.style.width = this.width.toString() + "px";
274+ this.DOMbase.style.height = this.height.toString() + "px";
261275 this.DOMobject.style.opacity = this.opacity.toString();
262276 this.DOMobject.style.fontSize = this.fontsize + '%';
263277 }
@@ -264,11 +278,12 @@
264278
265279 rollbox(degree) {
266280 this.degree = degree;
267- this.DOMobject.dataset.degree = degree;
268- this.renderFunc.enqueue(this.renderrollbox.bind(this));
281+ this.DOMbase.dataset.degree = degree;
282+// this.renderFunc.enqueue(this.renderrollbox.bind(this));
283+ window.renderLoop.requestRenderFunc(this.renderrollbox.bind(this));
269284 }
270285 renderrollbox() {
271- this.DOMobject.style.transform = 'rotateZ(' + this.degree + 'deg);';
286+ this.DOMbase.style.transform = 'rotateZ(' + this.degree + 'deg);';
272287 }
273288
274289
@@ -288,22 +303,19 @@
288303 return;
289304 }
290305 // Mouse eventをappAreaからScalerに渡してもらうように設定
291- window.appArea.setMouseEventObj(this.mouseMove.bind(this), this.mouseUp.bind(this));
306+ window.appArea.setMouseEventObj('DispBase',this.mouseMove.bind(this), this.mouseUp.bind(this));
292307 evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
293308 evt.preventDefault(); // 要素既定のdefault動作を止める
294309
295-
296- // Focus設定
297- evt.target.dataset.focus = "true";
298310 // 移動元として座標を保持
299311 this.startDragX = evt.pageX;
300312 this.startDragY = evt.pageY;
301313
302314 // Focus表示
303- window.partsFocus.setClingingPartner(this.DOMobject);
315+ window.partsFocus.setClingingPartner(this.DOMbase);
304316
305317 }
306- mouseMove(evt) {
318+ mouseMove(evt, target) {
307319 evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
308320 evt.preventDefault(); // 要素既定のdefault動作を止める
309321
@@ -317,17 +329,18 @@
317329 moveX = this.x + moveX;
318330 moveY = this.y + moveY;
319331
320- this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
332+// this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
333+ window.renderLoop.requestRenderFunc(this.renderMoveDragging.bind(this, moveX, moveY));
321334 }
322335 renderMoveDragging(x, y) {
323- this.DOMobject.style.left = x + "px";
324- this.DOMobject.style.top = y + "px";
336+ this.DOMbase.style.left = x + "px";
337+ this.DOMbase.style.top = y + "px";
325338 this.DOMobject.style.opacity = 0.4;
326339 }
327- mouseUp(evt) {
340+ mouseUp(evt, target) {
328341 this.debuglog("mouseUp");
329342 // Mouse event処理対象をクリア
330- window.appArea.setMouseEventObj(null, null);
343+ window.appArea.setMouseEventObj(null, null, null);
331344 evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
332345 evt.preventDefault(); // 要素既定のdefault動作を止める
333346
--- HtmlDrawApp/HTMLDrawApp/js/DisplayField.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/js/DisplayField.js (revision 32)
@@ -7,7 +7,7 @@
77 class CDisplayField {
88 constructor(dom) {
99 this.DOMobject = dom;
10- this.renderFunc = new Queue();
10+// this.renderFunc = new Queue();
1111 this.mouseMoveFunc = null;
1212 this.mouseUpFunc = null;
1313 }
@@ -51,7 +51,7 @@
5151 }
5252
5353
54-
54+ /*
5555 // ブラウザ上への描画 -------------------------
5656 render() {
5757 while (0 < this.renderFunc.size()) {
@@ -59,9 +59,9 @@
5959 renderFunction();
6060 }
6161 }
62+ */
6263
6364
64-
6565 // Event handler -------------------
6666 // 表示要素の drag & drop禁止
6767 onDragStart(evt) {
--- HtmlDrawApp/HTMLDrawApp/js/ObjIDMgr.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/js/ObjIDMgr.js (revision 32)
@@ -5,7 +5,7 @@
55 // ・DispObjへのobjid割り当て
66 // ・objidから実体への変換
77 // ・DispObjへのcommand処理要求 (振り分け)
8-// ・DispObjの描画関数呼び出し
8+// ×【やめ】DispObjの描画関数呼び出し
99
1010 class CObjIDMgr {
1111 constructor() {
@@ -46,6 +46,7 @@
4646 }
4747 }
4848
49+ /* ★ObjIDMgrは描画には関与しないように変更★
4950 // 管理Elementの描画関数呼び出し
5051 // requestAnimationFrame loop内から呼び出される
5152 renderAll() {
@@ -53,6 +54,7 @@
5354 this.ObjIDarray[i].render();
5455 }
5556 }
57+ */
5658
5759 // 指定されたIDの実体(への参照)を返す
5860 getIDtoDispObj(id) {
--- HtmlDrawApp/HTMLDrawApp/js/UI_parts.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/js/UI_parts.js (revision 32)
@@ -11,14 +11,12 @@
1111 // そのため Focus図形を描く専用の DOMを用意する
1212 class CPartsFocus {
1313 constructor() {
14- this.lineWidth = 2;
15- this.markWidth = 20;
1614 this.num2str = ['focusleft', 'focustop', 'focusright', 'focusbottom'];
1715 this.clingingPartner = null;
1816 this.DOM = [null, null, null, null]; // focus表示用
1917 this.domScaler = null;
2018 this.domRoller = null;
21- this.renderFunc = new Queue();
19+// this.renderFunc = new Queue();
2220 }
2321
2422 debuglog(str) {
@@ -26,7 +24,7 @@
2624 debuglog("【PartsFocus】 focused objid=" + focused + ", " + str);
2725 }
2826
29-
27+/*
3028 // ブラウザ上への描画 -------------------------
3129
3230 // domの淵を囲むように Focus lineを表示する
@@ -36,102 +34,20 @@
3634 let renderFunction = this.renderFunc.dequeue();
3735 renderFunction();
3836 }
39-
40- // Drag & Dropを追いかけるための処理
41- this.renderClinging();
4237 }
43- renderClinging() {
44- if (null == this.clingingPartner) return;
38+*/
4539
46- let originX = parseInt(this.clingingPartner.style.width) / 2;
47- let originY = parseInt(this.clingingPartner.style.height) / 2;
48- // DOM 描画先rect 回転の中心位置
49- this.renderClingingSetPosition(this.DOM[0], this.getRectLeft(), (originX + this.lineWidth / 2) + 'px', '50%');
50- this.renderClingingSetPosition(this.DOM[1], this.getRectTop(), '50%', (originY + this.lineWidth / 2) + 'px');
51- this.renderClingingSetPosition(this.DOM[2], this.getRectRight(), (originX - this.lineWidth / 2) * -1 + 'px', '50%');
52- this.renderClingingSetPosition(this.DOM[3], this.getRectBottom(), '50%', (originY - this.lineWidth / 2) * -1 + 'px');
53- this.renderClingingSetPosition(this.domScaler, this.getRectScaler(), (originX - this.markWidth / 2) * -1 + 'px', (originY - this.markWidth / 2) * -1 + 'px');
54- // this.renderClingingSetPosition( this.domRoller, this.getRectRoller(), (originX - this.markWidth / 2) * -1 + 'px', (originY + this.markWidth / 2) + 'px');
55- this.renderClingingSetPosition(this.domRoller, this.getRectRoller(), '50%', (originY + this.markWidth / 2) + 'px');
56- }
57- renderClingingSetPosition(dom, rect, ox, oy) {
58- dom.style.left = rect.left.toString() + "px";
59- dom.style.top = rect.top.toString() + "px";
60- dom.style.width = (rect.right - rect.left).toString() + "px";
61- dom.style.height = (rect.bottom - rect.top).toString() + "px";
62- // dom.style.border = "1px solid blue";
63- dom.style.transform = this.clingingPartner.style.transform;
64- dom.style.transformOrigin = ox + ' ' + oy + ';'; // 回転の中心を focus対象の中心点に合わせる
65- }
6640
67-
68-
69- // Elementの描画 size取得関数 -------------------------
70-
71- // Focusとして描画する4つのbar それぞれの サイズ取得
72- getRectLeft() {
73- if (null == this.clingingPartner) return new rectData(0, 0, 0, 0);
74- let rect = new rectData();
75- rect.setLTWH(this.clingingPartner.style.left, this.clingingPartner.style.top, this.clingingPartner.style.width, this.clingingPartner.style.height);
76- rect.left -= this.lineWidth / 2; rect.top -= this.lineWidth / 2;
77- rect.right = rect.left + this.lineWidth; rect.bottom += this.lineWidth / 2;
78- return rect;
79- }
80- getRectTop() {
81- if (null == this.clingingPartner) return new rectData(0, 0, 0, 0);
82- let rect = new rectData();
83- rect.setLTWH(this.clingingPartner.style.left, this.clingingPartner.style.top, this.clingingPartner.style.width, this.clingingPartner.style.height);
84- rect.left += this.lineWidth / 2; rect.top -= this.lineWidth / 2;
85- rect.right -= this.lineWidth / 2; rect.bottom = rect.top + this.lineWidth;
86- return rect;
87- }
88- getRectRight() {
89- if (null == this.clingingPartner) return new rectData(0, 0, 0, 0);
90- let rect = new rectData();
91- rect.setLTWH(this.clingingPartner.style.left, this.clingingPartner.style.top, this.clingingPartner.style.width, this.clingingPartner.style.height);
92- rect.right += this.lineWidth / 2; rect.bottom += this.lineWidth / 2;
93- rect.left = rect.right - this.lineWidth; rect.top -= this.lineWidth / 2;
94- return rect;
95- }
96- getRectBottom() {
97- if (null == this.clingingPartner) return new rectData(0, 0, 0, 0);
98- let rect = new rectData();
99- rect.setLTWH(this.clingingPartner.style.left, this.clingingPartner.style.top, this.clingingPartner.style.width, this.clingingPartner.style.height);
100- rect.right -= this.lineWidth / 2; rect.bottom += this.lineWidth / 2;
101- rect.left += this.lineWidth / 2; rect.top = rect.bottom - this.lineWidth;
102- return rect;
103- }
104- // 拡大縮小用 右下マーカーの rect取得
105- getRectScaler() {
106- if (null == this.clingingPartner) return new rectData(0, 0, 0, 0);
107- let centerX = parseInt(this.clingingPartner.style.left) + parseInt(this.clingingPartner.style.width);
108- let centerY = parseInt(this.clingingPartner.style.top) + parseInt(this.clingingPartner.style.height);
109- let rect = new rectData();
110- rect.left = centerX - this.markWidth / 2; rect.top = centerY - this.markWidth / 2;
111- rect.right = centerX + this.markWidth / 2; rect.bottom = centerY + this.markWidth / 2;
112- return rect;
113- }
114- // 回転用 上辺中心部 マーカーの rect取得
115- getRectRoller() {
116- if (null == this.clingingPartner) return new rectData(0, 0, 0, 0);
117- let centerX = parseInt(this.clingingPartner.style.left) + parseInt(this.clingingPartner.style.width) / 2;
118- let centerY = parseInt(this.clingingPartner.style.top);
119- let rect = new rectData();
120- rect.left = centerX - this.markWidth / 2; rect.top = centerY - this.markWidth / 2;
121- rect.right = centerX + this.markWidth / 2; rect.bottom = centerY + this.markWidth / 2;
122- return rect;
123- }
124-
12541 // 表示関数-----------------------------------
12642 // Focus作成
12743 create() {
128- let getRectProperty = [this.getRectLeft.bind(this), this.getRectTop.bind(this), this.getRectRight.bind(this), this.getRectBottom.bind(this)];
12944 for (let cnt = 0; cnt < this.num2str.length; cnt++) {
13045 this.DOM[cnt] = document.createElement('div');
13146 this.DOM[cnt].dataset.objid = this.num2str[cnt];
13247 this.DOM[cnt].classList.add('focusimage');
13348 this.DOM[cnt].classList.add(this.num2str[cnt]);
134- this.renderFunc.enqueue(this.renderCreateOneFocusbar.bind(this, this.DOM[cnt], getRectProperty[cnt]()));
49+// this.renderFunc.enqueue(this.renderCreateOneFocusbar.bind(this, this.DOM[cnt], null));
50+ window.renderLoop.requestRenderFunc(this.renderCreateOneFocusbar.bind(this, this.DOM[cnt], null));
13551 }
13652 // this.debuglog("create() renderFunc size=" + this.renderFunc.size());
13753
@@ -140,13 +56,7 @@
14056 }
14157 renderCreateOneFocusbar(dom, rect) {
14258 dom.style.display = (null == this.clingingPartner) ? "none" : "block";
143- dom.style.position = "absolute";
144- dom.style.left = rect.left.toString() + "px";
145- dom.style.top = rect.top.toString() + "px";
146- dom.style.width = (rect.right - rect.left).toString() + "px";
147- dom.style.height = (rect.bottom - rect.top).toString() + "px";
148- // dom.style.border = "1px solid blue";
149- document.getElementById('DispField').appendChild(dom);
59+ this.clingingPartner.appendChild(dom);
15060 }
15161
15262
@@ -156,17 +66,12 @@
15666 this.domScaler.dataset.objid = 'scaler';
15767 this.domScaler.classList.add('scaler');
15868 this.domScaler.addEventListener('mousedown', this.onMouseDownScale.bind(this), false);
159- this.renderFunc.enqueue(this.renderScaler.bind(this, this.getRectScaler()));
69+// this.renderFunc.enqueue(this.renderScaler.bind(this, null));
70+ window.renderLoop.requestRenderFunc(this.renderScaler.bind(this, null));
16071 }
16172 renderScaler(rect) {
16273 this.domScaler.style.display = (null == this.clingingPartner) ? "none" : "block";
163- this.domScaler.style.position = 'absolute';
164- this.domScaler.style.left = rect.left.toString() + "px";
165- this.domScaler.style.top = rect.top.toString() + "px";
166- this.domScaler.style.width = (rect.right - rect.left).toString() + "px";
167- this.domScaler.style.height = (rect.bottom - rect.top).toString() + "px";
168- // this.domScaler.style.border = "1px solid blue";
169- document.getElementById('DispField').appendChild(this.domScaler);
74+ this.clingingPartner.appendChild(this.domScaler);
17075 }
17176
17277 // 回転操作マーカー作成
@@ -175,17 +80,12 @@
17580 this.domRoller.dataset.objid = 'roller';
17681 this.domRoller.classList.add('roller');
17782 this.domRoller.addEventListener('mousedown', this.onMouseDownRoll.bind(this), false);
178- this.renderFunc.enqueue(this.renderRoller.bind(this, this.getRectRoller()));
83+// this.renderFunc.enqueue(this.renderRoller.bind(this, null));
84+ window.renderLoop.requestRenderFunc(this.renderRoller.bind(this, null));
17985 }
18086 renderRoller(rect) {
18187 this.domRoller.style.display = (null == this.clingingPartner) ? "none" : "block";
182- this.domRoller.style.position = 'absolute';
183- this.domRoller.style.left = rect.left.toString() + "px";
184- this.domRoller.style.top = rect.top.toString() + "px";
185- this.domRoller.style.width = (rect.right - rect.left).toString() + "px";
186- this.domRoller.style.height = (rect.bottom - rect.top).toString() + "px";
187- // this.domRoller.style.border = "1px solid blue";
188- document.getElementById('DispField').appendChild(this.domRoller);
88+ this.clingingPartner.appendChild(this.domRoller);
18989 }
19090
19191 // 操作関数-----------------------------------
@@ -193,11 +93,10 @@
19393 // 非選択: nullを返す
19494 getFocusedObjid() {
19595 this.debuglog("getFocusedObjid().");
196- let ret = null;
197- if (null != this.clingingPartner) {
198- ret = this.clingingPartner.dataset.objid;
199- }
200- return ret;
96+ let eleFocus = this.getFocusdElements();
97+ if (eleFocus < 2) return null;
98+
99+ return eleFocus[0].dataset.objid;
201100 }
202101
203102 // Forcus先 クリア (focus 非表示)
@@ -207,7 +106,7 @@
207106 // requestAnimationFrameでの描画タイミング中は DOM.outerHTMLを変更できないため
208107 // 処理ロジック上のまま削除処理を実行する
209108 // this.renderFunc.enqueue( this.renderClearClingingPartner.bind(this) );
210- this.debuglog("clearClingingPartner() renderFunc size=" + this.renderFunc.size());
109+ this.debuglog("clearClingingPartner()");
211110
212111 this.renderClearClingingPartner();
213112 }
@@ -242,8 +141,23 @@
242141 this.clearClingingPartner();
243142 return;
244143 }
245- // Focus先 変更
246- else if (this.clingingPartner != dom) {
144+
145+ // Focus対象チェック
146+ let result = dom.classList.contains('DispBase');
147+ if (false == result) {
148+ console.error('フォーカス先要素 誤り objid=' + dom.dataset.objid + ', className=' + dom.className);
149+ // 誤って子要素が指定されている可能性があるため、treeを遡って検索
150+ dom = findClassNameParent('DispBase', dom);
151+ if (null == dom) {
152+ console.error('フォーカス先要素 誤り (フォーカス先検索も失敗)');
153+ this.clearClingingPartner();
154+ return;
155+ }
156+ }
157+
158+
159+ // Focus先 変更
160+ if (this.clingingPartner != dom) {
247161 // 現在の情報をクリア
248162 this.clearClingingPartner();
249163 // 新しいFocus先に変更
@@ -256,17 +170,26 @@
256170 // Event handler -------------------------
257171 onMouseDownScale(evt) {
258172 this.debuglog('onMouseDownScale');
173+ let eleFocus = this.getFocusdElements();
174+ if (eleFocus < 2) return;
175+ evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
176+ evt.preventDefault(); // 要素既定のdefault動作を止める
259177
260178 // Mouse eventをappAreaからScalerに渡してもらうように設定
261- window.appArea.setMouseEventObj(this.mouseMoveScale.bind(this), this.mouseUpScale.bind(this));
179+ window.appArea.setMouseEventObj(null, this.mouseMoveScale.bind(this), this.mouseUpScale.bind(this));
262180
263181 // 移動元として座標を保持
264- this.scaleStartWidth = parseInt(this.clingingPartner.style.width);
265- this.scaleStartHeight = parseInt(this.clingingPartner.style.height);
182+ this.scaleStartWidth = parseInt(eleFocus[0].style.width);
183+ this.scaleStartHeight = parseInt(eleFocus[0].style.height);
266184 this.startDragX = evt.pageX;
267185 this.startDragY = evt.pageY;
268186 }
269187 mouseMoveScale(evt) {
188+ let eleFocus = this.getFocusdElements();
189+ if (eleFocus < 2) return;
190+ evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
191+ evt.preventDefault(); // 要素既定のdefault動作を止める
192+
270193 // 画像の仮変形
271194 this.endDragX = evt.pageX;
272195 this.endDragY = evt.pageY;
@@ -276,30 +199,33 @@
276199
277200 switch(1){
278201 case 0: // 領域サイズ変更のみ
279- this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY));
202+// this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY));
203+ window.renderLoop.requestRenderFunc(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY));
280204 break;
281205 case 1: // 縦倍率に合わせfont sizeも変更
282206 {
283- let orgwidth = parseInt(this.clingingPartner.dataset.orgwidth);
284- let orgheight = parseInt(this.clingingPartner.dataset.orgheight);
207+ let orgheight = parseInt(eleFocus[1].dataset.orgheight);
285208 let scaleY = (this.scaleStartHeight + moveY) / orgheight * 100; // ★さらに初期倍率設定値を掛ける必要がある
286- this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY, scaleY));
209+// this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY, scaleY));
210+ window.renderLoop.requestRenderFunc(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY, scaleY));
287211 }
288212 break;
289213 }
290214 }
291215 renderMouseMoveScale(width, height, scalefont) {
292- this.clingingPartner.style.opacity = 0.4;
216+ let eleFocus = this.getFocusdElements();
217+ if (eleFocus < 2) return;
218+ eleFocus[1].style.opacity = 0.4;
293219
294220 switch(1){
295221 case 0:
296- this.clingingPartner.style.width = width + "px";
297- this.clingingPartner.style.height = height + "px";
222+ eleFocus[0].style.width = width + "px";
223+ eleFocus[0].style.height = height + "px";
298224 break;
299225 case 1:
300- this.clingingPartner.style.width = width + "px";
301- this.clingingPartner.style.height = height + "px";
302- this.clingingPartner.style.fontSize = scalefont + '%';
226+ eleFocus[0].style.width = width + "px";
227+ eleFocus[0].style.height = height + "px";
228+ eleFocus[1].style.fontSize = scalefont + '%';
303229 break;
304230 }
305231 }
@@ -306,8 +232,13 @@
306232 mouseUpScale(evt) {
307233 this.debuglog('mouseUpScale');
308234 // Mouse event callback設定をクリア
309- window.appArea.setMouseEventObj(null, null);
235+ window.appArea.setMouseEventObj(null, null, null);
310236
237+ let eleFocus = this.getFocusdElements();
238+ if (eleFocus < 2) return;
239+ evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
240+ evt.preventDefault(); // 要素既定のdefault動作を止める
241+
311242 // 画像の仮変形
312243 this.endDragX = evt.pageX;
313244 this.endDragY = evt.pageY;
@@ -317,7 +248,7 @@
317248
318249 let rectFrom = new rectData();
319250 let rectTo = new rectData();
320- rectFrom.setLTWH(parseInt(this.clingingPartner.style.left), parseInt(this.clingingPartner.style.top), this.scaleStartWidth, this.scaleStartHeight);
251+ rectFrom.setLTWH(parseInt(eleFocus[0].style.left), parseInt(eleFocus[0].style.top), this.scaleStartWidth, this.scaleStartHeight);
321252 rectTo.setLTWH(rectFrom.left, rectFrom.top, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY);
322253
323254 let scaleY = 1.0;
@@ -326,8 +257,8 @@
326257 break;
327258 case 1: // 縦倍率に合わせfont sizeも変更
328259 {
329- let orgwidth = parseInt(this.clingingPartner.dataset.orgwidth);
330- let orgheight = parseInt(this.clingingPartner.dataset.orgheight);
260+ let orgwidth = parseInt(eleFocus[1].dataset.orgwidth);
261+ let orgheight = parseInt(eleFocus[1].dataset.orgheight);
331262 scaleY = (this.scaleStartHeight + moveY) / orgheight * 100; // ★さらに初期倍率設定値を掛ける必要がある
332263 }
333264 break;
@@ -335,7 +266,7 @@
335266
336267 // Scale Command発行
337268 let cmd = new CCommandObj();
338- cmd.createCommand(cmdType.request, cmdAddress.Focus, cmdAddress.ObjIDMgr, cmdCmd.scalebox, this.clingingPartner.dataset.objid, rectFrom, rectTo, scaleY, 5);
269+ cmd.createCommand(cmdType.request, cmdAddress.Focus, cmdAddress.ObjIDMgr, cmdCmd.scalebox, eleFocus[0].dataset.objid, rectFrom, rectTo, scaleY, 5);
339270 this.debuglog("postToWorker");
340271 window.postToWorker.post(cmd);
341272 }
@@ -342,40 +273,75 @@
342273
343274 onMouseDownRoll(evt) {
344275 this.debuglog('onMouseDownRoll');
276+ evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
277+ evt.preventDefault(); // 要素既定のdefault動作を止める
345278
346279 // Mouse eventをappAreaからRollerに渡してもらうように設定
347- window.appArea.setMouseEventObj(this.mouseMoveRoll.bind(this), this.mouseUpRoll.bind(this));
280+ window.appArea.setMouseEventObj(null, this.mouseMoveRoll.bind(this), this.mouseUpRoll.bind(this));
348281 }
349282 mouseMoveRoll(evt) {
350- let x1 = parseInt(this.clingingPartner.style.left) + parseInt(this.clingingPartner.style.width) / 2;
351- let y1 = parseInt(this.clingingPartner.style.top) + parseInt(this.clingingPartner.style.height) / 2;
283+ let eleFocus = this.getFocusdElements();
284+ if (eleFocus < 2) return;
285+ evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
286+ evt.preventDefault(); // 要素既定のdefault動作を止める
287+
288+ let x1 = parseInt(eleFocus[0].style.left) + parseInt(eleFocus[0].style.width) / 2;
289+ let y1 = parseInt(eleFocus[0].style.top) + parseInt(eleFocus[0].style.height) / 2;
352290 let x2 = evt.pageX;
353291 let y2 = evt.pageY;
354292 let degree = angle(x2, y2, x1, y1);
355293
356- this.renderFunc.enqueue(this.renderMouseMoveRoll.bind(this, degree));
294+// this.renderFunc.enqueue(this.renderMouseMoveRoll.bind(this, degree));
295+ window.renderLoop.requestRenderFunc(this.renderMouseMoveRoll.bind(this, degree));
357296 }
358297 renderMouseMoveRoll(degree) {
359- this.clingingPartner.style.transform = 'rotateZ(' + degree + 'deg);';
298+ let eleFocus = this.getFocusdElements();
299+ if (eleFocus < 2) return;
300+
301+ eleFocus[0].style.transform = 'rotateZ(' + degree + 'deg);';
360302 }
361303 mouseUpRoll(evt) {
362304 this.debuglog('mouseUpRoll');
363305 // Mouse event callback設定をクリア
364- window.appArea.setMouseEventObj(null, null);
306+ window.appArea.setMouseEventObj(null, null, null);
307+ let eleFocus = this.getFocusdElements();
308+ if (eleFocus < 2) return;
309+ evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
310+ evt.preventDefault(); // 要素既定のdefault動作を止める
365311
366- let x1 = parseInt(this.clingingPartner.style.left) + parseInt(this.clingingPartner.style.width) / 2;
367- let y1 = parseInt(this.clingingPartner.style.top) + parseInt(this.clingingPartner.style.height) / 2;
312+ let x1 = parseInt(eleFocus[0].style.left) + parseInt(eleFocus[0].style.width) / 2;
313+ let y1 = parseInt(eleFocus[0].style.top) + parseInt(eleFocus[0].style.height) / 2;
368314 let x2 = evt.pageX;
369315 let y2 = evt.pageY;
370316 let degree = angle(x2, y2, x1, y1);
371317 // this.debuglog('■■ x1=' + x1 + ', y1=' + y1 + ',\nx2=' + x2 + ', y2=' + y2 + '\nangle=' + degree);
372- // window.ObjIDMgr.rollbox( this.clingingPartner.dataset.objid, degree ); // debug用 設定情報で直接表示
318+ // window.ObjIDMgr.rollbox( eleFocus[0].dataset.objid, degree ); // debug用 設定情報で直接表示
373319
374320 // Rotate command発行
375321 let cmd = new CCommandObj();
376- cmd.createCommand(cmdType.request, cmdAddress.Focus, cmdAddress.ObjIDMgr, cmdCmd.rollbox, this.clingingPartner.dataset.objid, degree, null, null, 6);
322+ cmd.createCommand(cmdType.request, cmdAddress.Focus, cmdAddress.ObjIDMgr, cmdCmd.rollbox, eleFocus[0].dataset.objid, degree, null, null, 6);
377323 this.debuglog("postToWorker");
378324 window.postToWorker.post(cmd);
379325 }
380326
327+
328+
329+
330+
331+
332+
333+ getFocusdElements() {
334+ let eleBase = this.clingingPartner;
335+ if (null == eleBase) {
336+ console.error('変形処理失敗 操作対象要素が見つからない PartsFocus');
337+ return [];
338+ }
339+ if (eleBase.children.length < 1) {
340+ console.error('変形処理失敗 表示要素が見つからない PartsFocus base element objid=' + eleBalse.dataset.objid + ', className=' + eleBase.className);
341+ return [];
342+ }
343+ let eleDisp = eleBase.children[0];
344+
345+ return [eleBase, eleDisp];
346+ }
381347 } // class CPartsFocus
--- HtmlDrawApp/HTMLDrawApp/js/apparea.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/js/apparea.js (revision 32)
@@ -26,10 +26,27 @@
2626
2727 // 操作関数 -----------------------------------
2828
29- // Mouse eventを処理するObj
30- setMouseEventObj(mouseMove, mouseUp) {
31- this.debuglog('setMouseEventObj callbackMove=' + ((null != mouseMove)? mouseMove.name: 'null') + ', callbackUp=' + ((null != mouseUp)? mouseUp.name: 'null'));
29+ // Mouse eventを拾ったときに通知してほしいときにセット
30+ // 上書きすると前に設定されていた callbackが消えます
31+ // callback: function mouseMove( evt ) move eventの evt.targetは目的のelementでない場合が多いため検索しない
32+ // callback: function mouseUp( evt, strclassElement ) elementが見つからなければ null
33+ setMouseEventObj(
34+ strclass, // mouse up callback 第2引数 targetとして返してほしいelementが持つ css class名
35+ mouseMove, // mouse moveで呼んでほしい関数 or null
36+ mouseUp // mouse upで呼んでほしい関数 or null
37+ ) {
38+ this.debuglog('setMouseEventObj strclass=' + strclass + ', callbackMove=' + ((null != mouseMove)? mouseMove.name: 'null') + ', callbackUp=' + ((null != mouseUp)? mouseUp.name: 'null'));
3239
40+ // Callbackを上書きしてしまう場合はエラー出力し、ひとまず処理を継続
41+ if (null != mouseMove || null != mouseUp) {
42+ if (null != this.mouseMoveFunc || null != this.mouseUpFunc) {
43+ console.error('マウスイベント callback設定上書き \n\
44+Before strclass=' + this.strclass + 'callbackMove=' + (this.mouseMoveFunc ? this.mouseMoveFunc.name : 'null') + ', callbackUp=' + (this.mouseUpFunc ? this.mouseUpFunc.name : 'null') + '\n\
45+After strclass=' + strclass + 'callbackMove=' + ((null != mouseMove) ? mouseMove.name : 'null') + ', callbackUp=' + ((null != mouseUp) ? mouseUp.name : 'null'));
46+ }
47+ }
48+
49+ this.strclass = strclass;
3350 this.mouseMoveFunc = mouseMove;
3451 this.mouseUpFunc = mouseUp;
3552 }
@@ -38,25 +55,27 @@
3855
3956 // ■マウス左ボタン押下 (Drag処理)
4057 onMouseDown(evt) {
58+ this.debuglog('マウスクリック onMouseDown()');
4159 }
4260 // ■ マウス移動 (ドラッグ中)
4361 onMouseMove(evt) {
44- // ★ evt.targetが期待するelementかチェックする必要がある
45- // ★ 期待するelementではない場合、DOM treeを辿って親elementから該当elementを探す必要がある
4662
4763 if (null != this.mouseMoveFunc) {
4864 this.mouseMoveFunc(evt);
49- return;
5065 }
5166 }
67+
5268 // ■ ドロップ処理
5369 onMouseUp(evt) {
54- // ★ evt.targetが期待するelementかチェックする必要がある
55- // ★ 期待するelementではない場合、DOM treeを辿って親elementから該当elementを探す必要がある
70+ this.debuglog('マウスアップ onMouseUp() findClass=' + this.strclass + ', callback move=' + (this.mouseMoveFunc ? this.mouseMoveFunc.name : 'null') + ', Up=' + (this.mouseUpFunc ? this.mouseUpFunc.name : 'null'));
71+ let e = findClassNameParent(this.strclass, evt.target);
72+ if (null == e) {
73+ console.error('マウスアップ 指定要素が見つからない findClass=' + this.strclass + ', callback move=' + (this.mouseMoveFunc ? this.mouseMoveFunc.name : 'null') + ', Up=' + (this.mouseUpFunc ? this.mouseUpFunc.name : 'null'));
74+ // ひとまず処理を継続する
75+ }
5676
5777 if (null != this.mouseUpFunc) {
58- this.mouseUpFunc(evt);
59- return;
78+ this.mouseUpFunc(evt, e);
6079 }
6180 }
6281
--- HtmlDrawApp/HTMLDrawApp/js/main.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/js/main.js (revision 32)
@@ -78,10 +78,10 @@
7878
7979
8080
81+ // 描画ループ
82+ window.renderLoop = new RenderLoop();
8183
82-
83-
84-
84+ /*
8585 // 画像読み込み等は待たずに実行開始
8686 window.startTime = window.performance.now();
8787 window.frameLength = 6.0;
@@ -91,7 +91,7 @@
9191 // let frame = Math.floor((nowTime - window.startTime) / (1000.0 / 60.0) % window.frameLength);
9292
9393 // Canvas area描画 (div tag)
94- window.displayField.render();
94+// window.displayField.render();
9595 // 各表示要素の描画 (div, img tag)
9696 window.ObjIDMgr.renderAll();
9797
@@ -103,10 +103,10 @@
103103
104104 requestAnimationFrame( renderLoop );
105105 })();
106+ */
106107
107108
108109
109-
110110 // worker threadからの Message受信関数
111111 // UI threadで処理が必要な commandが送られてくる
112112 function receiveWorkerMessage(evt) {
--- HtmlDrawApp/HTMLDrawApp/js/palette.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/js/palette.js (revision 32)
@@ -10,7 +10,7 @@
1010 constructor() {
1111 this.DOMobject = [];
1212 this.draggingDOM = null;
13- this.renderFunc = new Queue();
13+// this.renderFunc = new Queue();
1414 }
1515
1616 debuglog(str) {
@@ -146,7 +146,7 @@
146146 }
147147 }
148148
149-
149+ /*
150150 // 描画関数 ---------------------
151151
152152 render() {
@@ -155,6 +155,7 @@
155155 renderFunction();
156156 }
157157 }
158+ */
158159
159160 // Event handler -----------------------
160161
@@ -202,8 +203,8 @@
202203 evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
203204 evt.preventDefault(); // 要素既定のdefault動作を止める
204205
205- // Mouse eventをappAreaからCSSPalに渡してもらうように設定
206- window.appArea.setMouseEventObj(this.mouseMove.bind(this), this.mouseUp.bind(this));
206+ // Mouse eventをappAreaからCSSPalに渡してもらうように設定 (evt.targetは必ずpalette要素である前提。子要素なし。)
207+ window.appArea.setMouseEventObj(evt.target.dataset.objid, this.mouseMove.bind(this), this.mouseUp.bind(this));
207208
208209 // Drag対象を保持
209210 this.draggingDOM = evt.target;
@@ -229,7 +230,8 @@
229230 moveX = this.startElementX + moveX;
230231 moveY = this.startElementY + moveY;
231232
232- this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
233+// this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
234+ window.renderLoop.requestRenderFunc(this.renderMoveDragging.bind(this, moveX, moveY));
233235 //this.renderMoveDragging(moveX, moveY);
234236 }
235237 renderMoveDragging(x, y) {
@@ -256,7 +258,7 @@
256258 // Drag中 element情報をクリア
257259 this.draggingDOM = null;
258260 // Mouse event callback設定をクリア
259- window.appArea.setMouseEventObj(null, null);
261+ window.appArea.setMouseEventObj(null, null, null);
260262
261263 // マウス座標直下にある要素を検索
262264 // (evt.targetは自分を指してしまうため)
--- HtmlDrawApp/HTMLDrawApp/js/palgroup.js (revision 31)
+++ HtmlDrawApp/HTMLDrawApp/js/palgroup.js (revision 32)
@@ -16,7 +16,7 @@
1616 this.typeAction = 2;
1717
1818 this.DOMobject = []; // bg,text,action
19- this.renderFunc = new Queue();
19+// this.renderFunc = new Queue();
2020 }
2121 debuglog(str) {
2222 debuglog('【PalGroup】 ' + str);
@@ -44,7 +44,7 @@
4444 }
4545
4646
47-
47+ /*
4848 // 描画関数 ---------------------
4949
5050 render() {
@@ -53,14 +53,14 @@
5353 renderFunction();
5454 }
5555 }
56+ */
5657
5758
58-
5959 // Event handler -----------------------
6060
6161 onMouseDown(evt) {
6262 // Mouse eventをappAreaからCSSPalに渡してもらうように設定
63- window.appArea.setMouseEventObj(this.mouseMove.bind(this), null);
63+ window.appArea.setMouseEventObj(null, this.mouseMove.bind(this), null);
6464 evt.stopPropagation(); // event伝播を自分のところで止める(上位に行かなくなる)
6565 evt.preventDefault(); // 要素既定のdefault動作を止める
6666
@@ -88,7 +88,8 @@
8888 moveX = this.startElementX + moveX;
8989 moveY = this.startElementY + moveY;
9090
91- this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
91+// this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
92+ window.renderLoop.requestRenderFunc(this.renderMoveDragging.bind(this, moveX, moveY));
9293 //this.renderMoveDragging(moveX, moveY);
9394 }
9495 renderMoveDragging(x, y) {
@@ -106,7 +107,7 @@
106107 // Drag中 element情報をクリア
107108 this.draggingDOM = null;
108109 // Mouse event callback設定をクリア
109- window.appArea.setMouseEventObj(null, null);
110+ window.appArea.setMouseEventObj(null, null, null);
110111 }
111112
112113