Skip to content

Commit

Permalink
Add show sprite button to scene tagger list (#3536)
Browse files Browse the repository at this point in the history
* Add show sprite button to scene tagger list
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
  • Loading branch information
Flashy78 authored Mar 14, 2023
1 parent e22c938 commit e2b52a4
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
17 changes: 16 additions & 1 deletion ui/v2.5/src/components/Tagger/scenes/SceneTagger.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useState } from "react";
import React, { useContext, useMemo, useState } from "react";
import * as GQL from "src/core/generated-graphql";
import { SceneQueue } from "src/models/sceneQueue";
import { Button, Form } from "react-bootstrap";
Expand All @@ -15,6 +15,7 @@ import { SceneSearchResults } from "./StashSearchResult";
import { ConfigurationContext } from "src/hooks/Config";
import { faCog } from "@fortawesome/free-solid-svg-icons";
import { distance } from "src/utils/hamming";
import { useLightbox } from "src/hooks/Lightbox/hooks";

interface ITaggerProps {
scenes: GQL.SlimSceneDataFragment[];
Expand Down Expand Up @@ -221,6 +222,19 @@ export const Tagger: React.FC<ITaggerProps> = ({ scenes, queue }) => {
return minDurationDiffSceneA - minDurationDiffSceneB;
}

const [spriteImage, setSpriteImage] = useState<string | null>(null);
const lightboxImage = useMemo(
() => [{ paths: { thumbnail: spriteImage, image: spriteImage } }],
[spriteImage]
);
const showLightbox = useLightbox({
images: lightboxImage,
});
function showLightboxImage(imagePath: string) {
setSpriteImage(imagePath);
showLightbox();
}

function renderScenes() {
const filteredScenes = !hideUnmatched
? scenes
Expand Down Expand Up @@ -267,6 +281,7 @@ export const Tagger: React.FC<ITaggerProps> = ({ scenes, queue }) => {
}
: undefined
}
showLightboxImage={showLightboxImage}
>
{searchResult && searchResult.results?.length ? (
<SceneSearchResults scenes={searchResult.results} target={scene} />
Expand Down
30 changes: 29 additions & 1 deletion ui/v2.5/src/components/Tagger/scenes/TaggerScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import { TruncatedText } from "src/components/Shared/TruncatedText";
import { parsePath, prepareQueryString } from "src/components/Tagger/utils";
import { ScenePreview } from "src/components/Scenes/SceneCard";
import { TaggerStateContext } from "../context";
import { faChevronDown, faChevronUp } from "@fortawesome/free-solid-svg-icons";
import {
faChevronDown,
faChevronUp,
faImage,
} from "@fortawesome/free-solid-svg-icons";
import { objectPath, objectTitle } from "src/core/files";

interface ITaggerSceneDetails {
Expand Down Expand Up @@ -84,6 +88,7 @@ interface ITaggerScene {
doSceneQuery?: (queryString: string) => void;
scrapeSceneFragment?: (scene: GQL.SlimSceneDataFragment) => void;
loading?: boolean;
showLightboxImage: (imagePath: string) => void;
}

export const TaggerScene: React.FC<PropsWithChildren<ITaggerScene>> = ({
Expand All @@ -94,6 +99,7 @@ export const TaggerScene: React.FC<PropsWithChildren<ITaggerScene>> = ({
scrapeSceneFragment,
errorMessage,
children,
showLightboxImage,
}) => {
const { config } = useContext(TaggerStateContext);
const [queryString, setQueryString] = useState<string>("");
Expand Down Expand Up @@ -186,6 +192,27 @@ export const TaggerScene: React.FC<PropsWithChildren<ITaggerScene>> = ({
}
}

function onSpriteClick(ev: React.MouseEvent<HTMLElement>) {
ev.preventDefault();
showLightboxImage(scene.paths.sprite ?? "");
}

function maybeRenderSpriteIcon() {
// If a scene doesn't have any files, or doesn't have a sprite generated, the
// path will be http://localhost:9999/scene/_sprite.jpg
if (scene.files.length > 0) {
return (
<Button
className="sprite-button"
variant="link"
onClick={onSpriteClick}
>
<Icon icon={faImage} />
</Button>
);
}
}

return (
<div key={scene.id} className="mt-3 search-item">
<div className="row">
Expand All @@ -198,6 +225,7 @@ export const TaggerScene: React.FC<PropsWithChildren<ITaggerScene>> = ({
isPortrait={isPortrait}
soundActive={false}
/>
{maybeRenderSpriteIcon()}
</Link>
</div>
<Link to={url} className="scene-link overflow-hidden">
Expand Down
12 changes: 12 additions & 0 deletions ui/v2.5/src/components/Tagger/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
padding-bottom: 0;
}

.scene-card {
position: relative;
}

.scene-card-preview {
border-radius: 3px;
margin-bottom: 0;
Expand All @@ -18,6 +22,14 @@
}
}

.sprite-button {
bottom: 5px;
filter: drop-shadow(1px 1px 1px #222);
padding: 0;
position: absolute;
right: 5px;
}

.sub-content {
min-height: 1.5rem;
}
Expand Down
1 change: 1 addition & 0 deletions ui/v2.5/src/docs/en/Changelog/v0200.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
##### 💥 Note: The cache directory is now required if using HLS/DASH streaming. Please set the cache directory in the System Settings page.

### ✨ New Features
* Added button to tagger scene cards to view scene sprite. ([#3536](https://github.com/stashapp/stash/pull/3536))
* Added hardware acceleration support (for a limited number of encoders) for transcoding. ([#3419](https://github.com/stashapp/stash/pull/3419))
* Added support for DASH streaming. ([#3275](https://github.com/stashapp/stash/pull/3275))
* Added configuration option for the maximum number of items in selector drop-downs. ([#3277](https://github.com/stashapp/stash/pull/3277))
Expand Down

0 comments on commit e2b52a4

Please sign in to comment.