Skip to content
Snippets Groups Projects
Commit 8738264c authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[ivette/eva] probe selection

parent d1ba1c21
No related branches found
No related tags found
No related merge requests found
...@@ -239,7 +239,7 @@ export const CircButton = (props: ButtonProps) => { ...@@ -239,7 +239,7 @@ export const CircButton = (props: ButtonProps) => {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
export type IconButtonKind = export type IconButtonKind =
undefined | 'default' | 'negative' | 'positive' | 'warning'; undefined | 'selected' | 'default' | 'negative' | 'positive' | 'warning';
export interface IconButtonProps { export interface IconButtonProps {
/** Icon identifier. Displayed on the left side of the label. */ /** Icon identifier. Displayed on the left side of the label. */
...@@ -266,6 +266,7 @@ export interface IconButtonProps { ...@@ -266,6 +266,7 @@ export interface IconButtonProps {
display?: boolean; display?: boolean;
/** Styled bytton: /** Styled bytton:
- `'default'`: normal button; - `'default'`: normal button;
- `'selected'`: selection button, in blue;
- `'warning'`: warning button, in orange; - `'warning'`: warning button, in orange;
- `'positive'`: positive button, in green; - `'positive'`: positive button, in green;
- `'negative'`: negative button, in red. - `'negative'`: negative button, in red.
......
...@@ -52,8 +52,10 @@ function ProbeEditor() { ...@@ -52,8 +52,10 @@ function ProbeEditor() {
const rank = probe?.rank; const rank = probe?.rank;
const stmt = rank ? `@S${rank}` : undefined; const stmt = rank ? `@S${rank}` : undefined;
const { cols, rows } = sizeof(code); const { cols, rows } = sizeof(code);
const visible = probe ? !!code : model.getRowCount() > 0;
const visibility = visible ? 'visible' : 'hidden';
return ( return (
<Hpack className="eva-probe"> <Hpack style={{ visibility }} className="eva-probe">
<Label className="eva-probe-label">{label && `${label}:`}</Label> <Label className="eva-probe-label">{label && `${label}:`}</Label>
<div className="eva-probe-code"> <div className="eva-probe-code">
<SizedArea cols={cols} rows={rows}>{code}</SizedArea> <SizedArea cols={cols} rows={rows}>{code}</SizedArea>
...@@ -61,8 +63,7 @@ function ProbeEditor() { ...@@ -61,8 +63,7 @@ function ProbeEditor() {
<Code className="eva-probe-stmt">{stmt}</Code> <Code className="eva-probe-stmt">{stmt}</Code>
<IconButton <IconButton
className="eva-probe-button" className="eva-probe-button"
visible={!!code} kind={transient ? 'selected' : 'warning'}
kind={transient ? 'positive' : 'negative'}
icon={transient ? 'CIRC.CHECK' : 'CIRC.CLOSE'} icon={transient ? 'CIRC.CHECK' : 'CIRC.CLOSE'}
onClick={() => { if (probe) probe.setTransient(!transient); }} onClick={() => { if (probe) probe.setTransient(!transient); }}
title={transient ? 'Make the probe persistent' : 'Release the probe'} title={transient ? 'Make the probe persistent' : 'Release the probe'}
...@@ -73,7 +74,7 @@ function ProbeEditor() { ...@@ -73,7 +74,7 @@ function ProbeEditor() {
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// --- Table Cell // --- Table Cell Layout
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
interface TableCellProps { interface TableCellProps {
...@@ -85,10 +86,11 @@ const CELLPADDING = 4; ...@@ -85,10 +86,11 @@ const CELLPADDING = 4;
function TableCell(props: TableCellProps) { function TableCell(props: TableCellProps) {
const model = useModel(); const model = useModel();
const [selection, setSelection] = States.useSelection();
const { probe, kind } = props; const { probe, kind } = props;
const minWidth = CELLPADDING + WSIZER.dimension(probe.minCols); const minWidth = CELLPADDING + WSIZER.dimension(probe.minCols);
const maxWidth = CELLPADDING + WSIZER.dimension(probe.maxCols); const maxWidth = CELLPADDING + WSIZER.dimension(probe.maxCols);
const style = { minWidth, maxWidth }; const style = { width: minWidth, maxWidth };
let styling = 'dome-text-code'; let styling = 'dome-text-code';
let contents: React.ReactNode = props.probe.marker; let contents: React.ReactNode = props.probe.marker;
const { transient, label, code } = probe; const { transient, label, code } = probe;
...@@ -96,7 +98,7 @@ function TableCell(props: TableCellProps) { ...@@ -96,7 +98,7 @@ function TableCell(props: TableCellProps) {
case 'probes': case 'probes':
if (transient) { if (transient) {
styling = 'dome-text-label'; styling = 'dome-text-label';
contents = '« Current »'; contents = '« Probe »';
} else if (label) { } else if (label) {
styling = 'dome-text-label'; styling = 'dome-text-label';
contents = label; contents = label;
...@@ -105,9 +107,15 @@ function TableCell(props: TableCellProps) { ...@@ -105,9 +107,15 @@ function TableCell(props: TableCellProps) {
} }
break; break;
case 'values': case 'values':
contents = ( {
model.cache.getValues(probe.marker).values const { values } = model.cache.getValues(probe.marker);
); const { cols, rows } = sizeof(values);
contents = (
<SizedArea cols={cols} rows={rows}>
{values}
</SizedArea>
);
}
break; break;
} }
const isFocused = model.getFocused() === probe; const isFocused = model.getFocused() === probe;
...@@ -117,8 +125,19 @@ function TableCell(props: TableCellProps) { ...@@ -117,8 +125,19 @@ function TableCell(props: TableCellProps) {
transient && 'eva-transient', transient && 'eva-transient',
!transient && isFocused && 'eva-focused', !transient && isFocused && 'eva-focused',
); );
const onClick = () => {
if (probe) {
const fct = selection?.current?.function;
const location = { function: fct, marker: probe.marker };
setSelection({ location });
}
};
return ( return (
<div className={className} style={style}> <div
className={className}
style={style}
onClick={onClick}
>
{contents} {contents}
</div> </div>
); );
......
...@@ -107,8 +107,6 @@ export class Probe { ...@@ -107,8 +107,6 @@ export class Probe {
const rq = q.rank ?? 0; const rq = q.rank ?? 0;
if (rp < rq) return (-1); if (rp < rq) return (-1);
if (rp > rq) return (+1); if (rp > rq) return (+1);
if (p.transient && !q.transient) return (-1);
if (!p.transient && q.transient) return (+1);
if (p.marker < q.marker) return (-1); if (p.marker < q.marker) return (-1);
if (p.marker > q.marker) return (+1); if (p.marker > q.marker) return (+1);
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment