• 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

Revision16 (tree)
Time2016-11-15 08:19:19
Authortakoyaki_umaaaa

Log Message

textboxサイズ変更方法変更中

Change Summary

Incremental Difference

--- HtmlDrawApp/HTMLDrawApp/bin/Debug/AppX/js/DispObj.js (revision 15)
+++ HtmlDrawApp/HTMLDrawApp/bin/Debug/AppX/js/DispObj.js (revision 16)
@@ -15,6 +15,9 @@
1515 this.DOMobject = null;
1616 this.renderFunc = new Queue();
1717
18+ this.originalWidth = 0;
19+ this.originalHeight = 0;
20+
1821 this.dropinitsize = 100.0;
1922 }
2023
@@ -60,11 +63,16 @@
6063 this.y = rect.top;
6164 this.width = rect.right - rect.left;
6265 this.height = rect.bottom - rect.top;
66+ this.originalWidth = this.width;
67+ this.originalHeight = this.height;
6368
6469 // 画面に影響しない範囲で作成できるところまで Dom objectを作成する
6570 let elType = (null != type.match(/imagebox/)) ? 'img' : 'div';
6671 this.DOMobject = document.createElement(elType);
6772 this.DOMobject.dataset.objid = this.ObjID;
73+ this.DOMobject.dataset.orgwidth = this.originalWidth; // transform: scaleの基準サイズ
74+ this.DOMobject.dataset.orgheight = this.originalHeight;
75+ this.DOMobject.dataset.degree = 0;
6876 this.DOMobject.addEventListener('mousedown', this.onMouseDown.bind(this), false);
6977 if (null != type.match(/imagebox/)) {
7078 // imageの場合、画像読み込み完了後に描画する必要がある
@@ -100,10 +108,14 @@
100108 this.DOMobject.src = evt.target.result;
101109 this.DOMobject.onload = function (evt) {
102110 // 画像としての読み込み完了後に幅と高さが取れる
103- //
111+ // 大きすぎ/小さすぎても困るため初期サイズに収まるように拡大/縮小
104112 let rect = this.calcImageWH(parseInt(evt.target.naturalWidth), parseInt(evt.target.naturalHeight));
105113 this.width = rect.right - rect.left;
106114 this.height = rect.bottom - rect.top;
115+ this.originalWidth = this.width;
116+ this.originalHeight = this.height;
117+ this.DOMobject.dataset.orgwidth = this.originalWidth; // transform: scaleの基準サイズ
118+ this.DOMobject.dataset.orgheight = this.originalHeight;
107119 // 表示サイズ取得完了したので画面に表示
108120 this.renderFunc.enqueue(this.renderCreate.bind(this));
109121 }.bind(this);
@@ -182,6 +194,7 @@
182194
183195 rollbox(degree) {
184196 this.degree = degree;
197+ this.DOMobject.dataset.degree = degree;
185198 this.renderFunc.enqueue(this.renderrollbox.bind(this));
186199 }
187200 renderrollbox() {
@@ -228,6 +241,7 @@
228241 // dispObjがあった位置からマウス移動分移動させた後の位置取得
229242 moveX = this.x + moveX;
230243 moveY = this.y + moveY;
244+
231245 this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
232246 }
233247 renderMoveDragging(x, y) {
--- HtmlDrawApp/HTMLDrawApp/bin/Debug/AppX/js/UI_parts.js (revision 15)
+++ HtmlDrawApp/HTMLDrawApp/bin/Debug/AppX/js/UI_parts.js (revision 16)
@@ -40,7 +40,7 @@
4040
4141 let originX = parseInt(this.clingingPartner.style.width) / 2;
4242 let originY = parseInt(this.clingingPartner.style.height) / 2;
43-
43+ // DOM 描画先rect 回転の中心位置
4444 this.renderClingingSetPosition(this.DOM[0], this.getRectLeft(), (originX + this.lineWidth / 2) + 'px', '50%');
4545 this.renderClingingSetPosition(this.DOM[1], this.getRectTop(), '50%', (originY + this.lineWidth / 2) + 'px');
4646 this.renderClingingSetPosition(this.DOM[2], this.getRectRight(), (originX - this.lineWidth / 2) * -1 + 'px', '50%');
@@ -268,12 +268,49 @@
268268 // 移動量取得
269269 let moveX = this.endDragX - this.startDragX;
270270 let moveY = this.endDragY - this.startDragY;
271- this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY));
271+
272+ switch(2){
273+ case 0:
274+ this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY));
275+ break;
276+ case 1:
277+ {
278+ let orgwidth = parseInt(this.clingingPartner.dataset.orgwidth);
279+ let orgheight = parseInt(this.clingingPartner.dataset.orgheight);
280+ let scaleX = (orgwidth + moveX) / orgwidth;
281+ let scaleY = (orgheight + moveY) / orgheight;
282+
283+ this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, scaleX, scaleY));
284+ }
285+ break;
286+ case 2:
287+ {
288+ let orgwidth = parseInt(this.clingingPartner.dataset.orgwidth);
289+ let orgheight = parseInt(this.clingingPartner.dataset.orgheight);
290+ let scaleX = (this.scaleStartWidth + moveX) / orgwidth;
291+ let scaleY = (this.scaleStartHeight + moveY) / orgheight;
292+ this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY, scaleX, scaleY));
293+ }
294+ break;
295+ }
272296 }
273- renderMouseMoveScale(width, height) {
274- this.clingingPartner.style.width = width + "px";
275- this.clingingPartner.style.height = height + "px";
297+ renderMouseMoveScale(width, height, scalex, scaley) {
276298 this.clingingPartner.style.opacity = 0.4;
299+
300+ switch(2){
301+ case 0:
302+ this.clingingPartner.style.width = width + "px";
303+ this.clingingPartner.style.height = height + "px";
304+ break;
305+ case 1:
306+ this.clingingPartner.style.transform = 'scaleX(' + width + ') scaleY(' + height + ') rotateZ(' + parseInt(this.clingingPartner.dataset.degree) + 'deg);';
307+ break;
308+ case 2:
309+ this.clingingPartner.style.width = width + "px";
310+ this.clingingPartner.style.height = height + "px";
311+ this.clingingPartner.style.fontSize = (scaley * 100) + '%';
312+ break;
313+ }
277314 }
278315 mouseUpScale(evt) {
279316 this.debuglog('mouseUpScale');
--- HtmlDrawApp/HTMLDrawApp/js/DispObj.js (revision 15)
+++ HtmlDrawApp/HTMLDrawApp/js/DispObj.js (revision 16)
@@ -15,6 +15,9 @@
1515 this.DOMobject = null;
1616 this.renderFunc = new Queue();
1717
18+ this.originalWidth = 0;
19+ this.originalHeight = 0;
20+
1821 this.dropinitsize = 100.0;
1922 }
2023
@@ -60,11 +63,16 @@
6063 this.y = rect.top;
6164 this.width = rect.right - rect.left;
6265 this.height = rect.bottom - rect.top;
66+ this.originalWidth = this.width;
67+ this.originalHeight = this.height;
6368
6469 // 画面に影響しない範囲で作成できるところまで Dom objectを作成する
6570 let elType = (null != type.match(/imagebox/)) ? 'img' : 'div';
6671 this.DOMobject = document.createElement(elType);
6772 this.DOMobject.dataset.objid = this.ObjID;
73+ this.DOMobject.dataset.orgwidth = this.originalWidth; // transform: scaleの基準サイズ
74+ this.DOMobject.dataset.orgheight = this.originalHeight;
75+ this.DOMobject.dataset.degree = 0;
6876 this.DOMobject.addEventListener('mousedown', this.onMouseDown.bind(this), false);
6977 if (null != type.match(/imagebox/)) {
7078 // imageの場合、画像読み込み完了後に描画する必要がある
@@ -100,10 +108,14 @@
100108 this.DOMobject.src = evt.target.result;
101109 this.DOMobject.onload = function (evt) {
102110 // 画像としての読み込み完了後に幅と高さが取れる
103- //
111+ // 大きすぎ/小さすぎても困るため初期サイズに収まるように拡大/縮小
104112 let rect = this.calcImageWH(parseInt(evt.target.naturalWidth), parseInt(evt.target.naturalHeight));
105113 this.width = rect.right - rect.left;
106114 this.height = rect.bottom - rect.top;
115+ this.originalWidth = this.width;
116+ this.originalHeight = this.height;
117+ this.DOMobject.dataset.orgwidth = this.originalWidth; // transform: scaleの基準サイズ
118+ this.DOMobject.dataset.orgheight = this.originalHeight;
107119 // 表示サイズ取得完了したので画面に表示
108120 this.renderFunc.enqueue(this.renderCreate.bind(this));
109121 }.bind(this);
@@ -182,6 +194,7 @@
182194
183195 rollbox(degree) {
184196 this.degree = degree;
197+ this.DOMobject.dataset.degree = degree;
185198 this.renderFunc.enqueue(this.renderrollbox.bind(this));
186199 }
187200 renderrollbox() {
@@ -228,6 +241,7 @@
228241 // dispObjがあった位置からマウス移動分移動させた後の位置取得
229242 moveX = this.x + moveX;
230243 moveY = this.y + moveY;
244+
231245 this.renderFunc.enqueue(this.renderMoveDragging.bind(this, moveX, moveY));
232246 }
233247 renderMoveDragging(x, y) {
--- HtmlDrawApp/HTMLDrawApp/js/UI_parts.js (revision 15)
+++ HtmlDrawApp/HTMLDrawApp/js/UI_parts.js (revision 16)
@@ -40,7 +40,7 @@
4040
4141 let originX = parseInt(this.clingingPartner.style.width) / 2;
4242 let originY = parseInt(this.clingingPartner.style.height) / 2;
43-
43+ // DOM 描画先rect 回転の中心位置
4444 this.renderClingingSetPosition(this.DOM[0], this.getRectLeft(), (originX + this.lineWidth / 2) + 'px', '50%');
4545 this.renderClingingSetPosition(this.DOM[1], this.getRectTop(), '50%', (originY + this.lineWidth / 2) + 'px');
4646 this.renderClingingSetPosition(this.DOM[2], this.getRectRight(), (originX - this.lineWidth / 2) * -1 + 'px', '50%');
@@ -268,12 +268,49 @@
268268 // 移動量取得
269269 let moveX = this.endDragX - this.startDragX;
270270 let moveY = this.endDragY - this.startDragY;
271- this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY));
271+
272+ switch(2){
273+ case 0:
274+ this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY));
275+ break;
276+ case 1:
277+ {
278+ let orgwidth = parseInt(this.clingingPartner.dataset.orgwidth);
279+ let orgheight = parseInt(this.clingingPartner.dataset.orgheight);
280+ let scaleX = (orgwidth + moveX) / orgwidth;
281+ let scaleY = (orgheight + moveY) / orgheight;
282+
283+ this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, scaleX, scaleY));
284+ }
285+ break;
286+ case 2:
287+ {
288+ let orgwidth = parseInt(this.clingingPartner.dataset.orgwidth);
289+ let orgheight = parseInt(this.clingingPartner.dataset.orgheight);
290+ let scaleX = (this.scaleStartWidth + moveX) / orgwidth;
291+ let scaleY = (this.scaleStartHeight + moveY) / orgheight;
292+ this.renderFunc.enqueue(this.renderMouseMoveScale.bind(this, this.scaleStartWidth + moveX, this.scaleStartHeight + moveY, scaleX, scaleY));
293+ }
294+ break;
295+ }
272296 }
273- renderMouseMoveScale(width, height) {
274- this.clingingPartner.style.width = width + "px";
275- this.clingingPartner.style.height = height + "px";
297+ renderMouseMoveScale(width, height, scalex, scaley) {
276298 this.clingingPartner.style.opacity = 0.4;
299+
300+ switch(2){
301+ case 0:
302+ this.clingingPartner.style.width = width + "px";
303+ this.clingingPartner.style.height = height + "px";
304+ break;
305+ case 1:
306+ this.clingingPartner.style.transform = 'scaleX(' + width + ') scaleY(' + height + ') rotateZ(' + parseInt(this.clingingPartner.dataset.degree) + 'deg);';
307+ break;
308+ case 2:
309+ this.clingingPartner.style.width = width + "px";
310+ this.clingingPartner.style.height = height + "px";
311+ this.clingingPartner.style.fontSize = (scaley * 100) + '%';
312+ break;
313+ }
277314 }
278315 mouseUpScale(evt) {
279316 this.debuglog('mouseUpScale');
--- HtmlDrawApp/doc/FontSize相対指定.txt (nonexistent)
+++ HtmlDrawApp/doc/FontSize相対指定.txt (revision 16)
@@ -0,0 +1 @@
1+テ<span style="font-size:150%;color:red">キ<strong style="font-size:200%">ス</strong>ト</span><br>Text
\ No newline at end of file
--- HtmlDrawApp/doc/FontSize絶対指定.txt (nonexistent)
+++ HtmlDrawApp/doc/FontSize絶対指定.txt (revision 16)
@@ -0,0 +1 @@
1+テ<span style="font-size:20pt;color:red">キ<strong style="font-size:30pt">ス</strong>ト</span><br>Text
\ No newline at end of file
--- HtmlDrawApp/doc/PlaneText.txt (nonexistent)
+++ HtmlDrawApp/doc/PlaneText.txt (revision 16)
@@ -0,0 +1,2 @@
1+テキスト
2+Text
\ No newline at end of file