Skip to content

Commit 2e23114

Browse files
committed
functionally complete header and sidebar for images
1 parent 56a7499 commit 2e23114

File tree

2 files changed

+120
-190
lines changed

2 files changed

+120
-190
lines changed

src/MainLayout/index.js

Lines changed: 116 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -174,126 +174,8 @@ export const MainLayout = ({
174174
})
175175

176176
const debugModeOn = Boolean(window.localStorage.$ANNOTATE_DEBUG_MODE && state)
177-
178-
return (
179-
<Workspace
180-
allowFullscreen
181-
iconDictionary={iconDictionary}
182-
headerLeftSide={[
183-
state.annotationType === "video" && (
184-
<KeyframeTimeline
185-
currentTime={state.currentVideoTime}
186-
duration={state.videoDuration}
187-
onChangeCurrentTime={action("CHANGE_VIDEO_TIME", "newTime")}
188-
keyframes={state.keyframes}
189-
/>
190-
),
191-
].filter(Boolean)}
192-
headerItems={[
193-
{ name: "Prev" },
194-
{ name: "Next" },
195-
state.annotationType !== "video"
196-
? null
197-
: !state.videoPlaying
198-
? { name: "Play" }
199-
: { name: "Pause" },
200-
{ name: "Settings" },
201-
{ name: "Fullscreen" },
202-
{ name: "Save" },
203-
].filter(Boolean)}
204-
onClickHeaderItem={onClickHeaderItem}
205-
onClickIconSidebarItem={onClickIconSidebarItem}
206-
selectedTools={[
207-
state.selectedTool,
208-
state.showTags && "show-tags",
209-
state.showMask && "show-mask",
210-
].filter(Boolean)}
211-
iconSidebarItems={[
212-
{
213-
name: "select",
214-
helperText: "Select",
215-
selected: state.selectedTool,
216-
},
217-
{
218-
name: "pan",
219-
helperText: "Drag/Pan",
220-
},
221-
{
222-
name: "zoom",
223-
helperText: "Zoom In/Out",
224-
},
225-
{
226-
name: "show-tags",
227-
helperText: "Show / Hide Tags",
228-
},
229-
{
230-
name: "create-point",
231-
helperText: "Add Point",
232-
},
233-
{
234-
name: "create-box",
235-
helperText: "Add Bounding Box",
236-
},
237-
{
238-
name: "create-polygon",
239-
helperText: "Add Polygon",
240-
},
241-
{
242-
name: "create-expanding-line",
243-
helperText: "Add Expanding Line",
244-
},
245-
{
246-
name: "show-mask",
247-
helperText: "Show / Hide Mask",
248-
},
249-
]}
250-
rightSidebarItems={[
251-
debugModeOn && (
252-
<DebugBox state={debugModeOn} lastAction={state.lastAction} />
253-
),
254-
state.taskDescription && (
255-
<TaskDescription description={state.taskDescription} />
256-
),
257-
state.labelImages && (
258-
<TagsSidebarBox
259-
currentImage={activeImage}
260-
imageClsList={state.imageClsList}
261-
imageTagList={state.imageTagList}
262-
onChangeImage={action("CHANGE_IMAGE", "delta")}
263-
expandedByDefault
264-
/>
265-
),
266-
(state.images?.length || 0) > 1 && (
267-
<ImageSelector
268-
onSelect={action("SELECT_REGION", "region")}
269-
images={state.images}
270-
/>
271-
),
272-
<RegionSelector
273-
regions={activeImage ? activeImage.regions : emptyArr}
274-
onSelectRegion={action("SELECT_REGION", "region")}
275-
onDeleteRegion={action("DELETE_REGION", "region")}
276-
onChangeRegion={action("CHANGE_REGION", "region")}
277-
/>,
278-
state.keyframes && (
279-
<KeyframesSelector
280-
onChangeVideoTime={action("CHANGE_VIDEO_TIME", "newTime")}
281-
onDeleteKeyframe={action("DELETE_KEYFRAME", "time")}
282-
onChangeCurrentTime={action("CHANGE_VIDEO_TIME", "newTime")}
283-
currentTime={state.currentVideoTime}
284-
duration={state.videoDuration}
285-
keyframes={state.keyframes}
286-
/>
287-
),
288-
<HistorySidebarBox
289-
history={state.history}
290-
onRestoreHistory={action("RESTORE_HISTORY")}
291-
/>,
292-
].filter(Boolean)}
293-
>
294-
{canvas}
295-
</Workspace>
296-
)
177+
const nextImageHasRegions =
178+
!nextImage || (nextImage.regions && nextImage.regions.length > 0)
297179

