-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItemList.cpp
More file actions
72 lines (68 loc) · 2.55 KB
/
Copy pathItemList.cpp
File metadata and controls
72 lines (68 loc) · 2.55 KB
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
//
// Created by jonng on 5/2/2021.
//
#include "ItemList.h"
ItemList::ItemList() {
// item_list_states.disableState(States::IS_EXPANDED);
is_expanded = false;
}
void ItemList::addItem(String itemName) {
an_item.setString(itemName);
addBack(an_item);
if (tail != head) {
tail->data.setPosition({tail->prev->data.getGlobalBounds().left+an_item.getOutlineThickness(), tail->prev->data.getGlobalBounds().top + tail->prev->data.getGlobalBounds().height});
}
}
void ItemList::addEventHandler(sf::RenderWindow& window, sf::Event event) {
//Highlighting
if (is_expanded) {
for (Node<Item>* walker = head; walker != nullptr; walker = walker->next)
walker->data.addEventHandler(window,event);
}
}
void ItemList::draw(RenderTarget& target, RenderStates states) const {
if(is_expanded) {
for (Node<Item>* walker = head; walker != nullptr; walker = walker->next) {
target.draw(walker->data);
}
}
}
void ItemList::setSize(Vector2f size) {
an_item.setSize(size);
for (Node<Item>* walker = head; walker != nullptr; walker = walker->next) {
walker->data.setSize(size);
if(walker != head) {
walker->data.setPosition({walker->prev->data.getGlobalBounds().left+an_item.getOutlineThickness(), walker->prev->data.getGlobalBounds().top + walker->prev->data.getGlobalBounds().height});
}
}
}
void ItemList::setPosition(Vector2f position) {
an_item.setPosition(position);
if (head != nullptr) {
head->data.setPosition({position.x,position.y+an_item.getOutlineThickness()});
for (Node<Item>* walker = head; walker != nullptr; walker = walker->next) {
if (walker != head) {
walker->data.setPosition({walker->prev->data.getGlobalBounds().left+an_item.getOutlineThickness(), walker->prev->data.getGlobalBounds().top + walker->prev->data.getGlobalBounds().height});
}
}
}
}
void ItemList::setCharacterSize(unsigned int size) {
an_item.setCharacterSize(size);
for (Node<Item>* walker = head; walker != nullptr; walker = walker->next) {
walker->data.setCharacterSize(size);
walker->data.centerTextInBox();
}
}
void ItemList::setIsExpanded(bool aBoolean) {
is_expanded = aBoolean;
}
bool ItemList::isExpanded() const {
return is_expanded;
}
void ItemList::setOutlineThickness(float thickness) {
an_item.setOutlineThickness(thickness);
for (Node<Item>* walker = head; walker != nullptr; walker = walker->next) {
walker->data.setOutlineThickness(thickness);
}
}