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 - Myster

#1
Help requests / Re: Text offset in Tabs
03 October 2015, 14:08:05
Sorry for delay, I was ill.
It works) Thanks, texus)

But there was a difference (which gives programmers to choose between the stretchable/unstretchable tabs)

1st is:
Code (cpp) Select
winEditConfigTabs = theme->load("tab");
winEditConfigTabs->setTextSize(text_size);
winEditConfigTabs->setPosition(8, 60);
winEditConfigTabs->add(txt_tab_view);
winEditConfigTabs->add(txt_tab_export,false);
winEditConfigTabs->connect("TabSelected", [&](){ ConfigWinUpdate(); } );
winEditConfig->add(winEditConfigTabs); // <==


2nd is:
Code (cpp) Select
winEditConfigTabs = theme->load("tab");
winEditConfig->add(winEditConfigTabs); // <==
winEditConfigTabs->setTextSize(text_size);
winEditConfigTabs->setPosition(8, 60);
winEditConfigTabs->add(txt_tab_view);
winEditConfigTabs->add(txt_tab_export,false);
winEditConfigTabs->connect("TabSelected", [&](){ ConfigWinUpdate(); } );


But I don't know whether to give programmers a choice (?) because stretchable tabs are most commonly used ::)
#2
Help requests / Text offset in Tabs
30 September 2015, 21:14:23
Hello again)

In the last version of TGUI v0.7-alpha2 in my app strange problem appeared:
text on the tabs displaying above the tabs (see the screenshot: texts "View" and "Export" now between buttons and checkbox)

In prev. TGUI versions all was good.
Where my mistake? may be I overlooked something from new docs about tabs? :-\

My code:
Code (cpp) Select
winEditConfigTabs = theme->load("tab");
winEditConfigTabs->setTextSize(text_size);
winEditConfigTabs->setPosition(8, 60);
winEditConfigTabs->add(txt_tab_view);
winEditConfigTabs->add(txt_tab_export,false);
winEditConfigTabs->connect("TabSelected", [&](){ ConfigWinUpdate(); } );
winEditConfig->add(winEditConfigTabs);
#3
Thank you very much! :)
Remains only "space furl", but I agree that's problem in code from other places and not so easy. If there are any ideas, I will say.

I'll try to do something with the EditBox, but a bit studying, I knew that there is almost everywhere a different structure. While I did not even know at what stage the text selection.
#4
Yes! I remembered! Can you add this line, please?

Code (cpp) Select
            else // No double clicking
            {
                if (!(sf::Keyboard::isKeyPressed(sf::Keyboard::LShift) || sf::Keyboard::isKeyPressed(sf::Keyboard::RShift)))
                    m_selStart = caretPosition;
                m_selEnd = caretPosition;


In the "leftMousePressed" function are no events, but in order not to overload with event links it easier to make the line a bit longer?
In any case, I just remember that "Shift + LeftMouseClick" is comfortable too.  ::)
#5
No, you understood correctly. And you've already answered my question) Thank you :)

Quoteif there are multiple whitespace next to each other then they should all be selected
I updated with your changes. You right, it's better. Just now I noticed that in my Notepad++ implemented multiple space selection.

No. Unfortunately, still I don't have an account on the github. In fact, I think I gave the basic idea, but you made a substantial part of it. I mean, not sure that my work here has the weight and whether it is worth to mention me.
But all at your discretion) I'm thankful for all.
My surname and name (with transliteration): Ilyin Mikhail
E-mail: ilyin_my @ mail.ru (without spaces, it's for spam :) )

And yet all the innovations are stable. I've not bumped into bugs or crashes. But I'll let you know if something will (I hope not). I will test my app as a user, and the continuous work will show itself.
Maybe some features I forgot (my feeling). But now they are not significant, if I can't remember)
#6
No problem, the file attached.
I meant in any future and any update and even with any other code, etc.  I understand that it even may take time testing) Just to be comfortable control that will not scare the users of future applications)

