From 4adf4b8023e17c08757e595eba856f27e60190e2 Mon Sep 17 00:00:00 2001 From: Francisco Demartino Date: Sun, 14 Nov 2021 03:03:07 -0300 Subject: [PATCH] add includes for math.h, fixing build tested on gcc (Debian 10.2.1-6) --- src/gui/drawBatcher.cpp | 18 ++++--- src/gui/list/list.cpp | 31 ++++++----- src/gui/scrollbar/scrollbar.cpp | 4 +- src/gui/slider/dataslider.cpp | 5 +- src/gui/textfield/textfield.cpp | 53 ++++++++++--------- src/gui/vumeter/stereovumeter.cpp | 2 + src/midi/midi_import.cpp | 6 ++- src/views/pattern/patternSelection.cpp | 4 +- .../settings/configEditor_soundDevice.cpp | 6 ++- 9 files changed, 75 insertions(+), 54 deletions(-) diff --git a/src/gui/drawBatcher.cpp b/src/gui/drawBatcher.cpp index 7467d7a..750599f 100644 --- a/src/gui/drawBatcher.cpp +++ b/src/gui/drawBatcher.cpp @@ -1,6 +1,8 @@ #include "drawBatcher.hpp" #include "../globalFunctions.hpp" +#include + DrawBatcher drawBatcher; @@ -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) { @@ -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); @@ -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)y+(int)round(l->bg.getSize().y)) addItem(&l->selecteds_s[i]); } - + } @@ -229,7 +231,7 @@ void DrawBatcher::addItem(RectangleShape *r) { addItemSingleColor(r->getPosition().x, r->getPosition().y, r->getSize().x, r->getSize().y, r->getFillColor()); } - + } @@ -254,7 +256,7 @@ void DrawBatcher::draw() window->draw(lines); for (unsigned i=0; idraw(*texts[i]); - + } void DrawBatcher::addItem(sf::Text* text) @@ -262,4 +264,4 @@ void DrawBatcher::addItem(sf::Text* text) texts.resize(textCount+1); texts[textCount]=text; textCount++; -} \ No newline at end of file +} diff --git a/src/gui/list/list.cpp b/src/gui/list/list.cpp index 39a4df3..837184d 100644 --- a/src/gui/list/list.cpp +++ b/src/gui/list/list.cpp @@ -1,5 +1,8 @@ #include "list.hpp" #include "../contextmenu/contextmenu.hpp" + +#include + extern void *focusedElement; @@ -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) @@ -138,7 +141,7 @@ bool List::clicked(int mouseButton) selected = 1; return true; } - + } else { @@ -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)draw(selecteds_s[i]); } - + } for (unsigned i = scroll; i(scroll + maxrows, text.size()); ++i) @@ -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++) @@ -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]; @@ -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) @@ -290,7 +293,7 @@ void List::remove(int index) value = text.size() - 1; selecteds[text.size() - 1]=true; } - + updateView(); } @@ -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]); } - -} \ No newline at end of file + +} diff --git a/src/gui/scrollbar/scrollbar.cpp b/src/gui/scrollbar/scrollbar.cpp index b26a406..ef703b6 100644 --- a/src/gui/scrollbar/scrollbar.cpp +++ b/src/gui/scrollbar/scrollbar.cpp @@ -1,5 +1,7 @@ #include "scrollbar.hpp" +#include + 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) @@ -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); -} \ No newline at end of file +} diff --git a/src/gui/slider/dataslider.cpp b/src/gui/slider/dataslider.cpp index 0d0e2a3..6612283 100644 --- a/src/gui/slider/dataslider.cpp +++ b/src/gui/slider/dataslider.cpp @@ -1,6 +1,9 @@ #include "dataslider.hpp" #include "../contextmenu/contextmenu.hpp" #include "../popup/popup.hpp" + +#include + 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) @@ -182,4 +185,4 @@ void DataSlider::setSize(int _width) bgValue.setSize(Vector2f(barWidth, 19)); tvalue.setPosition((int)(x + width - tvalue.getLocalBounds().width - 2), y); -} \ No newline at end of file +} diff --git a/src/gui/textfield/textfield.cpp b/src/gui/textfield/textfield.cpp index ab00f31..e5c06b4 100644 --- a/src/gui/textfield/textfield.cpp +++ b/src/gui/textfield/textfield.cpp @@ -1,5 +1,8 @@ #include "textfield.hpp" #include "../contextmenu/contextmenu.hpp" + +#include + extern void *focusedElement; // very primitive text input, quite sucking atm @@ -38,7 +41,7 @@ int TextInput::getSelectionStart() { if (pos2 < selectionBegin) { - + return max(0, selectionBegin - selectionCount); } else @@ -62,7 +65,7 @@ int TextInput::getCursorIndex(int &stringPosLastLine) { stringPosLastLine += charCountLine[i]; } - + int pos22 = stringPosLastLine; int pos = 0; while (pos < mouse.pos.x - 8 && pos22 < stringPosLastLine + charCountLine[currentLine] && (int)round((text.findCharacterPos(pos22+1).y - y) / font.getLineSpacing(charSize)) == currentLine && text.getString()[pos22] != '\n') @@ -91,13 +94,13 @@ void TextInput::removeLine() void TextInput::newLine() { - + currentLine++; charCountLine.insert(charCountLine.begin() + currentLine, 0); charCountLine[currentLine]++; text.setString(string(text.getString()).insert(selectionBegin, "\n")); selectionBegin++; - + } void TextInput::createNewLine() @@ -108,7 +111,7 @@ void TextInput::createNewLine() cutSelection(); if (text.getString()[selectionBegin] != '\n') { - + int cpt = selectionBegin; while (cpt < text.getString().toAnsiString().size() && text.getString()[cpt] != '\n') @@ -119,7 +122,7 @@ void TextInput::createNewLine() cpt++; cpt -= selectionBegin; - + charCountLine[currentLine] -= cpt; charCountLine[currentLine]=max(0,charCountLine[currentLine]+1); currentLine++; @@ -168,11 +171,11 @@ bool TextInput::modified() editing = true; cursorBlink = 0; currentLine = min(charCountLine.size() - 1, (mouse.pos.y - bg.getPosition().y) / font.getLineSpacing(charSize)); - + int stringPos = 0; sIndex = getCursorIndex(stringPos); - + selectionBegin = mouse.pos.x < x + title.getLocalBounds().width + 8 ? stringPos : sIndex; recalcCursorPos(); mouseLock = 1; @@ -180,8 +183,8 @@ bool TextInput::modified() int stringPosLastLine; pos2 = getCursorIndex(stringPosLastLine); - - + + if (mouse.pos.x < text.getPosition().x) { @@ -189,7 +192,7 @@ bool TextInput::modified() cursor.setPosition(text.getPosition().x, text.findCharacterPos(selectionBegin).y); - + while (pos2 > 0 && text.getString()[pos2 - 1] != '\n') { pos2--; } @@ -235,7 +238,7 @@ bool TextInput::modified() unselect(); } bg.setFillColor(colors[TEXTINPUTBG]); - + } @@ -278,7 +281,7 @@ bool TextInput::modified() charCountLine[currentLine]--; text.setString(string(text.getString()).erase(selectionBegin, 1)); } - + } else { @@ -295,11 +298,11 @@ bool TextInput::modified() if (textEntered[textEnteredCount] == 8) { // backspace - + if ((int)round(selection.getSize().x) == 0) { - + if (selectionBegin > 0) { if (text.getString().toAnsiString()[selectionBegin - 1] == '\n') { @@ -325,14 +328,14 @@ bool TextInput::modified() text.setString(string(text.getString()).erase(selectionBegin, 1)); } } - - + + } else { cutSelection(); } - + recalcCursorPos(); return true; } @@ -353,7 +356,7 @@ bool TextInput::modified() { createNewLine(); } - + int start=selectionBegin; float ssize=0; while (text.getString()[start] != '\n' && start < (int)text.getString().toAnsiString().length()-1) @@ -361,7 +364,7 @@ bool TextInput::modified() start++; } int lineSize = text.findCharacterPos(start).x; - + if (lineSize - bg.getPosition().x < bg.getSize().x) { @@ -371,7 +374,7 @@ bool TextInput::modified() pos2++; recalcCursorPos(); } - + } return true; } @@ -392,15 +395,15 @@ bool TextInput::modified() { canChangeLine=false; } - + while (text.findCharacterPos(selectionBegin).x > text.findCharacterPos(old).x) { - + selectionBegin--; if (text.getString()[selectionBegin] == '\n' && !canChangeLine) break; } - + currentLine = max(0, currentLine - 1); cursorBlink = 0; @@ -571,4 +574,4 @@ void TextInput::unselect() editing = false; bg.setOutlineColor(colors[TEXTINPUTOUTLINE]); selection.setSize(Vector2f(0, 19)); -} \ No newline at end of file +} diff --git a/src/gui/vumeter/stereovumeter.cpp b/src/gui/vumeter/stereovumeter.cpp index 0b5f579..0efac38 100644 --- a/src/gui/vumeter/stereovumeter.cpp +++ b/src/gui/vumeter/stereovumeter.cpp @@ -1,5 +1,7 @@ #include "vumeter.hpp" +#include + StereoVuMeter::StereoVuMeter(int x, int y) : vuLeft(x, y, "L"), vuRight(x + 60, y, "R") { for (int i = 0; i < 5; i++) diff --git a/src/midi/midi_import.cpp b/src/midi/midi_import.cpp index b8858ce..0f26f4f 100644 --- a/src/midi/midi_import.cpp +++ b/src/midi/midi_import.cpp @@ -4,6 +4,8 @@ #include "../views/settings/configEditor.hpp" #include "../libs/simpleini/SimpleIni.h" +#include + extern ConfigEditor* config; extern CSimpleIniA ini_gmlist; @@ -1058,7 +1060,7 @@ int parseMidiRows(unsigned short delta_time_ticks) } } else - {// meta + {// meta eventType = midifile.get(); switch (eventType) { @@ -1268,4 +1270,4 @@ int midiImport(const char* filename) fm_buildStateTable(fm, 0, fm->patternCount, 0, FM_ch); return 0; -} \ No newline at end of file +} diff --git a/src/views/pattern/patternSelection.cpp b/src/views/pattern/patternSelection.cpp index 8b94c5f..84a628e 100644 --- a/src/views/pattern/patternSelection.cpp +++ b/src/views/pattern/patternSelection.cpp @@ -1,6 +1,8 @@ #include "patternSelection.hpp" #include "../../gui/gui.hpp" +#include + PatternSelection::PatternSelection() : bg(Vector2f(COL_WIDTH, ROW_HEIGHT)), moving(false), @@ -233,4 +235,4 @@ int PatternSelection::getMovedType() bool PatternSelection::isSingle() { return ((int)round(bg.getSize().x) == COL_WIDTH && (int)round(bg.getSize().y) == (int)ROW_HEIGHT); -} \ No newline at end of file +} diff --git a/src/views/settings/configEditor_soundDevice.cpp b/src/views/settings/configEditor_soundDevice.cpp index fb9dc78..790d779 100644 --- a/src/views/settings/configEditor_soundDevice.cpp +++ b/src/views/settings/configEditor_soundDevice.cpp @@ -6,12 +6,14 @@ #include "pa_win_ds.h" #endif +#include + extern PaStream *stream; extern PaStreamParameters out; int nearestPow2( int aSize ){ - return round(pow( 2, round( log( aSize ) / log( 2 ) ) )); + return round(pow( 2, round( log( aSize ) / log( 2 ) ) )); } int ConfigEditor::selectSoundDevice(int soundDeviceId, int _samplerate, int _latency, bool force) @@ -138,7 +140,7 @@ void ConfigEditor::selectBestSoundDevice() int soundDeviceId = atoi(ini_config.GetValue("config", "soundDeviceId", "-1")); if (equalsIgnoreCase(lastRunVersion.c_str(), "1.4")) { - + soundDeviceId+=directXdevicesCount; } int sampleRate = atoi(ini_config.GetValue("config", "sampleRate", "-1"));