Yes, this is indeed a typo (the code was like that in v0.5), thanks for reporting.
It will be fixed in the next few minutes.
It will be fixed in the next few minutes.
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 MenuQuotewhen i use callback.text=="Open" only the first method will be calledI'm not sure what you mean with this.
this->moveTilevoid moveSprite(tgui::Slider::Ptr slider, sf::Sprite& sprite, int minY, int maxY)
{
// Puts the sprite on position minY when the slider has value 0,
// on position maxY when the slider has its maximum value,
// and somewhere inbetween otherwise.
// Note that this formula will only work when the minimum of slider is 0, otherwise it has to be changed.
sprite.setPosition(sprite.getPosition().x, minY + (slider->getValue() / (float)slider->getMaximum()) * (maxY - minY));
}
// Let the slider call the moveSprite function when its value changes.
// The sprite will be placed between Y position 20 and 100, the X position will remain unchanged here.
slider->bindCallback(std::bind(moveSprite, slider, std::ref(sprite), 20, 100), tgui::Slider::ValueChanged);// pointerToMyClassInstance will be 'this' when this line is inside a function of MyClass.
slider->bindCallback(std::bind(&MyClass::moveSprite, pointerToMyClassInstance, slider, std::ref(sprite), 20, 100), tgui::Slider::ValueChanged);tgui::Canvas::Ptr canvas(*child);
canvas->setSize(child->getSize().x, child->getSize().y);
// This code is executed every time the sprite/texture changes.
// Either once when the sprite is a static image, or every frame when constantly changing the image.
canvas->clear();
canvas->draw(sprite);
canvas->display();
tgui::EditBox::Ptr name(*create);create->add(name);tgui::Button::Ptr button(gui);tgui::ChildWindow::Ptr child(gui);
tgui::Button::Ptr button(*child);
.QuoteOtherwise, I'm happy to wait until your updated release.I try to not make multiple releases in less than a month, especially not for one small bug. Creating these precompiled libraries is too time consuming. I have automated the compilation, but there is still a lot of work to do on every release. So you shouldn't expect a v0.6.4 release soon.
tgui::Label::Ptr label(gui);
label->setText("Hello");gui.setGlobalFont("data/TGUI/fonts/DejaVuSans.ttf");labelUsername->setTextColor(sf::Color::Black);
QuoteI don't totally understand your codeThat piece of code isn't meant to be understood. Its meant to be written once and hope that you never have to change it again
.Quote(You just wrote m_background and m_size in place of m_Background and m_Size :p)Thats because I was developing on the v0.7 branch, I made a small naming convention change there. Luckily you could see the mistake yourself here, in other widgets there were differences like m_LeftBorder vs m_borders.left.
sf::Vector2f topLeftPosition
= states.transform.transformPoint(((getPosition().x - target.getView().getCenter().x + (target.getView().getSize().x / 2.f)) * target.getView().getViewport().width) + (target.getView().getSize().x * target.getView().getViewport().left),
((getPosition().y - target.getView().getCenter().y + (target.getView().getSize().y / 2.f)) * target.getView().getViewport().height) + (target.getView().getSize().y * target.getView().getViewport().top));
sf::Vector2f bottomRightPosition
= states.transform.transformPoint((getPosition().x + m_background.getSize().x - target.getView().getCenter().x + (target.getView().getSize().x / 2.f)) * target.getView().getViewport().width + (target.getView().getSize().x * target.getView().getViewport().left),
(getPosition().y + m_background.getSize().y - target.getView().getCenter().y + (target.getView().getSize().y / 2.f)) * target.getView().getViewport().height + (target.getView().getSize().y * target.getView().getViewport().top));sf::Vector2f topLeftPosition
= states.transform.transformPoint(((getPosition().x - target.getView().getCenter().x + (target.getView().getSize().x / 2.f)) * target.getView().getViewport().width) + (target.getView().getSize().x * target.getView().getViewport().left),
((getPosition().y - target.getView().getCenter().y + (target.getView().getSize().y / 2.f)) * target.getView().getViewport().height) + (target.getView().getSize().y * target.getView().getViewport().top));
sf::Vector2f bottomRightPosition
= states.transform.transformPoint((getPosition().x + m_size.x - target.getView().getCenter().x + (target.getView().getSize().x / 2.f)) * target.getView().getViewport().width + (target.getView().getSize().x * target.getView().getViewport().left),
(getPosition().y + m_size.y - target.getView().getCenter().y + (target.getView().getSize().y / 2.f)) * target.getView().getViewport().height + (target.getView().getSize().y * target.getView().getViewport().top));Quote(Texus: I speak french at first, and I can see you're belgian, so can I speak with you in french?)Nope, I speak dutch. I know a little french, but not enough to really communicate with it.
QuoteI changed this part though, still look good?Yep, that still looks good.
Quote// <---since we already found a widget, why keep going, why not break out of loop; ?As you can see, when the boolean is false, the mouseNotOnWidget() function is called.
#include <TGUI/TGUI.hpp>
///////////////////////////////////////////////////////////////////////
tgui::Widget::Ptr mouseOnWhichWidget(float x, float y, std::vector<tgui::Widget::Ptr>& widgets)
{
bool widgetFound = false;
tgui::Widget::Ptr widget = nullptr;
// Loop through all widgets
for (std::vector<tgui::Widget::Ptr>::reverse_iterator it = widgets.rbegin(); it != widgets.rend(); ++it)
{
// Check if the widget is visible and enabled
if (((*it)->isVisible()) && ((*it)->isEnabled()))
{
if (widgetFound == false)
{
// Return the widget if the mouse is on top of it
if ((*it)->mouseOnWidget(x, y))
{
widget = *it;
widgetFound = true;
}
}
else // The widget was already found, so tell the other widgets that the mouse can't be on them
(*it)->mouseNotOnWidget();
}
}
return widget;
}
///////////////////////////////////////////////////////////////////////
int main()
{
sf::RenderWindow window(sf::VideoMode(930, 700), "TGUI window");
tgui::Gui gui(window);
if (gui.setGlobalFont("TGUI/fonts/DejaVuSans.ttf") == false)
return 1;
tgui::Widget::Ptr draggingWidget = nullptr;
sf::Vector2f draggingPosition;
tgui::Panel::Ptr panel1(gui);
tgui::Panel::Ptr panel2(gui);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
else
{
if (event.type == sf::Event::MouseButtonPressed)
{
tgui::Widget::Ptr widget = mouseOnWhichWidget(event.mouseButton.x, event.mouseButton.y, gui.getWidgets());
if ((widget.get() == panel1.get()) || (widget.get() == panel2.get()))
{
if (mouseOnWhichWidget(event.mouseButton.x, event.mouseButton.y, tgui::Panel::Ptr(widget)->getWidgets()) == nullptr)
{
draggingWidget = widget;
draggingPosition = sf::Vector2f(event.mouseButton.x, event.mouseButton.y);
}
}
}
else if (event.type == sf::Event::MouseButtonReleased)
{
draggingWidget = nullptr;
}
else if (event.type == sf::Event::MouseMoved)
{
if (draggingWidget != nullptr)
{
draggingWidget->setPosition(draggingWidget->getPosition().x + event.mouseMove.x - draggingPosition.x,
draggingWidget->getPosition().y + event.mouseMove.y - draggingPosition.y);
draggingPosition = sf::Vector2f(event.mouseMove.x, event.mouseMove.y);
}
}
}
gui.handleEvent(event);
}
window.clear();
gui.draw();
window.display();
sf::sleep(sf::milliseconds(1));
}
return 0;
}
. Trying to compare two widget pointers is not possible (function can't access private variable). That is why you have to use the '.get()' like in the above code.
QuoteAre there options I didn't see?I don't see another option either.
Quote3. Make child windows transparent and disabled when not in moving mode. Unfortunately when transparent, the child window (logically) makes its contents transparent too.There are of course workarounds to avoid making the whole contents transparent (without having to reset the transparency of every single widget in the window). You could have a panel inside the child window and all widgets inside the panel. Then after setting transparency of the child window to 0, you just set the panel to transparency 255 again.
Quote1. First idea was panels, but they can't be moved around without me doing stuff with them, and I'd rather just do solution 4 than have to deal with panels that overlap, are invisible, and or are disabled.If you would use a slightly edited version of the code in Container::mouseOnWhichWidget then it shouldn't be much of a problem. But unlike my suggestion before which didn't handle overlapping, you have to call the code twice: once to find out on which panel the mouse is on, and then on the widgets inside the panel to check if the mouse is on them. The code in that function also takes care of ignoring the invisible and disabled widgets.
// Do this when the mouse goes down
if (panel->mouseOnWidget(x, y)
{
bool mouseOnAnyWidget = false;
for (auto& widget : panel->getWidgets())
{
if (widget->mouseOnWidget(x - panel->getPosition(), y - panel->getPosition()))
{
mouseOnAnyWidget = true;
break;
}
}
// If mouseOnAnyWidget is false here then you should start dragging the panel, until you get a mouse released event
}gui.handleEvent(event, false);QuoteSo, i must try to compile sfml with my compiler?You can try it. But if you really downloaded the SJLJ version and the compiler used by codeblocks is still the correct one then it isn't going to make a difference.
QuoteI noticed, that the app requires at once libgcc_s_dw2-1.dll and libgcc_s_sjlj-1.dll. How he can require two different libraries at once?I never had this problem, so I can only guess. You have three things: the code that you compile yourself, the sfml libs and the tgui libs. I would except that one of these is compiled with the wrong compiler.
QuoteI get the same error, but the procedure is gxx_personality_sj0These kind of errors mean that the libraries aren't compatible with the compiler as far as I know.