Main Menu
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 - RitoonL

#1
Hello, thanx for your answer.

Did I say double arrow???

Well, the current issue for me is to have resizing arrow whatever they look like. As the program aims to be windows/Linux cross-platform it's not a problem that cursors are Linux style. I did not even noticed that resizing system was so different between Linux and windows.

We started to develop on 0.8 branch... Stables are much more psychologically relaxing, I guess... But if you add these mouse methods on 0.9 branche we'll move into it. I'm a little afraid of retro compatibility between 0.8 and 0.9,  do you think we'll have to re-write a lot or is it can be used as is?

I'm impressed on how you handle feedbacks and did not expected you to develop a new class for us... We're really grateful for this... I'll keep on monitoring changelog to see when it's ready.

Thanx.

RLF

#2
Hello Texus,

I'm searching how to change the mouse pointer when resizing childwindow. I have searched but did not found anything so far.

Is it possible to change the mouse pointer into double arrows when the position of the pointer is ResizableBorderWidth coordinates ?

Thanks by advance,

RLF
#3
Hi Texus,

I did not forgot that i had to reply here.

Thanx for your answer ...

Here is where we are now. Oh yes we did it, we compiled on the Pi, your answered helped us to seek that the memory card was full, there was no space for the Os swap, so the Pi went out of memory and froze. It's fixed now.

For the other message about the Deprecated method, we still do not figure why, the method is definitly not called in the code. As i coded myself all the things that use the mouse, i know i did not used this method. We are looking around to seek where is the problem but it's not a high priority task, as the code compiles we'll chase it for the next code merge.

Regards,

RitoonL
#4
Hello,

TGUI_DEPRECATED("Use leftMouseButtonNoLongerDown instead") virtual void mouseNoLongerDown();

I have this warning all the time when i am compiling. I am not using it in my code. How can i stop those warnings ?

Also, when compiling on Raspberry Pi, The OS crashes (yes the OS) just before this message (if we compare the logs from windows). Note that TGUI has been installed with succces as we are compiling exemple codes just fine.

is it possible that the crash could be related to the message ? For me, not ... but my dev-mate thinks so ...

news of the project : We're still working on it ... cleaning a lot of things, before adding new features.

Thanks by advance.
#5
understood,

Thanks
#6
Help requests / Signals, unbound parameter
01 June 2020, 16:58:51
Hello,

I'm trying to connect the SizeChanged signal from a child window.

I followed the tutorial and tried to do a simple thing to test :


Code (cpp) Select
void Ch_window::_test()
{
    cout<<"size changed"<<endl;
}

void Ch_window::channels_window (sf::RenderWindow &window, tgui::Gui& gui)
{
    auto channels = tgui::ChildWindow::create();
    channels->setTitle("Channels");
    channels->setTitleAlignment(tgui::ChildWindow::TitleAlignment::Left);
    channels->setResizable(true);//(tgui::ChildWindow::setResizable=true);
    channels->getRenderer()->setBackgroundColor(sf::Color::Black);
    channels->getRenderer()->setTitleBarHeight(15);
    channels->getRenderer()->setTitleColor(sf::Color::White);
    channels->getRenderer()->setTitleBarColor(sf::Color(20, 30, 60));
    channels->getRenderer()->setBorders(1);
    channels->getRenderer()->setMinimumResizableBorderWidth(3);
    channels->getRenderer()->setBorderColor(sf::Color(20, 30, 60));
    channels->connect("SizeChanged", _test);
}


this give me an error when i run the program

terminate called after throwing an instance of 'tgui::Exception'
  what():  Signal 'SizeChanged' could not provide data for unbound parameters.

i search about thes unbound parameters but did not find much. what i understand is that SizeChanged signal wants to give something to my function but i did not set arguments to my fuction to receive it.

is it newsize ? my _test function should havec a vector2f as argument ? ***edit*** seems not, void _test(sf::Vector2f new_size) did not changed anything.

thanks by advance,

RitoonL

#7
Very interesting answer,

i really like the class solution ... Because i can make each window as a class and forget it when it's done or drawing all windows in a class and make them interact easily. Now that you opened my eyes on it, i think making a class for the  windows is a good way. As i want to make magnetic windows, they can pass their coordonates to each other. would be better for windows arrangement.

i'll bookmark this and read it again and again ... I really think passing things in C++ code is the hardest for me, i need more comprehension for this. Hope it will come with experience.

Regards,

RLF
#8
Hello Texus

Coding is definitly a interesting puzzle.

