<template>
  <div>
    <div class="am-ctrl-pano strengthen">
      <span
        v-for="action in actions"
        ctrl
        :class="{ active: frameAction === action.key }"
        @click="
          $emit('changeFrameAction', {
            action: frameAction === action.key ? undefined : action.key,
            frame: data,
          })
        "
        class="fun-ctrl"
      >
        <ui-icon :type="action.icon" :tip="action.tip" />
      </span>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { AnimationModelFrame } from "@/api";
import { ui18n } from "@/lang";

const actions = [
  { key: "translate", icon: "a-move", tip: ui18n.t("fuse.move") },
  { key: "rotate", icon: "a-rotate", tip: ui18n.t("fuse.flip") },
  { key: "scale", icon: "a-zoom", tip: ui18n.t("fuse.scale") },
  // { key: "originTranslate", icon: "a-anchor" },
];

defineProps<{ data: AnimationModelFrame; frameAction?: string }>();
defineEmits<{
  (e: "changeFrameAction", d: { action?: string; frame: AnimationModelFrame }): void;
}>();
</script>

<style lang="scss" scoped>
.am-ctrl-pano {
  z-index: 99;
  position: absolute;
  top: calc(var(--editor-head-height) + var(--header-top));
  margin: 20px;
  right: calc(var(--editor-menu-right) + var(--editor-toolbox-width));
  border-radius: 4px;
  height: 40px;
  background: rgba(27, 27, 28, 0.8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;

  span {
    width: 32px;
    height: 32px;
    display: flex;
    border-radius: 4px;
    align-items: center;
    margin: 0 2px;
    cursor: pointer;
    justify-content: center;

    .icon {
      font-size: 18px;
    }

    &.active {
      background: rgba(0, 200, 175, 0.3);
    }
  }
}
</style>
