-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp_Window.cpp
61 lines (47 loc) · 1.45 KB
/
App_Window.cpp
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
//
// Created by Kelly Lwin on 4/24/2023.
//
#include "App_Window.h"
App_Window::App_Window(): App_Window("My Files") {
}
App_Window::App_Window(std::string appNameStr) {
Font::defaultFont(appName, font, appNameStr);
setupBackground();
setupCloseButton();
}
void App_Window::updatePositions() {
float x = appBackground.getPosition().x + 10;
float y = appBackground.getPosition().y + 5;
appName.setPosition({x, y});
x += 700, y += 10;
closeButton.setPosition({x, y});
}
void App_Window::setAppName(const std::string &name) {
appName.setString(name);
appName.setFillColor(sf::Color::White);
}
sf::Vector2f App_Window::getPosition() const {
return appBackground.getPosition();
}
void App_Window::setPosition(const sf::Vector2f &pos) {
appBackground.setPosition(pos);
updatePositions();
}
void App_Window::setupBackground() {
background.loadFromFile("Assets/app_window.png");
appBackground.setTexture(background);
setScale({0.7, 0.7});
}
void App_Window::setupCloseButton() {
closeButton.setSize({30, 30});
closeButton.setFillColor(sf::Color::Transparent);
updatePositions();
}
void App_Window::setScale(const sf::Vector2f &scale) {
appBackground.setScale(scale);
}
void App_Window::draw(sf::RenderTarget &target, sf::RenderStates states) const {
target.draw(appBackground);
target.draw(appName);
target.draw(closeButton);
}