tgui::Canvas::Ptr canvas = channels_window(window, gui); // that was the solution

i found the solution myself, i was too focused of what the fuctions were taking and never worried of what they were returning. I needed the first fuction called in the main returning a pointer of the canvas, so i could call my second function inside the loop, passing the canva. The canva is now refreshed. Everything is not perfect yet, but still, i'm progressing !!!

thanks for all the time you spent helping me, i know it's no fun helping newbies, specially when they lack of basic knowledges like me, you're not intended to be my teatcher but you had the patience to :) i'm grateful for this.

Regards,

RitoonL
#9
the features you just add seems very interesting, we'll look at it...

I tought i finished with this canvas code, but i'm struggling again with one thing.

I guess i'm not structuring my code correctly.

Code (cpp) Select
void channel_sorting(tgui::Canvas::Ptr &canvas)  // the fuction can't be called in the main because it's waiting &canvas as argument
{
    int displayed_channels=0;
    for(uint16_t i=0;i<1025;i++)
        {
            uint16_t column = (displayed_channels%10 );
            uint16_t row = (displayed_channels/10);
        if(address_channel[i]>0)
        {
            ch(i) draw_channel(canvas,column*52,row*72);//ch(i) is #define ch(x) tab_Channel[address_channel[x]]->
            displayed_channels++;
        }
     canvas->display();
    }
}


void channels_window(sf::RenderWindow &window, tgui::Gui& gui)
{
    auto channels = tgui::ChildWindow::create();
    channels->setTitle("Channels");
    channels->setTitleAlignment(tgui::ChildWindow::TitleAlignment::Left);
    channels->setResizable(true);//(tgui::ChildWindow::setResizable=true);
    channels->getRenderer()->setBackgroundColor(sf::Color::Black);
    channels->getRenderer()->setTitleBarHeight(15);
    channels->getRenderer()->setTitleColor(sf::Color::White);
    channels->getRenderer()->setTitleBarColor(sf::Color(20, 30, 60));
    channels->getRenderer()->setBorders(1);
    channels->getRenderer()->setMinimumResizableBorderWidth(3);
    channels->getRenderer()->setBorderColor(sf::Color(20, 30, 60));

    auto scrollbar = tgui::Scrollbar::create();
    scrollbar->getRenderer()->setTrackColor(sf::Color(20, 30, 60));
    scrollbar->getRenderer()->setThumbColor(sf::Color(70, 70, 70));
    scrollbar->getRenderer()->setThumbColorHover(sf::Color(70, 70, 70));
    scrollbar->getRenderer()->setArrowBackgroundColor(sf::Color(20, 30, 60));
    scrollbar->getRenderer()->setArrowBackgroundColorHover(sf::Color(20, 30, 60));
    scrollbar->getRenderer()->setArrowColor(sf::Color(70, 70, 70));
    scrollbar->getRenderer()->setArrowColorHover (sf::Color(70, 70, 70));
    scrollbar->setSize({10, bindHeight(channels)});
    scrollbar->setPosition({"100% - width", 0});

    auto channel_canvas= tgui::Canvas::create();
    channel_canvas->setSize(350,1000);

    sf::VertexArray channel_quad;

    gui.add(channels);
    channels->add(scrollbar);
    channels->add(channel_canvas);
    channel_sorting(channel_canvas);
}


in void channel_sorting

i'm creating the objects and formatting them. if i create 20 channels objects, they will be displayed in 2 colums of 10. columns and rows will adapt the size of the window in the future.

in void channels_window

i'm creating the channel window, 1 child window, 1 scroll bar and 1 canva (channel_canva), i will do an adaptative code later for the size of the canva, depending on how many channels are displayed, the scrollbar will be in relation of the canva to scroll channels out of the child window, but tis is not the problem i have now.

when the program starts, channels objects are not created. They are created by the user and the user can create more at anytime, it also have dynamic texts and colors. This part of the program works great.

the main problem is that i can't figure how to update the canva. i tried many solutions but the only way i found to update the canva is calling void channel_window() in the main loop wich duplicates all the GUI object each time the loop executes, but i can see my channels well sorted in the canvas, wich prove that i draw on it.

i copied the canva to channel_canva, i'm not proud of that, but if i use (tgui::Canvas::Ptr &canvas) as argument of the fuction, wich prevent copying the canvas, i can't use the function in the main.

I know that i must use canva->display() in my main or in a fuction called in the main, but i don't know how to do as the compiler wants the canvas to be declared . I think i'm lacking of knowledge in C++ to do what i want, but as you know me now, i'm fast learner if someone can put me on good rails.