QuoteSure, feel free to change it too.
Ok, I try if tomorrow will be a time. I hope)
#7
Now all bugs were terminated. I added a few lines before the scan starting.

Code (cpp) Select
                ...
                // The next click is going to be a normal one again
                m_possibleDoubleClick = false;
               
                // Correct the caret position if the click was to the right of the end of line
                if (m_lines[m_selStart.y].getSize() > 1 && (m_selStart.x == (m_lines[m_selStart.y].getSize()-1) || m_selStart.x == m_lines[m_selStart.y].getSize()))
                {
                    m_selStart.x--;
                    m_selEnd.x = m_selStart.x;
                }
               
                if (isWhitespace(m_lines[m_selStart.y][m_selStart.x]))
                {
                    // Select the space
                    ...


texus, will all of that were implemented in the future tgui's updates? ::) Cause it's very needful things, and I'd not like to do unnecessary inheritances or change sources every update ot other superfluous things. I think the other programmers too) ::)

And how about EditBox? Can I try to add to it similar events? Namely just three:
control
shift
double-click
#8
Ignore my last post please. I rewrote double-click from scratch. But some things have coincided with your code. Although the double-clicking algorithm really was a bit different than Keys' events. And I really didn't use "skippedWhitespace" (it seems superfluous for that event).

There is little bug (if it acknowledges as a bug, it doesn't cause the crash :D ) - when selects the '\n' at the end of line (at the end of the paragraph especially), it selects word on next line or itself '\n' at the current (but visually the caret moves to beginning of the line)

I'll try to find time to finish, so that it will be selected left word or left space, but not the '\n'

But for now this result:

Code (cpp) Select
...
            // Check if this is a double click
            if ((m_possibleDoubleClick) && (m_selStart == m_selEnd) && (caretPosition == m_selEnd))
            {
                // The next click is going to be a normal one again
                m_possibleDoubleClick = false;
               
                if (isWhitespace(m_lines[m_selStart.y][m_selStart.x]))
                {
                    // Select the space
                    m_selEnd.x = m_selStart.x + 1;
                }
                else
                {
                    // Move start pointer to the beginning of the word
                    bool done = false;
                    for (unsigned int j = m_selStart.y + 1; j > 0; --j)
                    {
                        for (unsigned int i = m_selStart.x; i > 0; --i)
                        {
                            if (isWhitespace(m_lines[m_selStart.y][i-1]))
                            {
                                m_selStart.x = i;
                                done = true;
                                break;
                            }
                            else
                                m_selStart.x = 0;
                        }
                       
                        if (!done)
                        {
                            if (m_selStart.x == 0)
                            {
                                if (m_selStart.y > 0)
                                {
                                    m_selStart.y--;
                                    m_selStart.x = m_lines[m_selStart.y].getSize();
                                }
                                else
                                {
                                    done = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            if (m_selStart.x == m_lines[m_selStart.y].getSize())
                            {
                                m_selStart.y++;
                                m_selStart.x = 0;
                            }
                            break;
                        }
                    }
                   
                    // Move start pointer to the end of the word
                    done = false;
                    for (unsigned int j = m_selEnd.y; j < m_lines.size(); ++j)
                    {
                        for (unsigned int i = m_selEnd.x; i < m_lines[m_selEnd.y].getSize(); ++i)
                        {
                            if (isWhitespace(m_lines[m_selEnd.y][i]))
                            {
                                m_selEnd.x = i;
                                done = true;
                                break;
                            }
                            else
                                m_selEnd.x = m_lines[m_selEnd.y].getSize();
                        }
                       
                        if (!done)
                        {
                            if (m_selEnd.x == m_lines[m_selEnd.y].getSize())
                            {
                                if ((m_selEnd.y + 1) < m_lines.size())
                                {
                                    m_selEnd.y++;
                                    m_selEnd.x = 0;
                                }
                                else
                                {
                                    done = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            if (m_selEnd.x == m_lines[m_selEnd.y].getSize())
                            {
                                m_selEnd.y--;
                                m_selEnd.x = m_lines[m_selEnd.y].getSize();
                            }
                            break;
                        }
                    }
                }
            }
            else // No double clicking
...
#9
Yes. It works good now)

Now I tried to make a selection the word by double clicking, based on your LeftKey and RightKey events (because I really better to select words that exceed the length of the line). But to be honest, I confused them.
There is a problem: if the caret is at the beginning of the word, it captures the word on the left too. If the cursor at the beginning of the line (i.e. when x = 0), it selects all the text before (from {0, 0} to word). And with the right button is nearly the same, but to the opposite side (to {0, linesize}).
To select a word by double-clicking "skippedWhitespace" bother me enough. :o Maybe it doesn't need to do this?
There is almost nothing has changed, except for an additional variable m_selClicked, and changes in the first part to m_selStart

Code (cpp) Select
            // Check if this is a double click
            if ((m_possibleDoubleClick) && (m_selStart == m_selEnd) && (caretPosition == m_selEnd))
            {
                // The next click is going to be a normal one again
                m_possibleDoubleClick = false;
               
                if( m_lines[m_selStart.y][m_selStart.x] == ' ' )
                {
                    // Select the space
                    m_selEnd.x = m_selStart.x + 1;
                }
                else
                {
                    // Select the word
                    sf::Vector2<std::size_t> m_selClicked = m_selStart;
                   
                    // Move to the beginning of the word
                    bool skippedWhitespace = false;
                    bool done = false;
                    for (unsigned int j = m_selClicked.y + 1; j > 0; --j)
                    {
                        for (unsigned int i = m_selClicked.x; i > 0; --i)
                        {
                            if (skippedWhitespace)
                            {
                                if (isWhitespace(m_lines[m_selStart.y][i-1]))
                                {
                                    m_selStart.x = i;
                                    done = true;
                                    break;
                                }
                            }
                            else
                            {
                                if (!isWhitespace(m_lines[m_selStart.y][i-1]))
                                    skippedWhitespace = true;
                            }
                        }

                        if (!done)
                        {
                            if (m_selStart.y > 0)
                            {
                                m_selStart.y--;
                                if (!m_lines[m_selStart.y].isEmpty() && m_lines[m_selStart.y][m_lines[m_selStart.y].getSize()-1] == '\n')
                                {
                                    if (!skippedWhitespace)
                                        m_selStart.x = m_lines[m_selStart.y].getSize()-1;
                                    else
                                    {
                                        m_selStart.x = 0;
                                        m_selStart.y++;
                                        break;
                                    }
                                }
                                else
                                    m_selStart.x = m_lines[m_selStart.y].getSize();
                            }
                            else
                            {
                                m_selStart.x = 0;
                                m_selStart.y = 0;
                            }
                        }
                        else
                            break;
                    }
                   
                    // Move to the end of the word
                    skippedWhitespace = false;
                    done = false;
                    for (unsigned int j = m_selClicked.y; j < m_lines.size(); ++j)
                    {
                        for (unsigned int i = m_selClicked.x; i < m_lines[m_selEnd.y].getSize(); ++i)
                        {
                            if (skippedWhitespace)
                            {
                                if (isWhitespace(m_lines[m_selEnd.y][i]))
                                {
                                    m_selEnd.x = i;
                                    done = true;
                                    break;
                                }
                            }
                            else
                            {
                                if (!isWhitespace(m_lines[m_selEnd.y][i]))
                                    skippedWhitespace = true;
                            }
                        }

                        if (!done)
                        {
                            if (!skippedWhitespace)
                            {
                                if (m_selEnd.y+1 < m_lines.size())
                                {
                                    m_selEnd.y++;
                                    m_selEnd.x = 0;
                                }
                            }
                            else
                            {
                                if (!m_lines[m_selEnd.y].isEmpty() && (m_lines[m_selEnd.y][m_lines[m_selEnd.y].getSize()-1] == '\n'))
                                    m_selEnd.x = m_lines[m_selEnd.y].getSize() - 1;
                                else
                                    m_selEnd.x = m_lines[m_selEnd.y].getSize();
                            }
                        }
                        else
                            break;
                    }
                }
            }...
#10
I like when people can rest a bit) Especially those who do a lot for other people ;)
I'm still on vacation too, but next week go out to work) and I think I will not worry so much, but who knows me :)
I pester often, because I'm not even a programmer (hardly at least), I'm more a designer-artist-writer, even though I'm an accountant by profession ;D

And I am very sorry, because I want a bit spoil the rest ::)
With the "jumping line" it works fine now) Big thanks for code! And with the PageUp there is no problem now as I see, but now there are PageDown seriously disappointed me. :-[

But I think I've understood what the problem is:
if the TextBox never contained more lines than TextBox size, the PageDown will try to move to a non-existent line.

I attached a video where it's better to be seen than I will explain (at the beginning of the video, tested where was a lot of lines of text; at the end of the video - where the text is never typed - and it causes crash)
#11
I'm surprised such work speed)) It's pretty much all that I needed.

* PageUp now works fine (as long as the problems are not seen, and the application does not throw)
* The Control behavior is now very competent (ends of words are taken into account, depending on the "caret movement" direction; and it seems the word that exceed the size of the line, fully selects; and Control key while pressing Shift now allows to select a word from a neighboring line)

Now it's more comfortable to edit text  :D

It remains an issues with: "jumping-joining next line", when Shift-selection (at the end of line) takes place without Control key; and with DoubleClick behaviour.
I'm still trying to fix double-click, but so far I have many distractions :o

Thanks a lot, texus. It's invaluable help)
#12
QuoteIs there an editor that works like that or is this just a side-effect of the code? The text editor that I use (gedit) selects the whitespace itself when the cursor is on the left of the space or between multiple spaces.
Agree. I use Notepad++ and it's selects spaces too. Like many editors as I see.
Honestly I thought that select the spaces never need, but only words. But I was wrong (and didn't think properly). In some cases it needs of course. It's better to stick to general practice and select the spaces itself. There is no doubt.

Quotewarnings on lines 504 and 722
Oops, I overlooked. Hasty. Remainders from the past variants. "==" meant.

Quote... somewhere in the middle together.
Overlooked too :) Thanks

QuoteI'll see if I can fix those things.
I will be very grateful. Also I will look for bugs, but at times for some things I lack logical vision.

#13
I did something, but a pair of things with bugs (details below).
From my list of the first post I implemented the following (maybe I don't know about any potential problems, but so far I didn't notice a lot of bugs at work. Only a pair as I said):


  • Pressed Shift (yes) (*old bug with the '\n' and RightKey I suppose, only at the end of the current line, and it's buggy only with Shift selecting, details below)
  • Pressed Control (yes)
  • Double-click (yes)
  • Home (yes)
  • End (yes)
  • Ctrl+Home (yes)
  • Ctrl+End (yes)
  • PageUp (yes) (*may be bug again with the Shift-selection, in special situations my app throws, I think problem not with the PageUp key, but with the Shift. I didn't even know at what point might throw, but I'll try to understand)
  • PageDown (yes)

Easier to see the code.

All problems abut to the return from the current line to the next. All that is needed is to miss the symbol '\n' wherever it appears on the way of 'm_selEnd'.
The bug algorithm that I saw (now when Shift pressed):
>> Cursor at the end of a paragraph
>> Pressing the right arrow
>> The cursor moves to the beginning of the NEXT line (it's ok), but the NEXT line moves to the end of the CURRENT line! The CURRENT and NEXT line are joined now when '\n' selected! :o  :o  :o
>> Pressing the right arrow again
>> Now the cursor is moved to the second character of the next line, and the next line gets to its rightful place)

In the source TextBox.cpp:

1) in the "leftMousePressed" function only the following lines was replaced with new word-selection code:

// Select the whole text
m_selStart = {0, 0};
m_selEnd = sf::Vector2<std::size_t>(m_lines[m_lines.size()-1].getSize(), _lines.size()-1);


2) in the "keyPressed" function:

case sf::Keyboard::Up: (nearly all corrected)
case sf::Keyboard::Down: (nearly all corrected)
case sf::Keyboard::Left: (nearly all corrected)
case sf::Keyboard::Right: (nearly all corrected) (*but here lies the bug with selection of '\n')
case sf::Keyboard::Home: (nearly all corrected)
case sf::Keyboard::End: (nearly all corrected)
case sf::Keyboard::PageUp: (added)
case sf::Keyboard::PageDown: (added)


3) When I corrected I questioned the need for the following code:

