Skip to content

Commit d69e9c8

Browse files
committed
fix(gsoc'24): Timing Diagram increase decrease buttons
1 parent 4d0b8de commit d69e9c8

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/components/Panels/TimingDiagramPanel/TimingDiagramPanel.vue

+11-13
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
{{ $t('simulator.panel_body.timing_diagram.units') }}
3535
<span id="timing-diagram-log"></span>
3636
</div>
37-
<div id="plot" ref="plotRef">
37+
<div id="plot" :style="{ width: plotWidth + 'px', height: plotHeight + 'px' }">
3838
<canvas id="plotArea"></canvas>
3939
</div>
4040
</div>
@@ -48,6 +48,7 @@ import { timingDiagramButtonActions } from '#/simulator/src/plotArea'
4848
import TimingDiagramButtons from './TimingDiagramButtons.vue'
4949
import buttonsJSON from '#/assets/constants/Panels/TimingDiagramPanel/buttons.json'
5050
import PanelHeader from '../Shared/PanelHeader.vue'
51+
import { sh } from '#/simulator/src/plotArea.js'
5152
5253
interface TimingDiagramButton {
5354
title: string
@@ -66,25 +67,22 @@ const plotArea: PlotArea = _plotArea
6667
const buttons = ref<TimingDiagramButton[]>(buttonsJSON)
6768
const plotRef = ref<HTMLElement | null>(null)
6869
const cycleUnits = ref(1000)
70+
const plotWidth = ref(sh(560));
71+
const plotHeight = ref(sh(20));
6972
7073
function handleButtonClick(button: string) {
7174
if (button === 'smaller') {
72-
if (plotRef.value) {
73-
plotRef.value.style.width = `${Math.max(
74-
plotRef.value.offsetWidth - 20,
75-
560
76-
)}px`
77-
}
78-
plotArea.resize()
75+
plotWidth.value = Math.max(plotWidth.value - sh(20), sh(560));
76+
plotArea.resize();
7977
} else if (button === 'larger') {
80-
if (plotRef.value) {
81-
plotRef.value.style.width = `${plotRef.value.offsetWidth + 20}px`
82-
}
78+
plotWidth.value += sh(20);
8379
plotArea.resize()
8480
} else if (button === 'smallHeight') {
85-
timingDiagramButtonActions.smallHeight()
81+
plotHeight.value = Math.max(plotHeight.value - sh(20), sh(20));
82+
plotArea.resize()
8683
} else if (button === 'largeHeight') {
87-
timingDiagramButtonActions.largeHeight()
84+
plotHeight.value = Math.min(plotHeight.value + sh(20), sh(100));
85+
plotArea.resize()
8886
} else {
8987
plotArea[button]()
9088
}

0 commit comments

Comments
 (0)