File size: 3,642 Bytes
b4f9490
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<template>
  <div class="objects-timeline-section">
    <div class="timeline-container">
      <div class="objects-container">
        <object-item 

          v-for="object in objects" 

          :key="object.id" 

          :object-id="object.id"

          :object-name="object.name"

          :color="object.color"

          :is-selected="annotationStore.selectedObjectId === object.id"

          @click="selectObject(object.id)"

        />
        <div class="add-object" v-if="objects.length === 0 || showAddButton">
          <button class="add-button" @click="addNewObject">+</button>
        </div>
        <div class="empty-state" v-if="objects.length === 0">
          <p>Aucun objet créé</p>
          <p>Cliquez sur + pour ajouter un objet</p>
        </div>
      </div>
      <div class="timeline-tools"></div>
    </div>
  </div>
</template>

<script>

import ObjectItem from './ObjectItem.vue'

import { useAnnotationStore } from '@/stores/annotationStore'

import { storeToRefs } from 'pinia'



export default {

  name: 'ObjectsTimelineSection',

  components: {

    ObjectItem

  },

  

  setup() {

    const annotationStore = useAnnotationStore()

    const { objects } = storeToRefs(annotationStore)

    

    return { 

      annotationStore,

      objects

    }

  },

  

  data() {

    return {

      showAddButton: true

    }

  },

  

  methods: {

    selectObject(objectId) {

      this.annotationStore.selectObject(objectId)

      this.$emit('object-selected', objectId)

    },

    

    addNewObject() {

      const newObjectId = this.annotationStore.addObject()

      this.$emit('object-selected', newObjectId)

    }

  }

}

</script>

<style scoped>

.objects-timeline-section {

  background: #363636;

  border-radius: 8px;

  height: 100%;

  display: flex;

  flex-direction: column;

  overflow: hidden; /* Contenir tout le contenu */

}



.timeline-container {

  display: flex;

  gap: 10px;

  flex: 1;

  min-height: 0; /* Crucial pour que le scroll fonctionne dans un conteneur flex */

  overflow: hidden; /* Contenir les enfants */

}



.objects-container {

  flex-grow: 1;

  overflow-y: auto; /* Activer le défilement vertical */

  padding: 8px;

  background: #2a2a2a;

  border-radius: 4px;

  /* Stylisation de la scrollbar */

  scrollbar-width: thin;

  scrollbar-color: #555 #2c2c2c;

  direction: rtl; /* Déplace la scrollbar à gauche */

}



.objects-container > * {

  direction: ltr; /* Rétablit la direction normale pour le contenu */

}



/* Stylisation de la scrollbar pour Chrome/Safari/Edge */

.objects-container::-webkit-scrollbar {

  width: 8px;

}



.objects-container::-webkit-scrollbar-track {

  background: #2c2c2c;

  border-radius: 4px;

}



.objects-container::-webkit-scrollbar-thumb {

  background-color: #555;

  border-radius: 4px;

}



.timeline-tools {

  width: 50px;

  background: #2c2c2c;

  border-radius: 4px;

  height: 100%;

}



h3 {

  color: #ffffff;

  margin: 0 0 12px 0;

  font-size: 1rem;

  font-weight: 500;

}



.add-object {

  display: flex;

  justify-content: center;

  margin-top: 8px;

}



.add-button {

  width: 30px;

  height: 30px;

  border-radius: 50%;

  background: #2c2c2c;

  border: none;

  color: white;

  font-size: 20px;

  display: flex;

  align-items: center;

  justify-content: center;

  cursor: pointer;

  transition: background-color 0.2s;

}



.add-button:hover {

  background: #3c3c3c;

}



.empty-state {

  text-align: center;

  color: #888;

  padding: 20px 0;

  font-size: 0.9rem;

}



.empty-state p {

  margin: 5px 0;

}

</style>