-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRibbonButton.cpp
62 lines (54 loc) · 1.62 KB
/
RibbonButton.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
62
#include "RibbonButton.h"
Texture RibbonButton::textures[9];
bool RibbonButton::isResourcesLoaded = false;
RibbonButton::RibbonButton(ButtonType t)
{
type = t;
if (!isResourcesLoaded)
{
loadResources();
isResourcesLoaded = true;
}
setBackgroundColor(Color::Transparent);
setSize(Vector2f(70, 70));
}
void RibbonButton::draw(RenderTarget &target, RenderStates states) const
{
Vector2f thisPos = getPosition();
Control::draw(target,states);
Sprite icon;
icon.setTexture(textures[type]);
icon.setPosition(thisPos.x, thisPos.y);
target.draw(icon);
}
void RibbonButton::loadResources()
{
textures[NEW_FILE].loadFromFile("resources\\images\\newFileButton.png");
textures[NEW_FOLDER].loadFromFile("resources\\images\\newFolderButton.png");
textures[DELETEE].loadFromFile("resources\\images\\deleteButton.png");
textures[RENAME].loadFromFile("resources\\images\\renameButton.png");
textures[COPY].loadFromFile("resources\\images\\copyButton.png");
textures[MOVE].loadFromFile("resources\\images\\cutButton.png");
textures[PASTE].loadFromFile("resources\\images\\pasteButton.png");
textures[BACK].loadFromFile("resources\\images\\backButton.png");
textures[FORTH].loadFromFile("resources\\images\\forthButton.png");
}
RibbonButton::ButtonType RibbonButton::getType()
{
return type;
}
RibbonButton::~RibbonButton()
{
}
FloatRect RibbonButton::getGlobalBounds() const
{
return FloatRect(getPosition(),getSize());
}
Control * RibbonButton::handleEvent(Event event, Vector2f mousePos)
{
return this;
}
Control * RibbonButton::clone() const
{
return new RibbonButton(*this);
}