Skip to content

add includes for math.h, fixing build #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/gui/drawBatcher.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "drawBatcher.hpp"
#include "../globalFunctions.hpp"

#include <math.h>

DrawBatcher drawBatcher;


Expand Down Expand Up @@ -57,14 +59,14 @@ void DrawBatcher::addItemBicolor(float x, float y, float w, float h, sf::Color c

void DrawBatcher::addItem(Operator *o)
{


addItemSingleColor(o->bg.getPosition().x-1, o->bg.getPosition().y-1, OP_SIZE+2, OP_SIZE+2, o->bg.getOutlineColor());

addItemSingleColor(o->bg.getPosition().x, o->bg.getPosition().y, OP_SIZE, OP_SIZE, (o->active || o->highlighted || o->hovered ) ? colors[OPERATORBGHOVER] : colors[o->muted ? OPERATORBGMUTED : OPERATORBG]);

addItemSingleColor(o->bgValue.getPosition().x, o->bgValue.getPosition().y, OP_SIZE, o->bgValue.getSize().y, o->bgValue.getFillColor());


if (o->active || o->highlighted || o->hovered)
{
Expand Down Expand Up @@ -97,7 +99,7 @@ void DrawBatcher::addItem(DataSlider *d)
{
addItemSingleColor(d->x, d->y, d->width, 19, d->focused ? colors[SLIDERBGHOVER] : colors[SLIDERBG]);
}


addItemSingleColor(d->bgValue.getPosition().x, d->y, d->bgValue.getSize().x, 19, d->focused ? colors[SLIDERBARHOVER] : colors[SLIDERBAR]);
addItem(&d->name);
Expand Down Expand Up @@ -192,13 +194,13 @@ void DrawBatcher::addItem(List *l)
addItem(&l->s2);

if (l->selectionVisible()) {

for (unsigned i = 0; i < l->selecteds_s.size(); i++)
{
if ((int)round(l->selecteds_s[i].getPosition().y)>=l->y && (int)round(l->selecteds_s[i].getPosition().y)<l->y+(int)round(l->bg.getSize().y))
addItem(&l->selecteds_s[i]);
}

}


Expand Down Expand Up @@ -229,7 +231,7 @@ void DrawBatcher::addItem(RectangleShape *r)
{
addItemSingleColor(r->getPosition().x, r->getPosition().y, r->getSize().x, r->getSize().y, r->getFillColor());
}

}


Expand All @@ -254,12 +256,12 @@ void DrawBatcher::draw()
window->draw(lines);
for (unsigned i=0; i<textCount; i++)
window->draw(*texts[i]);

}

void DrawBatcher::addItem(sf::Text* text)
{
texts.resize(textCount+1);
texts[textCount]=text;
textCount++;
}
}
31 changes: 17 additions & 14 deletions src/gui/list/list.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "list.hpp"
#include "../contextmenu/contextmenu.hpp"

#include <math.h>

extern void *focusedElement;


Expand Down Expand Up @@ -110,14 +113,14 @@ bool List::clicked(int mouseButton)
scrollbar.setValue((float)scroll / ((int)text.size() - maxrows) * 100);
}
updateView();

}



if (hover())
{

hovered = 1;
s2.setPosition(x, y + min(text.size() - 1 - scroll, (mouse.pos.y - y) / 17) * 17);
if (mouse.scroll != 0)
Expand All @@ -138,7 +141,7 @@ bool List::clicked(int mouseButton)
selected = 1;
return true;
}

}
else
{
Expand Down Expand Up @@ -189,13 +192,13 @@ void List::draw()
window->draw(s2);

if (selectionVisible()) {

for (unsigned i = 0; i < selecteds_s.size(); i++)
{
if ((int)round(selecteds_s[i].getPosition().y)>=y && (int)round(selecteds_s[i].getPosition().y)<y+(int)round(bg.getSize().y))
window->draw(selecteds_s[i]);
}

}

for (unsigned i = scroll; i<min<int>(scroll + maxrows, text.size()); ++i)
Expand Down Expand Up @@ -234,7 +237,7 @@ void List::selectAll()
void List::select(int index, bool updateScroll, bool hold)
{


if (multiple && keyboard.shift)
{
for (unsigned i = value; i <= index; i++)
Expand All @@ -248,7 +251,7 @@ void List::select(int index, bool updateScroll, bool hold)
}

value = clamp(index, 0, (int)text.size() - 1);

if (multiple && (keyboard.ctrl || hold))
{
selecteds[value]=!selecteds[value];
Expand All @@ -273,12 +276,12 @@ void List::select(int index, bool updateScroll, bool hold)
scroll = 0;
setScroll(scroll);
}

s.setPosition(x, y + (value - scroll) * 17);


updateView();

}

void List::remove(int index)
Expand All @@ -290,7 +293,7 @@ void List::remove(int index)
value = text.size() - 1;
selecteds[text.size() - 1]=true;
}

updateView();
}

Expand Down Expand Up @@ -381,11 +384,11 @@ void List::updateView()
selecteds_s[selecteds_s.size()-1].setPosition(x, y + (value - scroll) * 17);
selecteds_s[selecteds_s.size()-1].setFillColor(colors[LISTITEMBGFOCUS]);
}

for (int i = 0; i < text.size(); i++)
{
text[i].setColor(colors[selecteds[i] ? LISTITEMTEXTFOCUS : LISTITEMTEXT]);
}

}

}
4 changes: 3 additions & 1 deletion src/gui/scrollbar/scrollbar.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "scrollbar.hpp"

#include <math.h>


Slider::Slider(float def, float _max, float _min, float _step, int _x, int _y, int _size, bool _mini, bool _horizontal) :
x(_x),y(_y),size(_size), vmax(_max), step(_step), vmin(_min), mini(_mini), value(def), active(false), delta(0), horizontal(_horizontal)
Expand Down Expand Up @@ -109,4 +111,4 @@ void Slider::setScrollableContent(int content, int bounds)
else
cursor.setSize(Vector2f(bar.getSize().x, content <= bounds ? 0 : size*((float)bounds / content)));
setValue(value);
}
}
5 changes: 4 additions & 1 deletion src/gui/slider/dataslider.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "dataslider.hpp"
#include "../contextmenu/contextmenu.hpp"
#include "../popup/popup.hpp"

#include <math.h>

DataSlider* copiedSlider, pastedSlider;

DataSlider::DataSlider(int _x, int _y, int _max, int _min, string _name, int def, int _width, int _number) : tvalue(int2str[def], font, charSize), width(_width), name(_name, font, charSize)
Expand Down Expand Up @@ -182,4 +185,4 @@ void DataSlider::setSize(int _width)
bgValue.setSize(Vector2f(barWidth, 19));
tvalue.setPosition((int)(x + width - tvalue.getLocalBounds().width - 2), y);

}
}
Loading