Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - kiwon0905

#1
Removing TGUI_API worked. Thank you
#2
Test.h
Code (cpp) Select
#pragma once

struct Test
{
void test();
};


Test.cpp
Code (cpp) Select
#include "Test.h"
#include <SFML/Graphics.hpp>

void Test::test()
{
sf::FloatRect r;
}


main.cpp
Code (cpp) Select
#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>
int main()
{
sf::FloatRect r;
return 0;
}


Hi I'm trying to compile the above code on Visual studio 2017 and I get "error LNK2005: "public: __thiscall sf::Rect<float>::Rect<float>(void)" (??0?$Rect@M@sf@@QAE@XZ) already defined in Test.obj"

The error is gone when I comment out the #include <TGUI/TGUI.hpp>
Is this a problem with TGUI?
#3
Help requests / Re: How to use ScrollablePanel?
21 October 2017, 23:00:25
How about taking similar approach to SFGUI?

enum ScrollbarPolicy
{
    VerticalAutomatic = 1 << 0,
    VerticalAlways = 1 << 1,
    VerticalNever = 1 << 2,
    HorizontalAutomatic = 1 << 3,
    HorizontalAlways = 1 << 4,
    HorizontalNeve = 1 << 5
}
void setScrollbarPolicy(ScrollbarPolicy policy);
#4
Help requests / Re: How to use ScrollablePanel?
21 October 2017, 01:58:15
Thank you. I really appreciate your work.
I have a last question:

Code (cpp) Select

sf::RenderWindow window{ { 800, 600 }, "Window" };
tgui::Gui gui{ window }; // Create the gui and attach it to the window
auto scrollPanel = tgui::ScrollablePanel::create({ "50%", "50%" });
auto grid = tgui::Grid::create();
for (int i = 0; i < 100; ++i)
{
auto label = tgui::Label::create("Hi");
label->getRenderer()->setBackgroundColor(sf::Color::Green);
label->setSize({ tgui::bindWidth(scrollPanel), tgui::bindHeight(scrollPanel) / 10});
grid->addWidget(label, i, 0);
}
scrollPanel->add(grid);
gui.add(scrollPanel);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();

gui.handleEvent(event); // Pass the event to the widgets
}
window.clear();
gui.draw(); // Draw all widgets
window.display();
}





Using the above code, I get a horizontal scrollbar. When setting the size of the label, I think i need to subtract the width of the vertical scrollbar to not get it. How can I get the size of the scrollbar?
#5
Help requests / Re: How to use ScrollablePanel?
19 October 2017, 14:54:21

Ok i think i just messed up the order of grid.add(scrollPanel); and scrollPanel.add(grid); before.
Thanks.
#6
Help requests / Re: How to use ScrollablePanel?
19 October 2017, 03:26:41
Hi texus,
I'm trying to make something like this:


I tried inserting HorizontalLayouts to the grids, but I don't get the scrollbars.
Code (cpp) Select
auto scrollPanel = tgui::ScrollablePanel::create({ "75%", "75%" });
scrollPanel->getRenderer()->setBackgroundColor(sf::Color::Green);
auto grid = tgui::Grid::create();
for (int i = 0; i < 100; ++i)
{
auto h = tgui::HorizontalLayout::create({ tgui::bindWidth(scrollPanel), tgui::bindHeight(scrollPanel) / 10 });
h->add(tgui::Label::create("Hello"));
h->add(tgui::Label::create("Hello"));
h->add(tgui::Label::create("Hello"));
h->add(tgui::Label::create("Hello"));
grid->addWidget(h, i, 0);
}

gui.add(scrollPanel);
scrollPanel->add(grid);




What would be the best way to implement something like this?
#7
Help requests / Re: How to use ScrollablePanel?
18 October 2017, 22:17:23
The fix works. Thank you for the fast response!
#8
Help requests / How to use ScrollablePanel?
18 October 2017, 03:49:28
Code (cpp) Select

auto scrollPanel = tgui::ScrollablePanel::create({ "300", "300" });
scrollPanel->getRenderer()->setBackgroundColor(sf::Color::White);
auto grid = tgui::Grid::create();
grid->setAutoSize(true);

for (int r = 0; r < 100; ++r)
grid->addWidget(tgui::Label::create("h"), r, 0);
scrollPanel->add(grid);
gui.add(scrollPanel);


I'd like the scrollbar to appear when the grid gets bigger than the panel, but I don't see any scrollbar.