-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorPickerGUI.cpp
More file actions
38 lines (33 loc) · 1.33 KB
/
Copy pathColorPickerGUI.cpp
File metadata and controls
38 lines (33 loc) · 1.33 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
#include "include/ColorPickerGUI.hpp"
ColorPickerGUI::ColorPickerGUI(int size, Vector2 position, Color initialColor)
: size(size), position(position), selectedColor(initialColor), wheelOpen(false),
colorWheel(size*4, size*4, position, (Vector2){-30.f, 30.f}, initialColor) {}
bool ColorPickerGUI::isWheelOpen() {
return wheelOpen;
}
Color ColorPickerGUI::getSelectedColor() {
return selectedColor;
}
void ColorPickerGUI::update() {
Rectangle rect = (Rectangle){position.x, position.y, (float)size, (float)size};
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) {
if (CheckCollisionPointRec(GetMousePosition(), rect)) {
wheelOpen = !wheelOpen;
} else if (!CheckCollisionPointRec(GetMousePosition(), colorWheel.getColorWheelRect())) {
wheelOpen = false;
}
}
if (wheelOpen) colorWheel.update();
selectedColor = colorWheel.getSelectedColor();
}
void ColorPickerGUI::render() {
Rectangle rect = (Rectangle){position.x, position.y, (float)size, (float)size};
Color guiColor = (Color){125, 125, 125, 255};
DrawCircle(position.x + (float)size / 2, position.y + (float)size / 2, size, guiColor);
DrawRectangleRounded(rect, 0.5, 20, selectedColor);
DrawRectangleRoundedLines(rect, 0.5, 20, BLACK);
if (wheelOpen) {
DrawRectangleRounded(colorWheel.getColorWheelRect(), 0.5, 20, guiColor);
colorWheel.render();
}
}