298180
return (
299181
<Fullscreen
@@ -316,74 +198,124 @@ export const MainLayout = ({
316198
state.fullScreen && "Fullscreen"
317199
)}
318200
>
319-
<div className={classes.headerContainer}>
320-
<Header
321-
onHeaderButtonClick={action("HEADER_BUTTON_CLICKED", "buttonName")}
322-
videoMode={state.annotationType === "video"}
323-
alwaysShowNextButton={alwaysShowNextButton}
324-
alwaysShowPrevButton={alwaysShowPrevButton}
325-
inFullScreen={state.fullScreen}
326-
isAVideoFrame={isAVideoFrame}
327-
nextVideoFrameHasRegions={
328-
!nextImage || (nextImage.regions && nextImage.regions.length > 0)
329-
}
330-
videoDuration={state.videoDuration}
331-
multipleImages={state.images && state.images.length > 1}
332-
title={
333-
state.annotationType === "image"
334-
? activeImage
335-
? activeImage.name
336-
: "No Image Selected"
337-
: state.videoName || ""
338-
}
339-
onChangeCurrentTime={action("CHANGE_VIDEO_TIME", "newTime")}
340-
videoPlaying={state.videoPlaying}
341-
currentVideoTime={state.currentVideoTime}
342-
keyframes={state.keyframes}
343-
/>
344-
</div>
345-
<div className={classes.workspace}>
346-
<div className={classes.iconToolsContainer}>
347-
<IconTools
348-
enabledTools={state.enabledTools}
349-
showTags={state.showTags}
350-
showMask={state.showMask}
351-
selectedTool={state.selectedTool}
352-
onClickTool={action("SELECT_TOOL", "selectedTool")}
353-
/>
354-
</div>
355-
<div className={classes.imageCanvasContainer}>
356-
{state.annotationType === "image" && !state.selectedImage ? (
357-
<div className={classes.noImageSelected}>No Image Selected</div>
358-
) : (
359-
<div style={{ height: "100%", width: "100%" }}>{canvas}</div>
360-
)}
361-
</div>
362-
<div className={classes.sidebarContainer}>
363-
<Sidebar
364-
debug={window.localStorage.$ANNOTATE_DEBUG_MODE && state}
365-
taskDescription={state.taskDescription}
366-
images={state.images}
367-
regions={activeImage ? activeImage.regions : null}
368-
history={state.history}
369-
currentImage={activeImage}
370-
labelImages={state.labelImages}
371-
imageClsList={state.imageClsList}
372-
imageTagList={state.imageTagList}
373-
keyframes={state.keyframes}
374-
currentVideoTime={state.currentVideoTime}
375-
onChangeImage={action("CHANGE_IMAGE", "delta")}
201+
<Workspace
202+
allowFullscreen
203+
iconDictionary={iconDictionary}
204+
headerLeftSide={[
205+
state.annotationType === "video" && (
206+
<KeyframeTimeline
207+
currentTime={state.currentVideoTime}
208+
duration={state.videoDuration}
209+
onChangeCurrentTime={action("CHANGE_VIDEO_TIME", "newTime")}
210+
keyframes={state.keyframes}
211+
/>
212+
),
213+
].filter(Boolean)}
214+
headerItems={[
215+
{ name: "Prev" },
216+
{ name: "Next" },
217+
state.annotationType !== "video"
218+
? null
219+
: !state.videoPlaying
220+
? { name: "Play" }
221+
: { name: "Pause" },
222+
!nextImageHasRegions && activeImage.regions && { name: "Clone" },
223+
{ name: "Settings" },
224+
state.fullScreen ? { name: "Window" } : { name: "Fullscreen" },
225+
{ name: "Save" },
226+
].filter(Boolean)}
227+
onClickHeaderItem={onClickHeaderItem}
228+
onClickIconSidebarItem={onClickIconSidebarItem}
229+
selectedTools={[
230+
state.selectedTool,
231+
state.showTags && "show-tags",
232+
state.showMask && "show-mask",
233+
].filter(Boolean)}
234+
iconSidebarItems={[
235+
{
236+
name: "select",
237+
helperText: "Select",
238+
selected: state.selectedTool,
239+
},
240+
{
241+
name: "pan",
242+
helperText: "Drag/Pan",
243+
},
244+
{
245+
name: "zoom",
246+
helperText: "Zoom In/Out",
247+
},
248+
{
249+
name: "show-tags",
250+
helperText: "Show / Hide Tags",
251+
},
252+
{
253+
name: "create-point",
254+
helperText: "Add Point",
255+
},
256+
{
257+
name: "create-box",
258+
helperText: "Add Bounding Box",
259+
},
260+
{
261+
name: "create-polygon",
262+
helperText: "Add Polygon",
263+
},
264+
{
265+
name: "create-expanding-line",
266+
helperText: "Add Expanding Line",
267+
},
268+
{
269+
name: "show-mask",
270+
helperText: "Show / Hide Mask",
271+
},
272+
]}
273+
rightSidebarItems={[
274+
debugModeOn && (
275+
<DebugBox state={debugModeOn} lastAction={state.lastAction} />
276+
),
277+
state.taskDescription && (
278+
<TaskDescription description={state.taskDescription} />
279+
),
280+
state.labelImages && (
281+
<TagsSidebarBox
282+
currentImage={activeImage}
283+
imageClsList={state.imageClsList}
284+
imageTagList={state.imageTagList}
285+
onChangeImage={action("CHANGE_IMAGE", "delta")}
286+
expandedByDefault
287+
/>
288+
),
289+
(state.images?.length || 0) > 1 && (
290+
<ImageSelector
291+
onSelect={action("SELECT_REGION", "region")}
292+
images={state.images}
293+
/>
294+
),
295+
<RegionSelector
296+
regions={activeImage ? activeImage.regions : emptyArr}
376297
onSelectRegion={action("SELECT_REGION", "region")}
377298
onDeleteRegion={action("DELETE_REGION", "region")}
378-
onSelectImage={action("SELECT_IMAGE", "image")}
379299
onChangeRegion={action("CHANGE_REGION", "region")}
300+
/>,
301+
state.keyframes && (
302+
<KeyframesSelector
303+
onChangeVideoTime={action("CHANGE_VIDEO_TIME", "newTime")}
304+
onDeleteKeyframe={action("DELETE_KEYFRAME", "time")}
305+
onChangeCurrentTime={action("CHANGE_VIDEO_TIME", "newTime")}
306+
currentTime={state.currentVideoTime}
307+
duration={state.videoDuration}
308+
keyframes={state.keyframes}
309+
/>
310+
),
311+
<HistorySidebarBox
312+
history={state.history}
380313
onRestoreHistory={action("RESTORE_HISTORY")}
381-
onChangeVideoTime={action("CHANGE_VIDEO_TIME", "newTime")}
382-
onDeleteKeyframe={action("DELETE_KEYFRAME", "time")}
383-
onShortcutActionDispatched={dispatch}
384-
/>
385-
</div>
386-
</div>
314+
/>,
315+
].filter(Boolean)}
316+
>
317+
{canvas}
318+
</Workspace>
387319
<SettingsDialog
388320
open={state.settingsOpen}
389321
onClose={() =>

src/Sidebar/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22

33
import React from "react"
4-
import { makeStyles } from "@material-ui/core/styles"
4+
import { styled, makeStyles } from "@material-ui/core/styles"
55
import TaskDescription from "../TaskDescriptionSidebarBox"
66
import ImageSelector from "../ImageSelectorSidebarBox"
77
import RegionSelector from "../RegionSelectorSidebarBox"
@@ -11,7 +11,7 @@ import TagsSidebarBox from "../TagsSidebarBox"
1111
import KeyframesSelector from "../KeyframesSelectorSidebarBox"
1212
import type { Region } from "../ImageCanvas/region-tools.js"
1313

14-
const useStyles = makeStyles({})
14+
const Container = styled("div")({})
1515

1616
type Image = {
1717
name: string,
@@ -67,12 +67,10 @@ export const Sidebar = ({
6767
onDeleteKeyframe,
6868
onShortcutActionDispatched,
6969
}: Props) => {
70-
const classes = useStyles()
71-
7270
if (!regions) regions = emptyArr
7371

7472
return (
75-
<div>
73+
<Container>
7674
{debug && <DebugBox state={debug} lastAction={debug.lastAction} />}
7775
{taskDescription && (taskDescription || "").length > 1 && (
7876
<TaskDescription description={taskDescription} />
@@ -105,7 +103,7 @@ export const Sidebar = ({
105103
)}
106104
<History history={history} onRestoreHistory={() => onRestoreHistory()} />
107105
{/* <Shortcuts onShortcutActionDispatched={onShortcutActionDispatched} /> */}
108-
</div>
106+
</Container>
109107
)
110108
}
111109

0 commit comments

Comments
 (0)