+export function ToolbarButton({children, disabled, ...props}) {
+ return
{children}
;
}
diff --git a/web/app/cad/actions/actionButtonBehavior.js b/web/app/cad/actions/actionButtonBehavior.js
new file mode 100644
index 00000000..9b7d3e29
--- /dev/null
+++ b/web/app/cad/actions/actionButtonBehavior.js
@@ -0,0 +1,12 @@
+
+import {TOKENS as ACTION_TOKENS} from "./actionSystemPlugin";
+
+export function mapActionBehavior(actionId) {
+ let actionRunToken = ACTION_TOKENS.actionRun(actionId);
+
+ return dispatch => ({
+ onClick: data => dispatch(actionRunToken, data),
+ onMouseEnter: ({pageX, pageY}) => dispatch(ACTION_TOKENS.SHOW_HINT_FOR, [actionId, pageX, pageY]),
+ onMouseLeave: () => dispatch(ACTION_TOKENS.SHOW_HINT_FOR, null)
+ });
+}
\ No newline at end of file
diff --git a/web/app/cad/actions/actionSystemPlugin.js b/web/app/cad/actions/actionSystemPlugin.js
index bea2637d..52ed23c3 100644
--- a/web/app/cad/actions/actionSystemPlugin.js
+++ b/web/app/cad/actions/actionSystemPlugin.js
@@ -40,7 +40,8 @@ export function activate(context) {
}
bus.subscribe(TOKENS.actionRun(action.id), (data) => action.invoke(context, data));
}
-
+
+ bus.enableState(TOKENS.HINT, null);
function registerAction(action) {
register(action);
}
@@ -48,16 +49,57 @@ export function activate(context) {
function registerActions(actions) {
actions.forEach(action => register(action));
}
-
+
+ synchActionHint(bus);
+
context.services.action = {run, registerAction, registerActions}
}
-export const TOKENS = {
- ACTION_STATE_NS: 'action.state',
- ACTION_APPEARANCE_NS: 'action.appearance',
- ACTION_RUN_NS: 'action.run',
+
+
+function synchActionHint(bus) {
- actionState: (actionId) => createToken(TOKENS.ACTION_STATE_NS, actionId),
- actionAppearance: (actionId) => createToken(TOKENS.ACTION_APPEARANCE_NS, actionId),
- actionRun: (actionId) => createToken(TOKENS.ACTION_RUN_NS, actionId),
+ let lastRequest = null;
+
+ // bus.subscribe(TOKENS.REQUEST_SHOW_HINT_FOR
+ bus.subscribe(TOKENS.SHOW_HINT_FOR, request => {
+ if (lastRequest !== null) {
+ if (request !== null) {
+ if (request[0] === lastRequest[0]) {
+ Object.assign(lastRequest, request);
+ return;
+ }
+ }
+ lastRequest.spoiled = true;
+ }
+ lastRequest = request;
+ if (request) {
+ setTimeout(() => {
+ if (!request.spoiled) {
+ let [actionId, x, y] = request;
+ let actionState = bus.getState(TOKENS.actionState(actionId));
+ let actionAppearance = bus.getState(TOKENS.actionAppearance(actionId));
+ if (actionState && actionAppearance) {
+ bus.dispatch(TOKENS.HINT, {
+ actionId, x: x + 10, y: y + 10,
+ info: actionAppearance.info,
+ hint: actionState.hint
+ });
+ }
+ }
+ }, 500);
+ } else {
+ bus.dispatch(TOKENS.HINT, null);
+ }
+ });
+}
+
+export const ACTION_NS = 'action';
+export const TOKENS = {
+ actionState: (actionId) => createToken(ACTION_NS, 'state', actionId),
+ actionAppearance: (actionId) => createToken(ACTION_NS, 'appearance', actionId),
+ actionRun: (actionId) => createToken(ACTION_NS, 'run', actionId),
+
+ SHOW_HINT_FOR: createToken(ACTION_NS, 'showHintFor'),
+ HINT: createToken(ACTION_NS, 'hint'),
};
\ No newline at end of file
diff --git a/web/app/cad/dom/actionInfo/ActionInfo.jsx b/web/app/cad/dom/actionInfo/ActionInfo.jsx
new file mode 100644
index 00000000..ffb3cf77
--- /dev/null
+++ b/web/app/cad/dom/actionInfo/ActionInfo.jsx
@@ -0,0 +1,24 @@
+import React, {Fragment} from 'react';
+import ls from './ActionInfo.less';
+
+import AuxWidget from '../../../../../modules/ui/components/AuxWidget';
+import connect from '../../../../../modules/ui/connect';
+import {TOKENS as ACTION_TOKENS} from '../../actions/actionSystemPlugin';
+import {TOKENS as KeyboardTokens} from "../../keyboard/keyboardPlugin";
+
+function ActionInfo({actionId, x, y, info, hint, hotKey}) {
+ let visible = !!actionId;
+
+ return
+ {visible &&
+ {hint}
+ {info}
+ {hotKey && hotkey: {hotKey}
}
+ }
+ ;
+}
+
+export default connect([ACTION_TOKENS.HINT, KeyboardTokens.KEYMAP], ActionInfo, undefined,
+ ([ hintInfo, keymap ]) => (Object.assign({hotKey: hintInfo && keymap[hintInfo.actionId]}, hintInfo)) );
+
diff --git a/web/app/cad/dom/actionInfo/ActionInfo.less b/web/app/cad/dom/actionInfo/ActionInfo.less
new file mode 100644
index 00000000..b86d86bc
--- /dev/null
+++ b/web/app/cad/dom/actionInfo/ActionInfo.less
@@ -0,0 +1,3 @@
+.root {
+ display: flex;
+}
\ No newline at end of file
diff --git a/web/app/cad/dom/actionInfo/actionInfoPlugin.js b/web/app/cad/dom/actionInfo/actionInfoPlugin.js
new file mode 100644
index 00000000..49f611b4
--- /dev/null
+++ b/web/app/cad/dom/actionInfo/actionInfoPlugin.js
@@ -0,0 +1,4 @@
+
+export function activate() {
+
+}
\ No newline at end of file
diff --git a/web/app/cad/dom/components/ActionInfo.jsx b/web/app/cad/dom/components/ActionInfo.jsx
deleted file mode 100644
index 0095af65..00000000
--- a/web/app/cad/dom/components/ActionInfo.jsx
+++ /dev/null
@@ -1,12 +0,0 @@
-import React from 'react';
-
-
-
-export default function ActionInfo({children}) {
-
- return
- {children}
- ;
-}
-
-
diff --git a/web/app/cad/dom/components/ControlBar.jsx b/web/app/cad/dom/components/ControlBar.jsx
index 0787b617..b7eefaba 100644
--- a/web/app/cad/dom/components/ControlBar.jsx
+++ b/web/app/cad/dom/components/ControlBar.jsx
@@ -15,9 +15,9 @@ export default function ControlBar({left, right}) {
}
-export function ControlBarButton({onClick, onElement, disabled, children}) {
+export function ControlBarButton({onElement, disabled, children, onClick, ...props}) {
return