if (m_selStart != m_selEnd)
{
if ((m_selStart.y > m_selEnd.y) || ((m_selStart.y == m_selEnd.y) && (m_selStart.x > m_selEnd.x)))
m_selStart = m_selEnd;
else
m_selEnd = m_selStart;
}
...


because the selection is still lost in the end of the keys' method execution. In any case, I haven't noticed significant differences. In my case, all selection-deselection problems decided a simple condition:

if (!event.key.shift) m_selStart = m_selEnd;

But may be I'm wrong.

Summary:
The bug with the Union "Shift-selection + jumping next line" is tolerable because app isn't throws.
But the bug with the Union "Shift-selection + PageUp" very unstable, it's seriously, than the jumping line.
I will still think with it.
#14
Understood. Excellent! One terminated))
Thanks. Now I'll try to be useful with other questions, if I can. With some success I'll keep up to post.
#15
Big thanks for useful brief) I'll try it, but not sure that it will be soon (for me it may be long). But I'll try certainly, and if it will be some productive, I'll send my results.

With the no-return problem I tested a little more, and I can add a few words about the strange signs in the behavior of the caret:
1) It only happens at the end of a paragraph (I think, where the returning is going to take place... and yes, I forgot to say that I'm still working and compile on Win7. My first thoughts about the problem with a difference return characters like "\r\n" on Windows, but maybe I'm wrong)
2) I'll describe a little easier the bug algorithm that I saw:
* Cursor at the end of a paragraph
* Pressing the right arrow
* The cursor moves to the beginning of the CURRENT line
* Pressing the right arrow again
* Now the cursor moves to the NEXT line

