-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
645 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,6 +236,7 @@ | |
#draw-text | ||
{ | ||
position : absolute; | ||
border : 1px dashed #363636; | ||
pointer-events : none; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/js/screen/application/TextRect/service/TextRectHideService.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { execute } from "./TextRectHideService"; | ||
import { $SCREEN_DRAW_TEXT_ID } from "../../../../config/ScreenConfig"; | ||
|
||
describe("TextRectHideServiceTest", () => | ||
{ | ||
test("execute test", () => | ||
{ | ||
const parent = document.createElement("div"); | ||
parent.id = $SCREEN_DRAW_TEXT_ID; | ||
document.body.appendChild(parent); | ||
|
||
expect(parent.style.display).toBe(""); | ||
execute(); | ||
expect(parent.style.display).toBe("none"); | ||
|
||
parent.remove(); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
src/js/screen/application/TextRect/service/TextRectHideService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { $SCREEN_DRAW_TEXT_ID } from "@/config/ScreenConfig"; | ||
|
||
/** | ||
* @description 範囲選択を非表示に更新 | ||
* Update the range selection to be hidden | ||
* | ||
* @return {void} | ||
* @method | ||
* @public | ||
*/ | ||
export const execute = (): void => | ||
{ | ||
// 範囲選択のElementを表示 | ||
const element: HTMLElement | null = document | ||
.getElementById($SCREEN_DRAW_TEXT_ID); | ||
|
||
if (!element) { | ||
return ; | ||
} | ||
|
||
element.setAttribute("style", "display: none;"); | ||
}; |
19 changes: 19 additions & 0 deletions
19
src/js/screen/application/TextRect/service/TextRectShowService.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { execute } from "./TextRectShowService"; | ||
import { $SCREEN_DRAW_TEXT_ID } from "../../../../config/ScreenConfig"; | ||
|
||
describe("TextRectShowServiceTest", () => | ||
{ | ||
test("execute test", () => | ||
{ | ||
const parent = document.createElement("div"); | ||
parent.id = $SCREEN_DRAW_TEXT_ID; | ||
document.body.appendChild(parent); | ||
|
||
parent.style.display = "none"; | ||
expect(parent.style.display).toBe("none"); | ||
execute(); | ||
expect(parent.style.display).toBe(""); | ||
|
||
parent.remove(); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
src/js/screen/application/TextRect/service/TextRectShowService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { $SCREEN_DRAW_TEXT_ID } from "@/config/ScreenConfig"; | ||
import { textRect } from "@/screen/domain/model/TextRect"; | ||
|
||
/** | ||
* @description 範囲選択をアクティブ表示 | ||
* Active display of range selection | ||
* | ||
* @param {number} x | ||
* @param {number} y | ||
* @param {string} [radius=""] | ||
* @return {void} | ||
* @method | ||
* @public | ||
*/ | ||
export const execute = (x: number, y: number): void => | ||
{ | ||
// 範囲選択のElementを表示 | ||
const element: HTMLElement | null = document | ||
.getElementById($SCREEN_DRAW_TEXT_ID); | ||
|
||
if (!element) { | ||
return ; | ||
} | ||
|
||
textRect.x = x; | ||
textRect.y = y; | ||
|
||
// 表示を更新 | ||
let style = ""; | ||
style += `left: ${x}px;`; | ||
style += `top: ${y}px;`; | ||
style += "width: 0px;"; | ||
style += "height: 0px;"; | ||
|
||
element.setAttribute("style", style); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* @description テキストの範囲選択の管理クラス | ||
* Text range selection management class | ||
* | ||
* @class | ||
* @public | ||
*/ | ||
class TextRect | ||
{ | ||
private _$x: number; | ||
private _$y: number; | ||
|
||
/** | ||
* @constructor | ||
* @public | ||
*/ | ||
constructor () | ||
{ | ||
/** | ||
* @type {number} | ||
* @private | ||
*/ | ||
this._$x = 0; | ||
|
||
/** | ||
* @type {number} | ||
* @private | ||
*/ | ||
this._$y = 0; | ||
} | ||
|
||
/** | ||
* @description x座標 | ||
* x coordinate | ||
* | ||
* @type {number} | ||
* @public | ||
*/ | ||
get x (): number | ||
{ | ||
return this._$x; | ||
} | ||
set x (x: number) | ||
{ | ||
this._$x = x; | ||
} | ||
|
||
/** | ||
* @description y座標 | ||
* y coordinate | ||
* | ||
* @type {number} | ||
* @public | ||
*/ | ||
get y (): number | ||
{ | ||
return this._$y; | ||
} | ||
set y (y: number) | ||
{ | ||
this._$y = y; | ||
} | ||
} | ||
|
||
export const textRect = new TextRect(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/js/tool/application/TextTool/service/TextToolActiveService.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { $TOOL_TEXT_NAME } from "../../../../config/ToolConfig"; | ||
import { execute } from "./TextToolActiveService"; | ||
import { $setActiveTool, $getActiveTool, $registerDefaultTool } from "../../ToolUtil"; | ||
|
||
describe("TextToolActiveServiceTest", () => | ||
{ | ||
test("execute test", () => | ||
{ | ||
const mock1 = { | ||
"dispatchEvent": () => {}, | ||
"name": "mock1" | ||
}; | ||
$registerDefaultTool(mock1); | ||
|
||
const mock2 = { | ||
"dispatchEvent": () => {}, | ||
"name": $TOOL_TEXT_NAME | ||
}; | ||
$registerDefaultTool(mock2); | ||
|
||
// test case mock1 | ||
$setActiveTool(mock1); | ||
expect($getActiveTool().name).toBe(mock1.name); | ||
|
||
execute(); | ||
|
||
expect($getActiveTool().name).toBe(mock2.name); | ||
}); | ||
|
||
}); |
22 changes: 22 additions & 0 deletions
22
src/js/tool/application/TextTool/service/TextToolActiveService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { $TOOL_TEXT_NAME } from "@/config/ToolConfig"; | ||
import { $getDefaultTool, $setActiveTool } from "../../ToolUtil"; | ||
import type { TextTool } from "@/tool/domain/model/TextTool"; | ||
import type { ToolImpl } from "@/interface/ToolImpl"; | ||
|
||
/** | ||
* @description テキストツールをアクティブにする | ||
* Make the text tool active | ||
* | ||
* @return {void} | ||
* @method | ||
* @public | ||
*/ | ||
export const execute = (): void => | ||
{ | ||
const tool: ToolImpl<TextTool> = $getDefaultTool($TOOL_TEXT_NAME); | ||
if (!tool) { | ||
return ; | ||
} | ||
|
||
$setActiveTool(tool); | ||
}; |
29 changes: 29 additions & 0 deletions
29
src/js/tool/application/TextTool/service/TextToolChangeCursorEventService.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { execute } from "./TextToolChangeCursorEventService"; | ||
import { $registerDefaultTool } from "../../ToolUtil"; | ||
import { $TOOL_TEXT_NAME } from "../../../../config/ToolConfig"; | ||
|
||
describe("TextToolChangeCursorEventServiceTest", () => | ||
{ | ||
test("execute test", () => | ||
{ | ||
const mock = { | ||
"name": $TOOL_TEXT_NAME, | ||
"cursor": "crosshair" | ||
}; | ||
$registerDefaultTool(mock); | ||
|
||
const style = document | ||
.documentElement | ||
.style; | ||
|
||
style.setProperty("--tool-cursor", "auto"); | ||
|
||
// test case mock1 | ||
expect(style.getPropertyValue("--tool-cursor")).toBe("auto"); | ||
|
||
execute(); | ||
|
||
expect(style.getPropertyValue("--tool-cursor")).toBe(mock.cursor); | ||
}); | ||
|
||
}); |
23 changes: 23 additions & 0 deletions
23
src/js/tool/application/TextTool/service/TextToolChangeCursorEventService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { ToolImpl } from "@/interface/ToolImpl"; | ||
import type { TextTool } from "@/tool/domain/model/TextTool"; | ||
import { $setCursor } from "@/global/GlobalUtil"; | ||
import { $getDefaultTool } from "../../ToolUtil"; | ||
import { $TOOL_TEXT_NAME } from "@/config/ToolConfig"; | ||
|
||
/** | ||
* @description カーソルを変更する | ||
* Change the cursor | ||
* | ||
* @return {void} | ||
* @method | ||
* @public | ||
*/ | ||
export const execute = (): void => | ||
{ | ||
const tool: ToolImpl<TextTool> = $getDefaultTool($TOOL_TEXT_NAME); | ||
if (!tool) { | ||
return ; | ||
} | ||
|
||
$setCursor(tool.cursor); | ||
}; |
24 changes: 24 additions & 0 deletions
24
src/js/tool/application/TextTool/service/TextToolMouseOutEventService.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { execute } from "./TextToolMouseOutEventService"; | ||
import { $setCursor } from "../../../../global/GlobalUtil"; | ||
|
||
describe("TextToolMouseOutEventServiceTest", () => | ||
{ | ||
test("execute test", () => | ||
{ | ||
$setCursor("test"); | ||
|
||
const style = document | ||
.documentElement | ||
.style; | ||
|
||
// test case mock1 | ||
expect(style.getPropertyValue("--tool-cursor")).toBe("test"); | ||
|
||
execute({ | ||
"stopPropagation": () => {}, | ||
"preventDefault": () => {} | ||
}); | ||
|
||
expect(style.getPropertyValue("--tool-cursor")).toBe("auto"); | ||
}); | ||
}); |
Oops, something went wrong.