Working on GUI for testbed application
This commit is contained in:
parent
7d0b5df216
commit
b15d46a95f
|
@ -47,7 +47,6 @@ Gui::Gui(TestbedApplication* app) : mApp(app) {
|
||||||
Gui::~Gui() {
|
Gui::~Gui() {
|
||||||
|
|
||||||
|
|
||||||
//imguiRenderGLDestroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initialize the GUI
|
/// Initialize the GUI
|
||||||
|
@ -217,7 +216,7 @@ void Gui::createSettingsPanel() {
|
||||||
|
|
||||||
// Velocity solver iterations
|
// Velocity solver iterations
|
||||||
Widget* panelVelocityIterations = new Widget(mPhysicsPanel);
|
Widget* panelVelocityIterations = new Widget(mPhysicsPanel);
|
||||||
panelVelocityIterations->setLayout(new BoxLayout(Orientation::Horizontal, Alignment::Fill, 0, 5));
|
panelVelocityIterations->setLayout(new BoxLayout(Orientation::Horizontal, Alignment::Middle, 0, 5));
|
||||||
Label* labelVelocityIterations = new Label(panelVelocityIterations, "Velocity solver","sans-bold");
|
Label* labelVelocityIterations = new Label(panelVelocityIterations, "Velocity solver","sans-bold");
|
||||||
labelVelocityIterations->setFixedWidth(120);
|
labelVelocityIterations->setFixedWidth(120);
|
||||||
TextBox* textboxVelocityIterations = new TextBox(panelVelocityIterations);
|
TextBox* textboxVelocityIterations = new TextBox(panelVelocityIterations);
|
||||||
|
@ -229,6 +228,8 @@ void Gui::createSettingsPanel() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
float value = std::stof(str);
|
float value = std::stof(str);
|
||||||
|
std::ostringstream out;
|
||||||
|
out << std::setprecision(0) << std::fixed << value;
|
||||||
|
|
||||||
if (value < 1 || value > 1000) return false;
|
if (value < 1 || value > 1000) return false;
|
||||||
|
|
||||||
|
@ -246,7 +247,7 @@ void Gui::createSettingsPanel() {
|
||||||
|
|
||||||
// Position solver iterations
|
// Position solver iterations
|
||||||
Widget* panelPositionIterations = new Widget(mPhysicsPanel);
|
Widget* panelPositionIterations = new Widget(mPhysicsPanel);
|
||||||
panelPositionIterations->setLayout(new BoxLayout(Orientation::Horizontal, Alignment::Fill, 0, 5));
|
panelPositionIterations->setLayout(new BoxLayout(Orientation::Horizontal, Alignment::Middle, 0, 5));
|
||||||
Label* labelPositionIterations = new Label(panelPositionIterations, "Position solver","sans-bold");
|
Label* labelPositionIterations = new Label(panelPositionIterations, "Position solver","sans-bold");
|
||||||
labelPositionIterations->setFixedWidth(120);
|
labelPositionIterations->setFixedWidth(120);
|
||||||
TextBox* textboxPositionIterations = new TextBox(panelPositionIterations);
|
TextBox* textboxPositionIterations = new TextBox(panelPositionIterations);
|
||||||
|
@ -258,6 +259,8 @@ void Gui::createSettingsPanel() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
float value = std::stof(str);
|
float value = std::stof(str);
|
||||||
|
std::ostringstream out;
|
||||||
|
out << std::setprecision(0) << std::fixed << value;
|
||||||
|
|
||||||
if (value < 1 || value > 1000) return false;
|
if (value < 1 || value > 1000) return false;
|
||||||
|
|
||||||
|
@ -275,7 +278,7 @@ void Gui::createSettingsPanel() {
|
||||||
|
|
||||||
// Time before sleep
|
// Time before sleep
|
||||||
Widget* panelTimeSleep = new Widget(mPhysicsPanel);
|
Widget* panelTimeSleep = new Widget(mPhysicsPanel);
|
||||||
panelTimeSleep->setLayout(new BoxLayout(Orientation::Horizontal, Alignment::Fill, 0, 5));
|
panelTimeSleep->setLayout(new BoxLayout(Orientation::Horizontal, Alignment::Middle, 0, 5));
|
||||||
Label* labelTimeSleep = new Label(panelTimeSleep, "Time before sleep","sans-bold");
|
Label* labelTimeSleep = new Label(panelTimeSleep, "Time before sleep","sans-bold");
|
||||||
labelTimeSleep->setFixedWidth(120);
|
labelTimeSleep->setFixedWidth(120);
|
||||||
out.str("");
|
out.str("");
|
||||||
|
@ -307,10 +310,9 @@ void Gui::createSettingsPanel() {
|
||||||
textboxTimeSleep->setFontSize(16);
|
textboxTimeSleep->setFontSize(16);
|
||||||
textboxTimeSleep->setAlignment(TextBox::Alignment::Right);
|
textboxTimeSleep->setAlignment(TextBox::Alignment::Right);
|
||||||
|
|
||||||
|
|
||||||
// Sleep linear velocity
|
// Sleep linear velocity
|
||||||
Widget* panelSleepLinearVel = new Widget(mPhysicsPanel);
|
Widget* panelSleepLinearVel = new Widget(mPhysicsPanel);
|
||||||
panelSleepLinearVel->setLayout(new GridLayout(Orientation::Horizontal, 2, Alignment::Middle, 5, 5));
|
panelSleepLinearVel->setLayout(new GridLayout(Orientation::Horizontal, 2, Alignment::Middle, 0, 5));
|
||||||
Label* labelSleepLinearVel = new Label(panelSleepLinearVel, "Sleep linear velocity","sans-bold");
|
Label* labelSleepLinearVel = new Label(panelSleepLinearVel, "Sleep linear velocity","sans-bold");
|
||||||
labelSleepLinearVel->setFixedWidth(120);
|
labelSleepLinearVel->setFixedWidth(120);
|
||||||
out.str("");
|
out.str("");
|
||||||
|
@ -344,7 +346,7 @@ void Gui::createSettingsPanel() {
|
||||||
|
|
||||||
// Sleep angular velocity
|
// Sleep angular velocity
|
||||||
Widget* panelSleepAngularVel = new Widget(mPhysicsPanel);
|
Widget* panelSleepAngularVel = new Widget(mPhysicsPanel);
|
||||||
panelSleepAngularVel->setLayout(new GridLayout(Orientation::Horizontal, 2, Alignment::Fill, 5, 5));
|
panelSleepAngularVel->setLayout(new GridLayout(Orientation::Horizontal, 2, Alignment::Middle, 0, 5));
|
||||||
Label* labelSleepAngularVel = new Label(panelSleepAngularVel, "Sleep angular velocity","sans-bold");
|
Label* labelSleepAngularVel = new Label(panelSleepAngularVel, "Sleep angular velocity","sans-bold");
|
||||||
labelSleepAngularVel->setFixedWidth(120);
|
labelSleepAngularVel->setFixedWidth(120);
|
||||||
out.str("");
|
out.str("");
|
||||||
|
@ -408,7 +410,7 @@ void Gui::createSettingsPanel() {
|
||||||
void Gui::createProfilingPanel() {
|
void Gui::createProfilingPanel() {
|
||||||
|
|
||||||
Widget* profilingPanel = new Window(mApp, "Profiling");
|
Widget* profilingPanel = new Window(mApp, "Profiling");
|
||||||
profilingPanel->setPosition(Vector2i(15, 530));
|
profilingPanel->setPosition(Vector2i(15, 525));
|
||||||
profilingPanel->setLayout(new BoxLayout(Orientation::Vertical, Alignment::Fill, 10, 5));
|
profilingPanel->setLayout(new BoxLayout(Orientation::Vertical, Alignment::Fill, 10, 5));
|
||||||
profilingPanel->setId("SettingsPanel");
|
profilingPanel->setId("SettingsPanel");
|
||||||
profilingPanel->setFixedWidth(220);
|
profilingPanel->setFixedWidth(220);
|
||||||
|
|
|
@ -216,7 +216,6 @@ void TestbedApplication::drawContents() {
|
||||||
// Check the OpenGL errors
|
// Check the OpenGL errors
|
||||||
checkOpenGLErrors();
|
checkOpenGLErrors();
|
||||||
|
|
||||||
|
|
||||||
mGui.update();
|
mGui.update();
|
||||||
|
|
||||||
// Compute the current framerate
|
// Compute the current framerate
|
||||||
|
@ -324,17 +323,6 @@ void TestbedApplication::computeFPS() {
|
||||||
mPreviousTime = mCurrentTime;
|
mPreviousTime = mCurrentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
// GLFW error callback method
|
|
||||||
void TestbedApplication::error_callback(int error, const char* description) {
|
|
||||||
fputs(description, stderr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Callback method to receive keyboard events
|
|
||||||
void TestbedApplication::keyboard(GLFWwindow* window, int key, int scancode,
|
|
||||||
int action, int mods) {
|
|
||||||
//getInstance().mCurrentScene->keyboardEvent(key, scancode, action, mods);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TestbedApplication::keyboardEvent(int key, int scancode, int action, int modifiers) {
|
bool TestbedApplication::keyboardEvent(int key, int scancode, int action, int modifiers) {
|
||||||
|
|
||||||
if (Screen::keyboardEvent(key, scancode, action, modifiers)) {
|
if (Screen::keyboardEvent(key, scancode, action, modifiers)) {
|
||||||
|
@ -387,49 +375,5 @@ bool TestbedApplication::scrollEvent(const Vector2i &p, const Vector2f &rel) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update scroll on the GUI
|
|
||||||
//Gui::getInstance().setScroll(xAxis, yAxis);
|
|
||||||
|
|
||||||
return mCurrentScene->scrollingEvent(rel[0], rel[1], SCROLL_SENSITIVITY);
|
return mCurrentScene->scrollingEvent(rel[0], rel[1], SCROLL_SENSITIVITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestbedApplication::drawAll() {
|
|
||||||
glClearColor(mBackground[0], mBackground[1], mBackground[2], 1.0f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
|
||||||
|
|
||||||
drawContents();
|
|
||||||
drawWidgets();
|
|
||||||
|
|
||||||
glfwSwapBuffers(mGLFWWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Callback method to receive scrolling events
|
|
||||||
void TestbedApplication::scroll(GLFWwindow* window, double xAxis, double yAxis) {
|
|
||||||
|
|
||||||
// Update scroll on the GUI
|
|
||||||
//Gui::getInstance().setScroll(xAxis, yAxis);
|
|
||||||
|
|
||||||
//getInstance().mCurrentScene->scrollingEvent(xAxis, yAxis, SCROLL_SENSITIVITY);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when a mouse button event occurs
|
|
||||||
void TestbedApplication::mouseButton(GLFWwindow* window, int button, int action, int mods) {
|
|
||||||
|
|
||||||
// Get the mouse cursor position
|
|
||||||
double x, y;
|
|
||||||
glfwGetCursorPos(window, &x, &y);
|
|
||||||
|
|
||||||
//getInstance().mCurrentScene->mouseButtonEvent(button, action, mods, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when a mouse motion event occurs
|
|
||||||
void TestbedApplication::mouseMotion(GLFWwindow* window, double x, double y) {
|
|
||||||
|
|
||||||
int leftButtonState = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT);
|
|
||||||
int rightButtonState = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT);
|
|
||||||
int middleButtonState = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_MIDDLE);
|
|
||||||
int altKeyState = glfwGetKey(window, GLFW_KEY_LEFT_ALT);
|
|
||||||
|
|
||||||
/*getInstance().mCurrentScene->mouseMotionEvent(x, y, leftButtonState, rightButtonState,
|
|
||||||
middleButtonState, altKeyState);*/
|
|
||||||
}
|
|
||||||
|
|
|
@ -135,21 +135,6 @@ class TestbedApplication : public Screen {
|
||||||
/// Compute the FPS
|
/// Compute the FPS
|
||||||
void computeFPS();
|
void computeFPS();
|
||||||
|
|
||||||
/// GLFW error callback method
|
|
||||||
static void error_callback(int error, const char* description);
|
|
||||||
|
|
||||||
/// Callback method to receive keyboard events
|
|
||||||
static void keyboard(GLFWwindow* window, int key, int scancode, int action, int mods);
|
|
||||||
|
|
||||||
/// Callback method to receive scrolling events
|
|
||||||
static void scroll(GLFWwindow* window, double xAxis, double yAxis);
|
|
||||||
|
|
||||||
/// Called when a mouse button event occurs
|
|
||||||
static void mouseButton(GLFWwindow* window, int button, int action, int mods);
|
|
||||||
|
|
||||||
/// Called when a mouse motion event occurs
|
|
||||||
static void mouseMotion(GLFWwindow* window, double x, double y);
|
|
||||||
|
|
||||||
/// Initialize all the scenes
|
/// Initialize all the scenes
|
||||||
void createScenes();
|
void createScenes();
|
||||||
|
|
||||||
|
@ -190,7 +175,7 @@ class TestbedApplication : public Screen {
|
||||||
/// Destructor
|
/// Destructor
|
||||||
virtual ~TestbedApplication();
|
virtual ~TestbedApplication();
|
||||||
|
|
||||||
virtual void drawAll();
|
/// Render the content of the application
|
||||||
virtual void drawContents();
|
virtual void drawContents();
|
||||||
|
|
||||||
/// Window resize event handler
|
/// Window resize event handler
|
||||||
|
|
Loading…
Reference in New Issue
Block a user