Edit : I tried to declare
tgui::Canvas::Ptr canvas;
in the main and passig it to the functions, it compiles with no error but crashes when i execute the program.

thanks by advance
RitoonL
#10
Hello Texus,

Thanx for your answer, it's usefull again.

You really told me exactly what i was seeking without haveing to ask. Passing the already drawn entitys ... i'll do that.

I have to write the refreshing routine of the canva, i will maybe have questions about that later, but for now, i'm happy, i can pass what i need.

We're trying to optimize display as much as we can, so we're really seeking every opportunity to refresh only what we need and not everything every frame, because we want the software to run on Raspberry pi also. We compiled on a Raspi 3 today with success ... it could not run on a Raspi 2. It's still a previous version of the work that is not using tgui yet, but we're trying to keep in mind every opportunity to optimize display.

Well, i must thank you really much for your work and for your precious help also, be sure that i will ask more in the future !

Regards,

RitoonL



#11
i might be wrong as i am myself a bit not sure of what i'm doing, but you might try to give a size to your canva. It should be because you canvas size is 0
#12
Hello Texus,

Many thanks for this, once again very accurate answer, you were right i did not understood what a renderTarget is.

last question before i'm done with this thread, because i now have a better view of what i can do :

My final objective is to render what i have in my class

Drawing section of my class :

Code (cpp) Select
void Channel::draw_channel(sf::RenderWindow &window,uint16_t x,uint16_t y)
//void Channel::draw_channel(sf::RenderTarget &Canvas,uint16_t x,uint16_t y)

{
    ostringstream chnbr; // channel number into a string
    chnbr<<_channel_number;
    ostringstream lvlstr; // channel level into a string (can't be uint_8t)
    lvlstr<< _display_level;

    sf::Vertex vertex;
    //vertex.position = sf::Vector2f(0, 0);
    sf::VertexArray ch_quad(sf::Quads, 16);

    bool selected=false;
    for(uint16_t i=0; i<selected_chan.size() ;i++)
    {
        if(selected_chan[i]==_channel_number)
        {
            selected=true;
        }
    }

    // Draws under quad supposed to be outline (draw order)
    ch_quad[0].position = sf::Vector2f(0, 0);
    ch_quad[1].position = sf::Vector2f(50, 0);
    ch_quad[2].position = sf::Vector2f(50, 70);
    ch_quad[3].position = sf::Vector2f(0, 70);

    if(selected == false) //color of outline for selection
    {
        ch_quad[0].color = sf::Color(20, 30, 60);
        ch_quad[1].color = sf::Color(20, 30, 60);
        ch_quad[2].color = sf::Color(20, 30, 60);
        ch_quad[3].color = sf::Color(20, 30, 60);
    }
    if(selected == true)
    {
        ch_quad[0].color = sf::Color(255, 255, 255, 255);
        ch_quad[1].color = sf::Color(255, 255, 255, 255);
        ch_quad[2].color = sf::Color(255, 255, 255, 255);
        ch_quad[3].color = sf::Color(255, 255, 255, 255);
    }

    //draws the inside under quad ad sets the color (black)
    ch_quad[4].position = sf::Vector2f(1,1);
    ch_quad[5].position = sf::Vector2f(49,1);
    ch_quad[6].position = sf::Vector2f(49,69);
    ch_quad[7].position = sf::Vector2f(1,69);
    ch_quad[4].color = sf::Color(0, 0, 0);
    ch_quad[5].color = sf::Color(0, 0, 0);
    ch_quad[6].color = sf::Color(0, 0, 0);
    ch_quad[7].color = sf::Color(0, 0, 0);
    //draws the channel strip
    ch_quad[8].position = sf::Vector2f(1,1);
    ch_quad[9].position = sf::Vector2f(49,1);
    ch_quad[10].position = sf::Vector2f(49,17);
    ch_quad[11].position = sf::Vector2f(1,17);
    ch_quad[8].color = sf::Color(20, 30, 60);
    ch_quad[9].color = sf::Color(20, 30, 60);
    ch_quad[10].color = sf::Color(20, 30, 60);
    ch_quad[11].color = sf::Color(20, 30, 60);
    //draws the info strip
    ch_quad[12].position = sf::Vector2f(1,50);
    ch_quad[13].position = sf::Vector2f(49,50);
    ch_quad[14].position = sf::Vector2f(49,69);
    ch_quad[15].position = sf::Vector2f(1,69);
    ch_quad[12].color = sf::Color(20, 30, 60);
    ch_quad[13].color = sf::Color(20, 30, 60);
    ch_quad[14].color = sf::Color(20, 30, 60);
    ch_quad[15].color = sf::Color(20, 30, 60);

    sf::Transform pos;
    pos.translate(x, y);

    //window.draw(ch_quad, pos);
    window.draw(ch_quad, pos);

    // Channel number text
    ch.setFont(font);
    //ch.setString(std::string("ch ") + chnbr.str());
    ch.setString(chnbr.str());
    ch.setCharacterSize(12);
    ch.setLetterSpacing(0.3);
    ch.setFillColor(sf::Color(255, 255, 255));
    ch.setPosition(x+2, y+2);
    window.draw(ch);
    // Level Text
    if(_level>0)
    {
        lvl.setFont(font);
        lvl.setString(std::string("") + lvlstr.str());
        lvl.setCharacterSize(18);
        lvl.setLetterSpacing(0.3);
        if(_channel_mode == false)
            lvl.setFillColor(sf::Color(255, 255, 255));
        else
            lvl.setFillColor(sf::Color(255, 255, 100));
        lvl.setPosition(x+4, y+8);
        window.draw(lvl);
    }

}


