1
SFML projects / Re: New RichText class
« on: April 18, 2020, 09:38:29 pm »
Great class Mr. Roque. Its amazing what you have done. Only problem is text wrapping.
I am actually observing your code, editing the style, using newer cpp constructs like for each loop and such. Removing unneeded if statements, compacting the code, and compiling along the way to ensure it is the same results. All with the aim to add text wrapping.
Note that SFML should do better. It is nearly version 3 and they still havent added text wrapping and rich text directly in the library. They should look at the android graphics api, TextView, ListView, and such. These are regularly used ui constructs!
I am here on my Windows XP, no graphics acceleration, and finding it hard to write a simple ui. I am working like 4, 5 days and cant pass the ui stage. A ChessBoard, with pieces, movable, with 2 Text Box Fields.
Started using GDI, studied it in one day, then another day to devise a design structure for it. Then came to a dead end, when I ready to add the pieces, which NEED transparency.
So I began studying OpenGL. OpenGL and DirectX I studied in the past but failed to create any app with them. Now studying it again I was once again overwhelmed! Managed to set up the Context. Studying GDI elevater my understanding. But all I did was draw a rectangle and make it spin. I realized immediately I would have problems loading textures{chessboard, chesspieces}, and Object orient them like what I did with GDI; by giving each object a mem_ctx; Worse of all, OpenGl and GDI werent compatible, unless I want SlowGL. And how to render text with OpenGL?? 1.1 ?
I had to say later to OpenGL and reconsider GDI+ which I read was slow. After all DirectWrite and stuff is vista and up. I was staying away from SFML because I mastered it already. I created a draugh game and Chess game with it already. I wanted to grow my knowledge to the lowerlevels of graphics. I tried GDI+. Surprisely I never used it before in the past. I was gravitated by the advertisement of it on MSDN. Even though the documentation of it is well less than GDI, it was breath taking. They told you how much it has improved and improved and improved over GDI. When I checked it out, my heart sank. It literally tooks SECONDS for GDI+ to draw 8 Chess pieces. It really should be called GDI-; Why it has to be software implemented I dont know! But it is TOTALLY UNUSABLE on my machine.
So, out of desperation, I had to use SFML; my old friend. The one that taught me graphics programming. SFML 2.5.1.
It took me some time to install it. Only sfml as a library, tells you to give the linker symbolic names. sfml-graphics. There is no lib file called that. But now I know I can bypass setting lib directory, and simply selected the real lib file! Or I can do it how SFML says. either way.
But my real problem with SFML is the dll. What is the purposed of shared libraries if you cant share them! Why must I recopy those file into every app directory? They should be located from a centralized path, that one file can be shared. And finding and copying the files is simply troublesome. Especially when Sfml asks for dll not created by sfml. such as libgcc.
Anyhow, I finally got sfml working. Begin creating my drawables. Then another dead end. SFML does not do textwrapping. This is stupid! Performance wise, it best sfml does the drawing and wraps text in the iterations. Rather than have us use calculateCharacterPos which I am sure does an iteration on every call. Also sfml doesnt support editable text. Again take a page from Android! Lucking they provide a const sf::String& which is safely casted to non const.
Great. I can wrap text now. Then when I look at my use and the text looks bland. If only I could draw red text and then white text. Then it came to my realization that this wasnt going to be my easy moment. I thought about it and found nothing good.
So I tried back GDI as it is compatible with SFML. DrawText does textwrapping, but no rich text. GetTextExtentExPoint32 promised to give me measurements but was very cumbersome! TextOut can do rich yext but no text wrapping. And I could maths out how to do my everythinh any of these graphics engines.
To do rich text in a console app is very easier. For example, syntax highlighting. Why is the real graphics engines not allowing me this ease. And again, I am no where near learning to draw text with OpenGL.
Luckily I found a library on the internet that Roque metioned. Unfortunately I never got it to work. And it is not very very rich rich text. for example, he was exploding texts into Lines. So a line can only be in one color. Not enough for syntax highlighting or my needs. But I loved how he used the stream operator to stream in the state of the text and stuff.
Needless to say, I couldnt implement his idea. So I searched again and saw Roque's library. and got it working. And it was more beautiful than the illustration on the Net.
Thank you Roque. But SFML needs to do better! They should implement a TextBox, with text wrapping and rich text abilities. It makes no sense I am creating 50 sf::Text to display one string.
I am actually observing your code, editing the style, using newer cpp constructs like for each loop and such. Removing unneeded if statements, compacting the code, and compiling along the way to ensure it is the same results. All with the aim to add text wrapping.
Note that SFML should do better. It is nearly version 3 and they still havent added text wrapping and rich text directly in the library. They should look at the android graphics api, TextView, ListView, and such. These are regularly used ui constructs!
I am here on my Windows XP, no graphics acceleration, and finding it hard to write a simple ui. I am working like 4, 5 days and cant pass the ui stage. A ChessBoard, with pieces, movable, with 2 Text Box Fields.
Started using GDI, studied it in one day, then another day to devise a design structure for it. Then came to a dead end, when I ready to add the pieces, which NEED transparency.
So I began studying OpenGL. OpenGL and DirectX I studied in the past but failed to create any app with them. Now studying it again I was once again overwhelmed! Managed to set up the Context. Studying GDI elevater my understanding. But all I did was draw a rectangle and make it spin. I realized immediately I would have problems loading textures{chessboard, chesspieces}, and Object orient them like what I did with GDI; by giving each object a mem_ctx; Worse of all, OpenGl and GDI werent compatible, unless I want SlowGL. And how to render text with OpenGL?? 1.1 ?
I had to say later to OpenGL and reconsider GDI+ which I read was slow. After all DirectWrite and stuff is vista and up. I was staying away from SFML because I mastered it already. I created a draugh game and Chess game with it already. I wanted to grow my knowledge to the lowerlevels of graphics. I tried GDI+. Surprisely I never used it before in the past. I was gravitated by the advertisement of it on MSDN. Even though the documentation of it is well less than GDI, it was breath taking. They told you how much it has improved and improved and improved over GDI. When I checked it out, my heart sank. It literally tooks SECONDS for GDI+ to draw 8 Chess pieces. It really should be called GDI-; Why it has to be software implemented I dont know! But it is TOTALLY UNUSABLE on my machine.
So, out of desperation, I had to use SFML; my old friend. The one that taught me graphics programming. SFML 2.5.1.
It took me some time to install it. Only sfml as a library, tells you to give the linker symbolic names. sfml-graphics. There is no lib file called that. But now I know I can bypass setting lib directory, and simply selected the real lib file! Or I can do it how SFML says. either way.
But my real problem with SFML is the dll. What is the purposed of shared libraries if you cant share them! Why must I recopy those file into every app directory? They should be located from a centralized path, that one file can be shared. And finding and copying the files is simply troublesome. Especially when Sfml asks for dll not created by sfml. such as libgcc.
Anyhow, I finally got sfml working. Begin creating my drawables. Then another dead end. SFML does not do textwrapping. This is stupid! Performance wise, it best sfml does the drawing and wraps text in the iterations. Rather than have us use calculateCharacterPos which I am sure does an iteration on every call. Also sfml doesnt support editable text. Again take a page from Android! Lucking they provide a const sf::String& which is safely casted to non const.
Great. I can wrap text now. Then when I look at my use and the text looks bland. If only I could draw red text and then white text. Then it came to my realization that this wasnt going to be my easy moment. I thought about it and found nothing good.
So I tried back GDI as it is compatible with SFML. DrawText does textwrapping, but no rich text. GetTextExtentExPoint32 promised to give me measurements but was very cumbersome! TextOut can do rich yext but no text wrapping. And I could maths out how to do my everythinh any of these graphics engines.
To do rich text in a console app is very easier. For example, syntax highlighting. Why is the real graphics engines not allowing me this ease. And again, I am no where near learning to draw text with OpenGL.
Luckily I found a library on the internet that Roque metioned. Unfortunately I never got it to work. And it is not very very rich rich text. for example, he was exploding texts into Lines. So a line can only be in one color. Not enough for syntax highlighting or my needs. But I loved how he used the stream operator to stream in the state of the text and stuff.
Needless to say, I couldnt implement his idea. So I searched again and saw Roque's library. and got it working. And it was more beautiful than the illustration on the Net.
Thank you Roque. But SFML needs to do better! They should implement a TextBox, with text wrapping and rich text abilities. It makes no sense I am creating 50 sf::Text to display one string.