!328 优化动态提示框的位置

Merge pull request !328 from 肖诗雅/promptBlock_pos_merge
pull/328/MERGE
肖诗雅 5 years ago committed by ChenX
parent 48e3a20e21
commit 2109b8ac3f

@ -7,8 +7,8 @@ export enum ZINDEX
MainContent = "35", //主要内容的层级 MainContent = "35", //主要内容的层级
ToolBar = "2", //工具栏 ToolBar = "2", //工具栏
BluePortal = "30", //蓝图模态框默认值 BluePortal = "30", //蓝图模态框默认值
RightMenu = "30",//右键菜单
Portal = "38",//PopOver 见"DoorModal.less" Portal = "38",//PopOver 见"DoorModal.less"
RightMenu = "31",//右键菜单
ToolsBlock_small = "32", ToolsBlock_small = "32",
CommandInput = "28", CommandInput = "28",
TransparentTerminal = "0", TransparentTerminal = "0",

@ -13,6 +13,8 @@ import { PromptResult, PromptStatus } from './PromptResult';
import { FixIndex } from '../Common/Utils'; import { FixIndex } from '../Common/Utils';
import { KeyWordContextMenu } from '../UI/Components/ContextMenu/KeyWordContextMenu'; import { KeyWordContextMenu } from '../UI/Components/ContextMenu/KeyWordContextMenu';
const MENU_PADDING = 20;
const MENU_ITEM_HEIGHT = 30;
/** /**
* . * .
* *
@ -68,8 +70,13 @@ export class GetKeyWordsServices implements EditorService
//更新上下文菜单的位置 //更新上下文菜单的位置
private UpdateContextMenuPosition() private UpdateContextMenuPosition()
{ {
this.mousePositionX = this.ed.m_MouseCtrl.m_CurMousePointVCS.x; let menuHeight = this.keywordList.length * MENU_ITEM_HEIGHT + MENU_PADDING;
this.mousePositionY = this.ed.m_MouseCtrl.m_CurMousePointVCS.y;
if (this.ed.m_MouseCtrl.m_CurMousePointClient.y > window.innerHeight - menuHeight)
this.mousePositionY = this.ed.m_MouseCtrl.m_CurMousePointClient.y - menuHeight;
else
this.mousePositionY = this.ed.m_MouseCtrl.m_CurMousePointClient.y;
this.mousePositionX = this.ed.m_MouseCtrl.m_CurMousePointClient.x;
} }
Start(prompt: GetKeyWordPrommpt): Promise<PromptResult> Start(prompt: GetKeyWordPrommpt): Promise<PromptResult>
@ -86,11 +93,11 @@ export class GetKeyWordsServices implements EditorService
//默认所有的key为大写 //默认所有的key为大写
prompt.KeyWordList.forEach(k => k.key = k.key.toUpperCase()); prompt.KeyWordList.forEach(k => k.key = k.key.toUpperCase());
//初始化状态 //初始化状态
this.keywordList = prompt.KeyWordList;
this.UpdateContextMenuPosition(); this.UpdateContextMenuPosition();
this.selectIndex = 0; this.selectIndex = 0;
this.ed.m_InputState |= InputState.GetKeyWord; this.ed.m_InputState |= InputState.GetKeyWord;
this.IsReady = true; this.IsReady = true;
this.keywordList = prompt.KeyWordList;
this.prompt = prompt.Msg; this.prompt = prompt.Msg;
this.InitHandleInput(prompt); this.InitHandleInput(prompt);
//初始化键盘输入 //初始化键盘输入

@ -8,6 +8,7 @@ import { Editor } from './Editor';
export class MouseControls export class MouseControls
{ {
m_CurMousePointClient: Vector3 = new Vector3();
//当前鼠标的位置 屏幕 //当前鼠标的位置 屏幕
m_CurMousePointVCS: Vector3 = new Vector3(); m_CurMousePointVCS: Vector3 = new Vector3();
//世界坐标系 //世界坐标系
@ -56,6 +57,7 @@ export class MouseControls
} }
updateWordPoint = (e: MouseEvent) => updateWordPoint = (e: MouseEvent) =>
{ {
this.m_CurMousePointClient.set(e.clientX, e.clientY, 0);
this.m_CurMousePointVCS.set(e.offsetX, e.offsetY, 0); this.m_CurMousePointVCS.set(e.offsetX, e.offsetY, 0);
this.m_CurMousePointWCS.copy(this.m_CurMousePointVCS); this.m_CurMousePointWCS.copy(this.m_CurMousePointVCS);
this.viewer.ScreenToWorld(this.m_CurMousePointWCS); this.viewer.ScreenToWorld(this.m_CurMousePointWCS);

@ -28,7 +28,7 @@ export class KeyWordContextMenu extends React.Component<{ keywordStore?: GetKeyW
{ {
minWidth: "100px", minWidth: "100px",
display: store.IsReady ? "block" : "none", display: store.IsReady ? "block" : "none",
position: "fixed", position: "absolute",
left: `${store.mousePositionX}px`, left: `${store.mousePositionX}px`,
top: `${store.mousePositionY}px`, top: `${store.mousePositionY}px`,
cursor: "default", cursor: "default",

@ -23,7 +23,7 @@ export class DynamicInputManage
this.container = document.createElement("div"); this.container = document.createElement("div");
this.container.style.pointerEvents = "none"; this.container.style.pointerEvents = "none";
this.container.style.position = "fixed"; this.container.style.position = "absolute";
this.container.style.zIndex = "10"; this.container.style.zIndex = "10";
this.container.style.width = "100%"; this.container.style.width = "100%";
this.container.style.height = "100%"; this.container.style.height = "100%";
@ -32,7 +32,7 @@ export class DynamicInputManage
this.container.addEventListener("mousedown", () => { this.IsInputing = false }); this.container.addEventListener("mousedown", () => { this.IsInputing = false });
document.body.appendChild(this.container); document.getElementById("Webgl").appendChild(this.container);
this.RegisterEvent(); this.RegisterEvent();

@ -1,7 +1,9 @@
import { DynamicInputManage } from './DynamicInputManage'; import { DynamicInputManage } from './DynamicInputManage';
import { DynamicInput } from './DynamicInputBase'; import { DynamicInput } from './DynamicInputBase';
import { Vector3 } from "three"; import { Vector3 } from "three";
import { app } from '../../ApplicationServices/Application';
const MINUS_HEIGHT = 46;
/** /**
* , . * , .
* *
@ -21,7 +23,7 @@ export class PromptBlock
this.dynamicInputManage = dynamicInputManage; this.dynamicInputManage = dynamicInputManage;
//容器 //容器
this.promptContainer = document.createElement("div"); this.promptContainer = document.createElement("div");
this.promptContainer.style.position = "fixed"; this.promptContainer.style.position = "absolute";
this.promptContainer.style.fontSize = "15px"; this.promptContainer.style.fontSize = "15px";
//提示 //提示
this.promptEl = document.createElement('label'); this.promptEl = document.createElement('label');
@ -54,11 +56,15 @@ export class PromptBlock
if (this.dynamicInputManage.IsInputing) return; if (this.dynamicInputManage.IsInputing) return;
//设置 promptEl 的位置. //设置 promptEl 的位置.
let promptElX = mousePos.x + 20; let promptElX = mousePos.x + 20;
let promptElY = mousePos.y + 90; let promptElY = mousePos.y + 20;
this.promptContainer.style.left = promptElX + "px"; if (promptElY > app.m_Viewer.Height - MINUS_HEIGHT)
this.promptContainer.style.top = mousePos.y - 40 + "px";
else
this.promptContainer.style.top = promptElY + "px"; this.promptContainer.style.top = promptElY + "px";
this.promptContainer.style.left = promptElX + "px";
this.dynamicInputManage.Focus(); this.dynamicInputManage.Focus();
} }
public UpdatePrompt(prompt: string) public UpdatePrompt(prompt: string)

Loading…
Cancel
Save