I was passing this directly to the sf::renderWindow, but it's not anymore what i want to do.
As you can see, these graphics are made of 1 vertex array of 16 vertexes, and some text that is dynamically updating.

do you think i shall pass each of the component of my drawing and draw them in the function where i create the canva, or pre-rendering it direcly in the class (in a renderTexture, if i did understand well what you said before) and passing the texture to my function. Does it makes sense to do this? What would be better for display performance ? ... you maybe want to know that the class can have several instances (might be between 1 to 4000 instances).

***EDIT*** Or Even maybe making a sprite in the class and pass it ?

Thanks by advance,

RitoonL
#13
Well,

in facts there is a class ready with the drawings that i've created before, this can be displayed in sf::rendererWindow, but now that i'm constructing the GUI, i want it displayed in the canva. I'm just trying to do it step by step because there is already a lot of code ready that i don't want to breack, that's why i want to know how to pass this renderTarget by reference.

I might be wrong but if  i can do from function to function,  i can do  from class to function the same way. The funny thing is that it should be like using the renderWindow, but i don't know why, i'm stalling on this one.

I feel like i want to plug an aspirator on the kitchen sink ...

just for info, here it my class ... i'm not waiting other people do things for me but i need help for this one ... not showing the .h :

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

using namespace std;
using namespace sf;
//sf::Font font;
//sf::Text ch;
//sf::Text lvl;

static sf::Font font;
extern vector <uint16_t> selected_chan;

bool Channel::Init(const std::string& fontFile)
{
    return font.loadFromFile(fontFile);
}

Channel::Channel(uint16_t channel_number):
    _channel_number(channel_number),
    _level(0),
    _channel_mode(true),
    _display_level(0)
{

}

Channel::~Channel()
{
        //a faire imperativement !
}
//-------------------------------------------------

void Channel::draw_channel(sf::RenderWindow &window,uint16_t x,uint16_t y)
//void Channel::draw_channel(sf::RenderTarget &Canvas,uint16_t x,uint16_t y)