Of course, the code is already big, so I will show clippings where my textbox is used (I think everything is pretty trivial):

in Layout.h

class Layout
{
private:
// ...
tgui::TextBox::Ptr mainTextBox;
// ...
};


in Layout.cpp
// ...
extern sf::RenderWindow window;
extern tgui::Gui gui;
// ...

Layout::Layout(unsigned _scr_w, unsigned _scr_h)
{
// ...
mainTextBox = tgui::TextBox::create(path_guiconf);
mainTextBox->setTextSize(text_size);
gui.add(mainTextBox);
// ...
}

void Layout::UpdateSizes(unsigned _scr_w, unsigned _scr_h)
{
// ...
mainTextBox->setPosition(col_text_pos, row1_pos_top + button_height*2.0f + spacing_border*2.0f);
mainTextBox->setSize(col_text_width, scr_h - button_height*3.0f - spacing_border*5.0f);
// ...
}

void Layout::Update()
{
if( win_mode == MODAL ){
mainTextBox->disable();
// ...
}else{
mainTextBox->enable();
// ...
}
}

void Layout::SceneLoad()
{
// ...
mainTextBox->setText( project[proj_pos-1].SceneGetText(item_pos) );
// ...
}

void Layout::SceneSave()
{
// ...
sf::String tstr( mainTextBox->getText() );
// ...
}


Actually my app quite raw, and some bug with the textbox already had, which was associated with the continuous sizes updating. Due to the continuous use of the resize command, a scroll bar did not give to see the text, if the view range of the textbox was without caret. It was necessary first to move the caret closer to opposite side (top or bottom), then use the scroll bar again (by mouse I mean). I corrected that visual bug when started to use resize-command only when window-resize-event happens, not every frame. It was my stupid mistake. And I wouldn't surprise it may be again) Though... all size bugs already fixed %) And moreover, this problem occurs in any created textbox (without any resize, and even inside the child windows)... I did not leave think about "\r\n" on Windows OS.