phase 1 & 2 add text mark
This commit is contained in:
@@ -11,9 +11,28 @@ export interface ImageItem {
|
||||
zcaSuggestion?: { x: number; y: number; zone: string };
|
||||
}
|
||||
|
||||
export interface WatermarkSettings {
|
||||
type: 'text'; // Fixed to text
|
||||
text: string;
|
||||
color: string; // Hex
|
||||
opacity: number; // 0-1
|
||||
scale: number; // 0.01 - 0.5 (relative to image height)
|
||||
manual_override: boolean;
|
||||
manual_position: { x: number, y: number };
|
||||
}
|
||||
|
||||
export const useGalleryStore = defineStore("gallery", () => {
|
||||
const images = ref<ImageItem[]>([]);
|
||||
const selectedIndex = ref<number>(-1);
|
||||
const watermarkSettings = ref<WatermarkSettings>({
|
||||
type: 'text',
|
||||
text: 'Watermark',
|
||||
color: '#FFFFFF',
|
||||
opacity: 0.8,
|
||||
scale: 0.05, // 5% of height default
|
||||
manual_override: false,
|
||||
manual_position: { x: 0.5, y: 0.9 }
|
||||
});
|
||||
|
||||
const selectedImage = computed(() => {
|
||||
if (selectedIndex.value >= 0 && selectedIndex.value < images.value.length) {
|
||||
@@ -26,6 +45,10 @@ export const useGalleryStore = defineStore("gallery", () => {
|
||||
images.value = newImages;
|
||||
selectedIndex.value = -1;
|
||||
}
|
||||
|
||||
function updateWatermarkSettings(settings: Partial<WatermarkSettings>) {
|
||||
watermarkSettings.value = { ...watermarkSettings.value, ...settings };
|
||||
}
|
||||
|
||||
async function selectImage(index: number) {
|
||||
if (index < 0 || index >= images.value.length) return;
|
||||
@@ -35,8 +58,6 @@ export const useGalleryStore = defineStore("gallery", () => {
|
||||
if (!img.zcaSuggestion) {
|
||||
try {
|
||||
const suggestion = await invoke<{x: number, y: number, zone: string}>("get_zca_suggestion", { path: img.path });
|
||||
// Update the item in the array
|
||||
// Note: Directly modifying the object inside ref array is reactive in Vue 3
|
||||
img.zcaSuggestion = suggestion;
|
||||
} catch (e) {
|
||||
console.error("ZCA failed", e);
|
||||
@@ -48,7 +69,9 @@ export const useGalleryStore = defineStore("gallery", () => {
|
||||
images,
|
||||
selectedIndex,
|
||||
selectedImage,
|
||||
watermarkSettings,
|
||||
setImages,
|
||||
selectImage,
|
||||
updateWatermarkSettings
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user