{
    //int x=100,y=0;
    //font.loadFromFile("kimberley_bl.ttf");



    ostringstream chnbr; // channel number into a string
    chnbr<<_channel_number;
    ostringstream lvlstr; // channel level into a string (can't be uint_8t)
    lvlstr<< _display_level;

    sf::Vertex vertex;
    //vertex.position = sf::Vector2f(0, 0);
    sf::VertexArray ch_quad(sf::Quads, 16);

    bool selected=false;
    for(uint16_t i=0; i<selected_chan.size() ;i++)
    {
        if(selected_chan[i]==_channel_number)
        {
            selected=true;
        }
    }

    // Draws under quad supposed to be outline (draw order)
    ch_quad[0].position = sf::Vector2f(0, 0);
    ch_quad[1].position = sf::Vector2f(50, 0);
    ch_quad[2].position = sf::Vector2f(50, 70);
    ch_quad[3].position = sf::Vector2f(0, 70);

    if(selected == false) //color of outline for selection
    {
        ch_quad[0].color = sf::Color(20, 30, 60);
        ch_quad[1].color = sf::Color(20, 30, 60);
        ch_quad[2].color = sf::Color(20, 30, 60);
        ch_quad[3].color = sf::Color(20, 30, 60);
    }
    if(selected == true)
    {
        ch_quad[0].color = sf::Color(255, 255, 255, 255);
        ch_quad[1].color = sf::Color(255, 255, 255, 255);
        ch_quad[2].color = sf::Color(255, 255, 255, 255);
        ch_quad[3].color = sf::Color(255, 255, 255, 255);
    }

    //draws the inside under quad ad sets the color (black)
    ch_quad[4].position = sf::Vector2f(1,1);
    ch_quad[5].position = sf::Vector2f(49,1);
    ch_quad[6].position = sf::Vector2f(49,69);
    ch_quad[7].position = sf::Vector2f(1,69);
    ch_quad[4].color = sf::Color(0, 0, 0);
    ch_quad[5].color = sf::Color(0, 0, 0);
    ch_quad[6].color = sf::Color(0, 0, 0);
    ch_quad[7].color = sf::Color(0, 0, 0);
    //draws the channel strip
    ch_quad[8].position = sf::Vector2f(1,1);
    ch_quad[9].position = sf::Vector2f(49,1);
    ch_quad[10].position = sf::Vector2f(49,17);
    ch_quad[11].position = sf::Vector2f(1,17);
    ch_quad[8].color = sf::Color(20, 30, 60);
    ch_quad[9].color = sf::Color(20, 30, 60);
    ch_quad[10].color = sf::Color(20, 30, 60);
    ch_quad[11].color = sf::Color(20, 30, 60);
    //draws the info strip
    ch_quad[12].position = sf::Vector2f(1,50);
    ch_quad[13].position = sf::Vector2f(49,50);
    ch_quad[14].position = sf::Vector2f(49,69);
    ch_quad[15].position = sf::Vector2f(1,69);
    ch_quad[12].color = sf::Color(20, 30, 60);
    ch_quad[13].color = sf::Color(20, 30, 60);
    ch_quad[14].color = sf::Color(20, 30, 60);
    ch_quad[15].color = sf::Color(20, 30, 60);

    sf::Transform pos;
    pos.translate(x, y);

    //window.draw(ch_quad, pos);
    window.draw(ch_quad, pos);

    // Channel number text
    ch.setFont(font);
    //ch.setString(std::string("ch ") + chnbr.str());
    ch.setString(chnbr.str());
    ch.setCharacterSize(12);
    ch.setLetterSpacing(0.3);
    ch.setFillColor(sf::Color(255, 255, 255));
    ch.setPosition(x+2, y+2);
    window.draw(ch);
    // Level Text
    if(_level>0)
    {
        lvl.setFont(font);
        lvl.setString(std::string("") + lvlstr.str());
        lvl.setCharacterSize(18);
        lvl.setLetterSpacing(0.3);
        if(_channel_mode == false)
            lvl.setFillColor(sf::Color(255, 255, 255));
        else
            lvl.setFillColor(sf::Color(255, 255, 100));
        lvl.setPosition(x+4, y+8);
        window.draw(lvl);
    }

}
//-------------------------------------------------

void Channel::set_channel_number(uint16_t channel_number)//Channel.set_channel_number
{
    _channel_number = channel_number;
}
//-------------------------------------------------

uint16_t Channel::get_channel_number()
{
    return _channel_number;
}
//-------------------------------------------------

void Channel::set_level(uint16_t level)//devenu void
{
    _level = level;
    display_level();
}
//-------------------------------------------------

uint16_t Channel::get_level()
{
    return _level;
}
//-------------------------------------------------

void Channel::change_mode(bool channel_mode)
{
    _channel_mode=channel_mode;
}
//-------------------------------------------------

bool Channel::get_mode()
{
    return _channel_mode;
}
//-------------------------------------------------

void Channel::display_level()
{
    if (_channel_mode==false)
    {
        _display_level = (_level/2.55);
    }
    else
    _display_level = _level;
}
#14
Sorry i have to !up the subject because i edited previous one ... oh yeah i hate double posts too !
#15
Ok i understand now that my error is to add the scrollbar to the child window instead of adding it with gui.add and binding it to my child window. I will keep this in mind for the future of the project.

As i'm still a beginner, and self learning, i have to learn by error, even if sometimes i can be considered as stupid/or asking stupid questions. But i have no mentor or school teatcher to who i can refer ... really sorry for that.

Your really accurate answer helps me a lot and i'm grateful for this.

Sorry for the problems with my mailbox, this is really strange, i received the confirmation mail this morning, but never received your personal answer. Thanks for adding me manually.

Regards,

RitoonL