SFML community forums

General => SFML projects => Topic started by: forrestcupp on August 07, 2009, 07:46:26 pm

Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on August 07, 2009, 07:46:26 pm
I was working on some GUI stuff to use in my SFML projects, and it ended up turning into a decent object oriented GUI toolkit.  It's object oriented, and extremely easy to use.  

I figured it might be useful to people, so I'm going to release it under the zlib/libpng license like SFML.  It is called cpGUI, and it's based on SFML version 1.5.

It includes the following controls:
* Normal highlightable Buttons with a text label
* Image Buttons that are based on an sf::Image
* Shape Buttons that take an sf::Shape and turn it into a clickable button
* Check Boxes
* Selection Boxes with the ability to add choices.  It uses a scroll bar when necessary
* Drop Down Boxes with the ability to add choices and set maximum depth. A scroll bar is used when you reach your maximum depth.
* Text Input Boxes - a one line box for inputting text.  It has a blinking caret, but it is non-editable
* Text Boxes for loading a simple text file and displaying it.  The Text Box will automatically word wrap the text according to the size of the box you create.  This is useful for displaying instructions or licensing info. Text Boxes are non-editable and read only.
* A GuiContainer class that contains all of your objects - used for setting focus, and also some other things under the hood.

Almost all of the work is done for you, and it is very simple to use.  In most of the controls, you can easily customize the colors, fonts, size, & position.  Each object can return its state and tell you if the mouse enters or exits the control, and can tell you if the button was clicked or if it's down.

If anyone is interested, I can upload it and put it in the wiki when I have time.  I'll post a screen shot that includes all of the available controls.  If I post the files in the wiki, I'll include the example code for the screen shot with lots of comments explaining how to use cpGUI.

Update:
I have added a built-in font manager to help save on resources. Now, rather than having a separate font for each object, new fonts are only loaded when necessary. Also, when a font is no longer used by any object, it is automatically deleted. Other than cpGUI's default font, you will never have an unused font in memory.

This is all automatic, and it doesn't change how cpGUI is used.

Thanks to “Meltra Bour” for pointing out the need on the forums. Thanks to “l0calh05t” & “Wavesonics” for helping me learn how to implement this.

**Major Update** - 9/28/9

See this post (http://www.sfml-dev.org/forum/viewtopic.php?p=10961#10961) for details.  Includes functions for setting mouseover color, bug fixes, and separate files to include only the controls you need for your project.

**Update** - 9/29/09

See this post (http://www.sfml-dev.org/forum/viewtopic.php?p=10992#10992) for details.  Update includes various tweaks, bug fixes, and now cpGUI has static libraries.


You can download the latest update in the Projects section of the Wiki. (http://www.sfml-dev.org/wiki/en/projects/cpgui)


(http://img24.imageshack.us/img24/4373/cpguiscreenshot.jpg)
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Lokk on August 07, 2009, 09:05:38 pm
Great job =)
Quote
If anyone is interested, I can upload it and put it in the wiki when I have time. I'll post a screen shot that includes all of the available controls. If I post the files in the wiki, I'll include the example code for the screen shot with lots of comments explaining how to use cpGUI.

Sounds good !
(Well, I am more interested in your source code... I am working on a gui here (http://code.google.com/p/sfui/) if you want to see it... )
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on August 08, 2009, 06:44:18 pm
Sorry to preempt you.  I guess it's always good for people to have choices.  It's also good to have different license choices, since you're using GPLv3 and I'm using zlib/libpng license.

Anyway, I got a wiki page up under the English Projects section.  You can find my wiki page here (http://www.sfml-dev.org/wiki/en/projects/cpgui), and you can download the code from that page.  It's in a zip file.


Edit:
I've updated my code to put everything in a namespace called cp.  I also fixed a small bug with the drop down box.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Meltra Bour on August 09, 2009, 08:18:25 am
Thx to both, was fun reading true the code, gui elements like those where somewhere on my todo list this puched it right up to the top. I have never been a fan of xml files so I'm glad to see the right lib with the right license. so thx for the time saver and thx for the learning xp lokk ...

I'l be integrating the code in to our little engine over the coming week so I'l keep you posted on how it works out 8)
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Meltra Bour on August 10, 2009, 08:38:21 am
First small steps, I'm a bit of a c++ newby but ...

The thing I was missing was a font manager, it seems you create a new instance of sf::Font for every object in the gui. It feels like this is a bit of a waist on resources, using a manager to spread one instance over several objects would speed up loading and reduce memory usage. Or is my newby mind playing trick on me ?
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Auron on August 10, 2009, 09:30:05 pm
Looks nice, it will be great to see when its released.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on August 10, 2009, 11:53:42 pm
Quote from: "Meltra Bour"
First small steps, I'm a bit of a c++ newby but ...

The thing I was missing was a font manager, it seems you create a new instance of sf::Font for every object in the gui. It feels like this is a bit of a waist on resources, using a manager to spread one instance over several objects would speed up loading and reduce memory usage. Or is my newby mind playing trick on me ?
I'll have to consider how to do that without losing the ability to have different fonts for different objects.  I could probably figure out a way to do it through the cpGuiContainer.

That is a good point, though.

Quote from: "Auron"
Looks nice, it will be great to see when its released.
Are you talking about mine, which was the original post, or Lokk's?  If you're talking about mine, it's in the wiki in the project section.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on August 11, 2009, 12:23:22 am
I'm thinking about the font problem mentioned earlier, and here's the problem.  SFML currently doesn't properly resize fonts.  If you have a font that was loaded at a size of 12 and resize it to 20, it's still has the same pixels it had as 12 but is blown up to be the size of 20.  Because of that, it doesn't look so great sometimes.  Even starting at a high size and lowering the size leaves nasty artifacts.

So in my code, I opted for quality by actually reloading the font at the new size when the user calls the SetFontSize() function.  The thing is, people are going to at least want different font sizes for different things like text boxes, selection boxes or buttons, even if they're using the default font.  If I have a central font, and the user wants to resize one thing, they will all be resized as a result of my method of doing things for quality sake.

So it seems that every time someone wants an object with a different font size, I would have to load a different font into a font manager.  I can't really see how that would be any better on resources than each object having its own font, unless I were to reprogram the entire way that SFML works with fonts.  I'm definitely not going to do that because my wife is having a baby next week, and it's not really my job anyway to do that.

So, does anyone have any solutions of an easier way to handle this problem?  Is it a big enough problem to even open a can of worms like this?  I'm open to suggestions here.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: l0calh05t on August 11, 2009, 12:47:36 am
Quote from: "forrestcupp"
So, does anyone have any solutions of an easier way to handle this problem?  Is it a big enough problem to even open a can of worms like this?  I'm open to suggestions here.


You could have a look at my resource manager ( http://www.sfml-dev.org/wiki/en/sources/resource_manager_l0calh05t ), it includes a sf::Font example. This would prevent reloading of the fonts as long as different elements use the same font size (so 8 buttons with font size 20 will share one font)
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Auron on August 11, 2009, 01:28:53 am
I don't which project I was talking about, but the GUI thing looks really nice.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on August 11, 2009, 01:59:07 am
Quote from: "l0calh05t"
Quote from: "forrestcupp"
So, does anyone have any solutions of an easier way to handle this problem?  Is it a big enough problem to even open a can of worms like this?  I'm open to suggestions here.


You could have a look at my resource manager ( http://www.sfml-dev.org/wiki/en/sources/resource_manager_l0calh05t ), it includes a sf::Font example. This would prevent reloading of the fonts as long as different elements use the same font size (so 8 buttons with font size 20 will share one font)
What would happen if you called ReleaseUnusedResources() from inside the event loop instead of directly after?  

I'm trying to visualize a way to incorporate something like this without the user of cpGUI even having to know about its workings.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: redkiing on August 11, 2009, 02:22:55 am
Hi forrestcupp,
Nice work!! I think you're gui toolkit is really easy to use, and the included controls are indeed very useful.
However, I don't like that when you resize the window, the gui objects used by the toolkit don't work anymore. They keep using the old coords, so when you try clicking one button when the window has been resized, nothing happens...

I've navigated through your code and I modified the required functions to make it work.

I've create a Vect2f object called mousePos using the new coords with this little line of code in every place you verify the mouse coords:

Code: [Select]
sf::Vector2f mousePos = Parent->ConvertCoords(input->GetMouseX(), input->GetMouseY());

So, Instead of using
Code: [Select]
input->GetMouseX()
input->GetMouseY()

I use :
Code: [Select]
mousePos.x
mousePos.y

For instance, this function:
Code: [Select]
/// Checks to see if mouse pointer is inside control.  Returns true if it is.
bool cpObject::CheckMouseEntered(const sf::Input *input)
{
return (input->GetMouseX() >= PosX && input->GetMouseX() <= PosX+Width &&
input->GetMouseY() >= PosY && input->GetMouseY() <= PosY+Height);
}

translates into:
Code: [Select]
/// Checks to see if mouse pointer is inside control.  Returns true if it is.
bool cpObject::CheckMouseEntered(const sf::Input *input)
{
    sf::Vector2f mousePos = Parent->ConvertCoords(input->GetMouseX(), input->GetMouseY());
return (mousePos.x >= PosX && mousePos.x <= PosX+Width &&
        mousePos.y >= PosY && mousePos.y <= PosY+Height);
}

Hope it helps.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: l0calh05t on August 11, 2009, 08:39:56 am
Quote from: "forrestcupp"
What would happen if you called ReleaseUnusedResources() from inside the event loop instead of directly after?


Shouldn't make much of a difference, as most of the time there'll only be one event waiting anyways. If there are more you'll waste a bit of processing time be rescanning the map.

Quote
I'm trying to visualize a way to incorporate something like this without the user of cpGUI even having to know about its workings.


Well, you could of course modify the resource manager to discard anything the moment it goes out of use by storing boost::weak_pointers in the map instead of boost::shared_pointers (would only require an extra check in the GetResource function, because a resource in the map doesn't have to mean it's still loaded anymore)

EDIT:

Here's an (untested) modified version:
Code: [Select]

template<typename T>
class ResourceManager {
public:
typedef boost::shared_ptr<T> Resource;
typedef boost::weak_ptr<T> WeakResource;
typedef std::map<std::string, WeakResource> ResourceMap;
 
// Gets the resource described by the locator and loads it if it hasn't been loaded yet
Resource GetResource(const std::string& locator)
{
boost::mutex::scoped_lock lock(resource_mutex);
 
Resource loaded;
ResourceMap::iterator it = resources.find(locator);
if(it == resources.end()) // not loaded yet, load now
{
loaded = LoadResource(locator);
if(loaded)
it = resources.insert(std::make_pair(locator, loaded)).first;
else
throw std::runtime_error("Resource " + locator + " could not be loaded");
}
else
{
loaded = it->second.lock();
if(!loaded)
{
loaded = LoadResource(locator);
if(loaded)
it->second = loaded;
else
throw std::runtime_error("Resource " + locator + " could not be loaded");
}
}
 
return loaded;
}
 
protected:
// must be implemented for the corresponding resource type
virtual Resource LoadResource(const std::string& locator) = 0;
 
private:
ResourceMap resources;
boost::mutex resource_mutex;
};
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on August 11, 2009, 02:17:38 pm
Quote from: "redkiing"
Hi forrestcupp,
Nice work!! I think you're gui toolkit is really easy to use, and the included controls are indeed very useful.
However, I don't like that when you resize the window, the gui objects used by the toolkit don't work anymore. They keep using the old coords, so when you try clicking one button when the window has been resized, nothing happens...

I've navigated through your code and I modified the required functions to make it work.
Sweet!  Thank you!

I didn't even think about that because I'm going to be mostly using full screen.  Also, I'm used to wxWidgets not automatically resizing everything for you.  I'll update it when I get a chance and get it posted.  Thanks again.

Quote from: "l0calh05t"

Well, you could of course modify the resource manager to discard anything the moment it goes out of use by storing boost::weak_pointers in the map instead of boost::shared_pointers (would only require an extra check in the GetResource function, because a resource in the map doesn't have to mean it's still loaded anymore)
I know what I'm about to ask is probably remedial.  

I have a class called cpGuiContainer that takes care of some global GUI stuff.  Do you think I could just make an std::vector of sf::Fonts in my cpGuiContainer class.  It will always have my default font, and when someone loads a new font, it will be loaded into this vector if it's not already there.  Through my GuiContainer, I can keep track of what object uses which font, and only have one instance per font/fontsize.  Then when an object changes fonts/fontsizes, at that time cpGuiContainer can load the new one if necessary, and purge the vector of any unused fonts.  That way, it only happens when the user changes a font.  If I did that, instead of having each object create an instance to a font, the objects would be using a pointer to a font that is in cpGuiContainer's vector.

If that could work, it may be a more personalized way for me to do it.  What do you think?
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: l0calh05t on August 11, 2009, 03:49:08 pm
Quote from: "forrestcupp"
I know what I'm about to ask is probably remedial.  

I have a class called cpGuiContainer that takes care of some global GUI stuff.  Do you think I could just make an std::vector of sf::Fonts in my cpGuiContainer class.  It will always have my default font, and when someone loads a new font, it will be loaded into this vector if it's not already there.  Through my GuiContainer, I can keep track of what object uses which font, and only have one instance per font/fontsize.  Then when an object changes fonts/fontsizes, at that time cpGuiContainer can load the new one if necessary, and purge the vector of any unused fonts.  That way, it only happens when the user changes a font.  If I did that, instead of having each object create an instance to a font, the objects would be using a pointer to a font that is in cpGuiContainer's vector.

If that could work, it may be a more personalized way for me to do it.  What do you think?


Of course you could do it that way, but a vector is a bad choice for this because:

1. Searching for a specific font+size will be O(n), compared to O(log(n)) for a map
2. Removing an element that is not at the end involves copying large parts of the vector

also you'll have to do your own reference counting.

Why not use a manager like mine as a member of cpGuiContainer, and get your fonts from there? This would be invisible to the user. (It will add dependencies to boost::thread and boost::smart_ptr though... if you can get away with no thread safety, you might remove the lock/mutex and boost::smart_ptr only requires a few headers)
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on August 11, 2009, 08:04:20 pm
Quote from: "l0calh05t"

Why not use a manager like mine as a member of cpGuiContainer, and get your fonts from there? This would be invisible to the user. (It will add dependencies to boost::thread and boost::smart_ptr though... if you can get away with no thread safety, you might remove the lock/mutex and boost::smart_ptr only requires a few headers)
It might be a little while before I have time to look through the code and figure out how to fit it in.  

If I can work it out, is it ok for me to use your code?  If so, what would be the proper protocol for doing that?  I'm new at working with free licenses, and it looks like your license's terminology is slightly different than the zlib/libpng license I used.  I don't know how it works to mix code with different licenses and the best way to direct the credit where it is due.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: l0calh05t on August 11, 2009, 08:28:09 pm
Quote from: "forrestcupp"
It might be a little while before I have time to look through the code and figure out how to fit it in.  

If I can work it out, is it ok for me to use your code?  If so, what would be the proper protocol for doing that?  I'm new at working with free licenses, and it looks like your license's terminology is slightly different than the zlib/libpng license I used.  I don't know how it works to mix code with different licenses and the best way to direct the credit where it is due.


Since you mentioned the license... I just noticed that I didn't replace all the <> tags... Anyways... it's just your basic 3-clause BSD license which means, yes, you can use the code, but the copyright holder (me) has to be mentioned and the license in the documentation (or otherwise visibly included with the program). Furthermore you may not use my name in any advertising without my permission.
As far as I understand, you could use my code in your project and redistribute it, as long as you point out that parts of the code (and which parts) are licensed under a different license. (But I am no Lawyer)
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on August 11, 2009, 08:42:27 pm
Quote from: "l0calh05t"
Quote from: "forrestcupp"
It might be a little while before I have time to look through the code and figure out how to fit it in.  

If I can work it out, is it ok for me to use your code?  If so, what would be the proper protocol for doing that?  I'm new at working with free licenses, and it looks like your license's terminology is slightly different than the zlib/libpng license I used.  I don't know how it works to mix code with different licenses and the best way to direct the credit where it is due.


Since you mentioned the license... I just noticed that I didn't replace all the <> tags... Anyways... it's just your basic 3-clause BSD license which means, yes, you can use the code, but the copyright holder (me) has to be mentioned and the license in the documentation (or otherwise visibly included with the program). Furthermore you may not use my name in any advertising without my permission.
As far as I understand, you could use my code in your project and redistribute it, as long as you point out that parts of the code (and which parts) are licensed under a different license. (But I am no Lawyer)
As far as you understand, would it satisfy the requirements for me to just leave your license in the comments above your code just like you have it?  Of course, I would also give you credit in the wiki.

I need to take the time to make sure I can get it to work, first, though.  Thanks a lot for your assistance.


Edit:
I have updated my code with redkiing's fix for resizing the windows.  That fix is posted to the wiki now.  Thank you redkiing.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on August 11, 2009, 09:27:52 pm
Quote from: "l0calh05t"
Quote from: "forrestcupp"
So, does anyone have any solutions of an easier way to handle this problem?  Is it a big enough problem to even open a can of worms like this?  I'm open to suggestions here.


You could have a look at my resource manager ( http://www.sfml-dev.org/wiki/en/sources/resource_manager_l0calh05t ), it includes a sf::Font example. This would prevent reloading of the fonts as long as different elements use the same font size (so 8 buttons with font size 20 will share one font)
The main problem I'm seeing as I look through your code is that if someone doesn't have the boost libraries installed, it will render the whole thing useless.  I'd kind of hate to put that requirement on it.  It's definitely giving me stuff to think about, though.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: l0calh05t on August 11, 2009, 10:33:38 pm
Quote from: "forrestcupp"
As far as you understand, would it satisfy the requirements for me to just leave your license in the comments above your code just like you have it?  Of course, I would also give you credit in the wiki.


If the distribution is in source code form, yeah, sure.

Quote
The main problem I'm seeing as I look through your code is that if someone doesn't have the boost libraries installed, it will render the whole thing useless. I'd kind of hate to put that requirement on it. It's definitely giving me stuff to think about, though.


Every C++ programmer should have the boost libraries installed :P You could obviously replace the shared/weak pointers by a different implementation, but in general the boost ones are very reliable (which is why I chose them)
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on August 11, 2009, 10:47:51 pm
You've helped me a lot by pointing me towards the benefits of maps over vectors.  That helps me a lot.

I think by learning from your code and also Wavesonics resource manager, I can come up with something customized that will fit well in my project.

Thank you for your help.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on August 13, 2009, 05:30:16 pm
I have added a built-in font manager to help save on resources. Now, rather than having a separate font for each object, new fonts are only loaded when necessary. Also, when a font is no longer used by any object, it is automatically deleted. Other than cpGUI's default font, you will never have an unused font in memory.

This is all automatic, and it doesn't change how cpGUI is used.

Thanks to “Meltra Bour” for pointing out the need on the forums. Thanks to “l0calh05t” & “Wavesonics” for helping me learn how to implement this.

There were also other minor bug fixes in this update.  You can download the update in the Projects section of the Wiki.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Meltra Bour on August 13, 2009, 07:56:44 pm
Nicely done, its looking relay nice now. To bad I was told to stay away from sf::string and the likes. :roll:
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on August 13, 2009, 09:57:48 pm
Ha, ha.  Well, you can just stay away from sf::String in everything you do except cpGUI.  I don't think I'll be changing that anytime soon.  It really shouldn't affect anything else you do.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: l0calh05t on August 14, 2009, 02:55:56 pm
sf::String could definitely use some improvement (VAs instead of immediate mode, and since text always has to be set when changed the vertex data etc. should be prepared once, instead of being generate every frame etc..) but if cpGUI is meant for SFML it should use it, and the fixes have to be done on the SFML-side of things
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Laurent on August 14, 2009, 03:02:52 pm
It's true that sf::String is not optimized at all. There will be many improvements in SFML 2, including the use of VBOs/VAs.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on August 14, 2009, 07:52:31 pm
Will there be a lot of old stuff that is broken with SFML 2.0, or will most of the end-user code be easy to port?
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: luminous on August 19, 2009, 10:22:10 am
I am hardly the authority on the matter, But from my poking around in the SFML 2.0 code to get idea's on using FBO's of sizes differing from the screen size with SFML drawable objects it looked like most of the code would be compatible with sfml 1.x, likely only requiring minor changes and a recompile due to slight API differences.

Really I can't wait SFML 2.0 is something I am looking forward to.

I have a Gui project I am working on as well, if your interested I would be more then happy to post the code after I polish it a bit.

I have a working 9slice render that draws to an FBO and saves the result as a texture for use later to prevent having to re-render  the same thing every frame. My widgets use FBO's as well and my gui only "re-renders" when something changes.  Maybe this approach would help with sf:String speed issues as well?
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: drew on August 19, 2009, 07:21:12 pm
Ah very nice! I was just trying to plan out ideas on how to implement my own GUI objects and I ran across this. I do kinda want to make my own to learn more but at the same time I'm so tempted to use this in my current project so I don't have to bother trying to do it all, which would probably end up being really inefficient anyway. :D
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: crazy2be on August 30, 2009, 01:34:41 am
Really great! The biggest improvements i could imagine on this are the adding of "hot" colors as imgui called them, or mouseover colors, and the ability to have dragable windows with controls in them.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Andershizzle on September 03, 2009, 06:53:30 am
When I go to build your example using MingW in Windows I get 2 errors...

Quote

Compiling...
cpGUI.cpp: In member function `sf::Font* cp::cpGuiContainer::GetFont(std::string
, unsigned int)':
cpGUI.cpp:146: error: `runtime_error' is not a member of `std'
Finished!
  Run Executable? 'y' or 'n'
Y



I then run it and it runs perfectly but after I close it the program hangs and I either have to end task it or it gives me a "program stopped responding, do you want to send information about the problem to microsoft blahblah"

What am I doing wrong o.o

And here's my 'compile.bat'

Code: [Select]

@echo off
Echo Compiling...
C:/MinGW/bin/g++ main.cpp cpGUI.cpp -o compile/main.exe -mwindows -enable-auto-import -lsfml-system -lsfml-graphics -lsfml-window -lsfml-network -lsfml-audio
Echo Finished!
Echo   Run Executable? 'y' or 'n'                                            
CHOICE /N /C:NY

IF ERRORLEVEL 2 GOTO RUN
IF ERRORLEVEL 1 GOTO END

:RUN
cd compile
main.exe
cd ../
GOTO END

:END
cmd


(main.cpp is cpGUI-Example.cpp)

Any help is appreciated.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on September 04, 2009, 10:01:26 pm
Quote from: "crazy2be"
Really great! The biggest improvements i could imagine on this are the adding of "hot" colors as imgui called them, or mouseover colors, and the ability to have dragable windows with controls in them.
Thanks for the compliment.

Technically, it does have a hot/mouseover color; you just can't customize it.  It would be pretty easy for me to add that feature, but my wife just had a baby, and I don't know when I'll have time to get back to it.

In the mean time, you could get into the code and change the color to whatever you want, but it would apply to every instance.  If you want to do that, look into the CheckState functions for cpObject and cpButton.  I think it's around lines 478 & 794.

As for dragable windows, I don't think I'll be doing that anytime soon. :)  You're free to add that feature to the code if you want as long as you follow the license.

Quote from: "Andershizzle"
When I go to build your example using MingW in Windows I get 2 errors...

Quote

Compiling...
cpGUI.cpp: In member function `sf::Font* cp::cpGuiContainer::GetFont(std::string
, unsigned int)':
cpGUI.cpp:146: error: `runtime_error' is not a member of `std'
Finished!
  Run Executable? 'y' or 'n'
Y

Sorry.  I use Visual Studio, which automatically includes some standard headers in the project.  Maybe trying this in the cpGUI code will help:
Code: [Select]
#include <stdexcept>
Also, it appears that maybe you're trying to load a font that doesn't exist where you're telling it to look.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Andershizzle on September 05, 2009, 03:42:08 am
I added that include line to the cpGUI.cpp and the two errors mentioned above disappear. Also I added -Wall to my build line to show me any other possible errors. Now I'm getting this

Quote

Compiling...
In file included from main.cpp:27:
cpGUI.h:90: warning: `class cp::cpObject' has virtual functions but non-virtual
destructor
cpGUI.h:136: warning: `class cp::cpImageButton' has virtual functions but non-vi
rtual destructor
cpGUI.h:154: warning: `class cp::cpButton' has virtual functions but non-virtual
 destructor
cpGUI.h:183: warning: `class cp::cpCheckBox' has virtual functions but non-virtu
al destructor
cpGUI.h:203: warning: `class cp::cpTextInputBox' has virtual functions but non-v
irtual destructor
cpGUI.h:235: warning: `class cp::cpShapeButton' has virtual functions but non-vi
rtual destructor
cpGUI.h:294: warning: `class cp::cpSelectionBox' has virtual functions but non-v
irtual destructor
cpGUI.h:328: warning: `class cp::cpDropDownBox' has virtual functions but non-vi
rtual destructor
cpGUI.h:363: warning: `class cp::cpTextBox' has virtual functions but non-virtua
l destructor
In file included from cpGUI.cpp:26:
cpGUI.h:90: warning: `class cp::cpObject' has virtual functions but non-virtual
destructor
cpGUI.h:136: warning: `class cp::cpImageButton' has virtual functions but non-vi
rtual destructor
cpGUI.h:154: warning: `class cp::cpButton' has virtual functions but non-virtual
 destructor
cpGUI.h:183: warning: `class cp::cpCheckBox' has virtual functions but non-virtu
al destructor
cpGUI.h:203: warning: `class cp::cpTextInputBox' has virtual functions but non-v
irtual destructor
cpGUI.h:235: warning: `class cp::cpShapeButton' has virtual functions but non-vi
rtual destructor
cpGUI.h:294: warning: `class cp::cpSelectionBox' has virtual functions but non-v
irtual destructor
cpGUI.h:328: warning: `class cp::cpDropDownBox' has virtual functions but non-vi
rtual destructor
cpGUI.h:363: warning: `class cp::cpTextBox' has virtual functions but non-virtua
l destructor
cpGUI.cpp: In member function `int cp::cpScrollBar::CheckState(const sf::Input*)
':
cpGUI.cpp:1561: warning: unused variable 'c1'
cpGUI.cpp:1562: warning: unused variable 'c2'
Finished!
  Run Executable? 'y' or 'n'


And I hit Y, it runs, and everything works perfectly. But when I exit it the process hangs for about 2 minutes and then gives me a "do you want to send more information about the problem?" error.

Details:

Quote

Files that help describe the problem:
  C:\Users\David\AppData\Local\Temp\WER3779.tmp.WERInternalMetadata.xml
  C:\Users\David\AppData\Local\Temp\WER7D5F.tmp.appcompat.txt
  C:\Users\David\AppData\Local\Temp\WER7E2B.tmp.mdmp

Read our privacy statement online:
  http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409

If the online privacy statement is not available, please read our privacy statement offline:
  C:\Windows\system32\en-US\erofflps.txt


C:\Users\David\AppData\Loca\Temp\WER3779.tmp.WERInternalMetadata.xml

Quote

<?xml version="1.0" encoding="UTF-16"?>
<WERReportMetadata>
   <OSVersionInformation>
      <WindowsNTVersion>6.1</WindowsNTVersion>
      <Build>7600 </Build>
      <Product>(0x1): Windows 7 Ultimate</Product>
      <Edition>Ultimate</Edition>
      <BuildString>7600.16385.x86fre.win7_rtm.090713-1255</BuildString>
      <Revision>1</Revision>
      <Flavor>Multiprocessor Free</Flavor>
      <Architecture>X86</Architecture>
      <LCID>1033</LCID>
   </OSVersionInformation>
   <ParentProcessInformation>
      <ParentProcessId>3520</ParentProcessId>
      <ParentProcessPath>C:\Windows\System32\cmd.exe</ParentProcessPath>
      <ParentProcessCmdLine>cmd /c &quot;&quot;C:\Users\David\Desktop\NLO stuff\Compile\compile.bat&quot; &quot;</ParentProcessCmdLine>
   </ParentProcessInformation>
   <ProblemSignatures>
      <EventType>APPCRASH</EventType>
      <Parameter0>main.exe</Parameter0>
      <Parameter1>0.0.0.0</Parameter1>
      <Parameter2>4aa1be27</Parameter2>
      <Parameter3>ntdll.dll</Parameter3>
      <Parameter4>6.1.7600.16385</Parameter4>
      <Parameter5>4a5bdadb</Parameter5>
      <Parameter6>c0000005</Parameter6>
      <Parameter7>000520bd</Parameter7>
   </ProblemSignatures>
   <DynamicSignatures>
      <Parameter1>6.1.7600.2.0.0.256.1</Parameter1>
      <Parameter2>1033</Parameter2>
      <Parameter22>4bd1</Parameter22>
      <Parameter23>4bd1049f64c514e5b780fba7750a6444</Parameter23>
      <Parameter24>047f</Parameter24>
      <Parameter25>047f8eae1393d3b43639cbda06828f50</Parameter25>
   </DynamicSignatures>
   <SystemInformation>
      <MID>4BF97D24-63F3-4E1A-9F80-7AE1AEEB70A3</MID>
      <SystemManufacturer>Acer</SystemManufacturer>
      <SystemProductName>Aspire one</SystemProductName>
      <BIOSVersion>V1.03</BIOSVersion>
   </SystemInformation>
</WERReportMetadata>



  C:\Users\David\AppData\Local\Temp\WER7D5F.tmp.appcompat.txt
 

Quote

<?xml version="1.0" encoding="UTF-16"?>
<DATABASE>
<EXE NAME="main.exe" FILTER="CMI_FILTER_PRIVACY">
    <MATCHING_FILE NAME="main.exe" SIZE="832870" CHECKSUM="0x64F72539" MODULE_TYPE="WIN32" PE_CHECKSUM="0xD3E2A" LINKER_VERSION="0x10000" LINK_DATE="09/05/2009 01:25:59" UPTO_LINK_DATE="09/05/2009 01:25:59" EXE_WRAPPER="0x0" FILE_ID="00006435dac87dcdec294673fd02182c256ac347385a" PROGRAM_ID="0000da39a3ee5e6b4b0d3255bfef95601890afd80709" />
    <MATCHING_FILE NAME="sfml-audio.dll" SIZE="615028" CHECKSUM="0x5B7C2B7D" MODULE_TYPE="WIN32" PE_CHECKSUM="0x9D5EB" LINKER_VERSION="0x10000" LINK_DATE="05/28/2009 16:25:22" UPTO_LINK_DATE="05/28/2009 16:25:22" EXPORT_NAME="sfml-audio.dll" EXE_WRAPPER="0x0" FILE_ID="000069073a2742bbd65693a8e74eb147adaadcb7b83d" PROGRAM_ID="0003470739f515012dff8c3593313a1a1d400000ffff" />
    <MATCHING_FILE NAME="sfml-graphics.dll" SIZE="2103323" CHECKSUM="0xE5BFB186" MODULE_TYPE="WIN32" PE_CHECKSUM="0x20CB51" LINKER_VERSION="0x10000" LINK_DATE="05/28/2009 16:25:15" UPTO_LINK_DATE="05/28/2009 16:25:15" EXPORT_NAME="sfml-graphics.dll" EXE_WRAPPER="0x0" FILE_ID="00003313da24bc1dffa0365d0517712225570799f7b5" PROGRAM_ID="0003abcd64bf3aefe0f4bbf259ad6f3f91060000ffff" />
    <MATCHING_FILE NAME="sfml-network.dll" SIZE="619251" CHECKSUM="0x6CEA735" MODULE_TYPE="WIN32" PE_CHECKSUM="0x99A28" LINKER_VERSION="0x10000" LINK_DATE="05/28/2009 16:24:52" UPTO_LINK_DATE="05/28/2009 16:24:52" EXPORT_NAME="sfml-network.dll" EXE_WRAPPER="0x0" FILE_ID="0000aa2041af973efa60795da7418da8a7aecf230f28" PROGRAM_ID="0003b5b4a913697cc1c6748b29fba99c74040000ffff" />
    <MATCHING_FILE NAME="sfml-system.dll" SIZE="533351" CHECKSUM="0xD1667E5C" MODULE_TYPE="WIN32" PE_CHECKSUM="0x8A934" LINKER_VERSION="0x10000" LINK_DATE="05/28/2009 16:24:43" UPTO_LINK_DATE="05/28/2009 16:24:43" EXPORT_NAME="sfml-system.dll" EXE_WRAPPER="0x0" FILE_ID="0000a4f286ea3cd304388424329ce7af7ea0c8be85ff" PROGRAM_ID="000325ccb3fd7e77ad97e66837ecfe6a909a0000ffff" />
    <MATCHING_FILE NAME="sfml-window.dll" SIZE="563938" CHECKSUM="0xC77A85AF" MODULE_TYPE="WIN32" PE_CHECKSUM="0x91A68" LINKER_VERSION="0x10000" LINK_DATE="05/28/2009 16:24:46" UPTO_LINK_DATE="05/28/2009 16:24:46" EXPORT_NAME="sfml-window.dll" EXE_WRAPPER="0x0" FILE_ID="0000cc28f5058e87e2d4e093c68e8f0ba24d877a21fd" PROGRAM_ID="0003acaf3e3460b7f9e3fab39483cedbe36f0000ffff" />
</EXE>
<EXE NAME="ntdll.dll" FILTER="CMI_FILTER_THISFILEONLY">
    <MATCHING_FILE NAME="ntdll.dll" SIZE="1286144" CHECKSUM="0x1220566E" BIN_FILE_VERSION="6.1.7600.16385" BIN_PRODUCT_VERSION="6.1.7600.16385" PRODUCT_VERSION="6.1.7600.16385" FILE_DESCRIPTION="NT Layer DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows® Operating System" FILE_VERSION="6.1.7600.16385 (win7_rtm.090713-1255)" ORIGINAL_FILENAME="ntdll.dll.mui" INTERNAL_NAME="ntdll.dll" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0x14033F" LINKER_VERSION="0x60001" UPTO_BIN_FILE_VERSION="6.1.7600.16385" UPTO_BIN_PRODUCT_VERSION="6.1.7600.16385" LINK_DATE="07/14/2009 01:09:47" UPTO_LINK_DATE="07/14/2009 01:09:47" EXPORT_NAME="ntdll.dll" VER_LANGUAGE="English (United States) [0x409]" EXE_WRAPPER="0x0" FILE_ID="00009d56bf20851f26960c4c33dd4bde84730c8d483f" PROGRAM_ID="0000f519feec486de87ed73cb92d3cac802400000000" />
</EXE>
<EXE NAME="kernel32.dll" FILTER="CMI_FILTER_THISFILEONLY">
    <MATCHING_FILE NAME="kernel32.dll" SIZE="857088" CHECKSUM="0x22F48E19" BIN_FILE_VERSION="6.1.7600.16385" BIN_PRODUCT_VERSION="6.1.7600.16385" PRODUCT_VERSION="6.1.7600.16385" FILE_DESCRIPTION="Windows NT BASE API Client DLL" COMPANY_NAME="Microsoft Corporation" PRODUCT_NAME="Microsoft® Windows® Operating System" FILE_VERSION="6.1.7600.16385 (win7_rtm.090713-1255)" ORIGINAL_FILENAME="kernel32" INTERNAL_NAME="kernel32" LEGAL_COPYRIGHT="© Microsoft Corporation. All rights reserved." VERDATEHI="0x0" VERDATELO="0x0" VERFILEOS="0x40004" VERFILETYPE="0x2" MODULE_TYPE="WIN32" PE_CHECKSUM="0xD5597" LINKER_VERSION="0x60001" UPTO_BIN_FILE_VERSION="6.1.7600.16385" UPTO_BIN_PRODUCT_VERSION="6.1.7600.16385" LINK_DATE="07/14/2009 01:09:01" UPTO_LINK_DATE="07/14/2009 01:09:01" EXPORT_NAME="KERNEL32.dll" VER_LANGUAGE="English (United States) [0x409]" EXE_WRAPPER="0x0" FILE_ID="00004f0b455c60c4292a488291d8c29f48aeec7a17e7" PROGRAM_ID="0000f519feec486de87ed73cb92d3cac802400000000" />
</EXE>
</DATABASE>


DefaultDataCollection failed: 0x8007001f

Idk what to do.

And I'm not trying to load any different fonts. I'm using your source code provided to try and build this. The cpGUI-Example.cpp is what I'm trying to build.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: crazy2be on September 05, 2009, 04:43:57 am
I might adopt this project, as i need a GUI toolkit for my project, and using this would be easier than creating my own. However, i might have to release it under a GPL license, since my already existing window code is GPL license. Also, why did you put it all in one file? Doesn't that make it a pain to work with? (or do you have multiple files, you just combined them into one for release?). If you have it broken down into multiple files, i would appreciate if you PMed me the files or posted them here.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Andershizzle on September 05, 2009, 05:40:10 am
I honestly just need a textbox class. I don't need a whole GUI I just want a selectable TextInputBox and a large textbox with scrollbar that wordwraps text without the whole jizzjazz >.>
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on September 06, 2009, 10:07:49 pm
Quote from: "Andershizzle"
I added that include line to the cpGUI.cpp and the two errors mentioned above disappear. Also I added -Wall to my build line to show me any other possible errors. Now I'm getting this
Well, warnings are not the same as errors.  The code should run fine with warnings.  I tried to get rid of them all, and in Visual Studio, I did.

I honestly don't know why it's hanging for you.  I can't reproduce it.  Does SFML itself work for you without using cpGUI?  Also, are you using SFML version 1.5?

Quote from: "crazy2be"
I might adopt this project, as i need a GUI toolkit for my project, and using this would be easier than creating my own. However, i might have to release it under a GPL license, since my already existing window code is GPL license. Also, why did you put it all in one file? Doesn't that make it a pain to work with? (or do you have multiple files, you just combined them into one for release?). If you have it broken down into multiple files, i would appreciate if you PMed me the files or posted them here.
the zlib/libpng license is supposed to be compatible with the GPL.  That doesn't mean that cpGUI will turn into GPL for everyone else, though.  But it should be able to be incorporated into a GPL project.

Are you just wanting the classes each in their own files to make it more modular so you can just include only what you need?  I was thinking about doing that, but I never got around to it.  It really wouldn't be that hard for you to do it yourself, if that's what you're wanting.  I don't know when I'm going to get around to it.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Andershizzle on September 07, 2009, 05:19:32 pm
Yes SFML works normally for me. And yes I'm using 1.5. Oh well.

I think I'm just gonna revert back to Visual studio 2008.

BUT.

Quote

Are you just wanting the classes each in their own files to make it more modular so you can just include only what you need? I was thinking about doing that, but I never got around to it. It really wouldn't be that hard for you to do it yourself, if that's what you're wanting. I don't know when I'm going to get around to it.


I'd love this ^^

I hate the idea if installing a huge library just to get what I want out of it. For instance, I need regex. I say HELL no to installing all of "BOOST" just to get regex. Same goes for wxwidgets. I just want a textbox. not a whole huge huge workspace thing. I wish they had their stuff seperated so you can pick and choose at what you want for your needs.

So yeah, if you or anyone could seperate each of the classes into their own headers so you could just pick and choose that'd be awesome.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: phear- on September 12, 2009, 03:10:18 am
I made a mirror on my website since a lot of people don't like to use those pay2download sites.

http://blog.gtproductions.org/cpGUI_15_4.zip
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: phear- on September 14, 2009, 02:56:38 am
I made a static library out of the current release for use with my game if anyone needs it:

http://blog.gtproductions.org/cpGUI-s.rar

Put includes into /include/ folder and the lib files into /lib/. Remember to add to your linker: cpGUI-s.lib and include into your project with
#include <SFML/cpGUI/cpGUI.h>
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on September 14, 2009, 11:35:16 pm
Sweet!  Thanks for doing that.

I added your links to the wiki.  If you don't want them there, let me know.  Thanks again.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: nacsasoft on September 27, 2009, 04:53:44 pm
Helo forrestcupp !

I have a little problem with the cpSelectionBox.
I added 14 choices for my cpSelectionBox and select 13th choice.
http://img225.imageshack.us/i/itemselect.jpg/

I use the RemoveLastChoice() function and I get an error :
http://img98.imageshack.us/i/purevirtualmethodcalled.jpg/

What is the problem ?
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: phear- on September 28, 2009, 07:07:55 am
"pure virtual method called"
That's pretty self explanatory...
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on September 28, 2009, 05:30:54 pm
Well, there actually was a bug in the way RemoveLastChoice() was implemented.  It had to do with how the scroll bar is repopulated.  I also didn't have any error catching, and it desperately needed it.  I have completely fixed this bug in the version I just released in the wiki.  Thanks to nacsasoft for pointing this out.

Also, if you're dynamically removing the last choice when a selection is made, make sure you are only doing it when the selection is actually being made.  If you just set a variable to the selection and only test that variable, it will just end up removing all the selections because that variable will not change until the user changes their selection.

See my next post about the new version!


By the way, your first screen shot is pretty sweet, nacsasoft!
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on September 28, 2009, 05:42:28 pm
**Major Update**

I have just released cpGUI version 1.5.5b on the wiki.  This update adds a few things that people in this thread have asked for.

First, I have added the functions SetMouseoverColor() and GetMouseoverColor().  These functions allow you to customize the "hot" color that the object changes to when the user mouses over the object.

Secondly, I have added the ability to only include the objects that you want to use for your project to cut down on bloat.  I have separated most of the object classes into their own header and cpp files so that you can include only the ones you want.  There are cpGUI_base.h and cpGUI_base.cpp files that must be included as a requirement.  These files include the classes for cpGuiContainer, cpObject, cpButton, and cpScrollBar.  This is necessary because other objects depend on these.  cpSelectionBox and cpDropDownBox classes are both in the cpSelection-DropDownBox.h and cpSelection-DropDownBox.cpp files because the drop down box depends on the selection box.  Other than that, each of the other objects have their own files.  There is now a cpGUI-example-partial.cpp file to demonstrate how to do things this way.

Of course, you can still choose to do things the old way and include all of the classes in the original cpGUI.h and cpGUI.cpp files.  If you choose to do it this way, you don't need to include any of the new files.  The download still includes the cpGUI-example.cpp file to demonstrate how to do things this way.  The new features and bug fixes are incorporated into these files, also.

Lastly, I fixed a selection box bug pointed out by nacsasoft.  This bug caused a runtime error when you dynamically RemoveLastChoice() when the user makes a certain selection and the scroll bar is all the way down.  This bug is now fixed along with some much needed error catching in the RemoveLastChoice() function.

Enjoy!
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: nacsasoft on September 28, 2009, 06:23:09 pm
Thank You for quick help !!!!
 :P
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on September 29, 2009, 09:55:07 pm
**Another Update**

I'm sorry for updating so soon, but I think this one will be worth it.  I found out about a few things that needed to be addressed after I had already released the new version the other day.

cpGUI version 1.5.6 includes a tweak to the CheckState() function.  This tweak was pointed out by Meltra Bour.  Since CheckState is called every frame, this could hopefully give some considerable speed boosts.

I've also included a few minor bug fixes.

But one of the most exciting additions is that cpGUI now has a static library.  The download now includes structured directories for the includes, libs, source (the cpp files), and samples.  You can unzip the folder wherever you want and set up your IDE to statically link to cpGUI's libs.  This is done the same way as described in SFML's "Getting Started" tutorials.  You should use the -d.lib files for debug mode.

The cpp files are still included in the "source" directory if you would like to just do things the old way and include the files in your project.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: phear- on September 29, 2009, 10:34:00 pm
Mirror again:
http://gtproductions.org/sfml/cpGUI_15_6.zip

Thanks for having a static library this time around.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on September 30, 2009, 03:05:32 am
Thanks for the mirror.  I'll try to get it on the wiki tomorrow.

I actually just now changed my own link to a direct download, so there should be less complaints now.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: madmark on October 03, 2009, 02:16:34 am
Love this and I already have it in my current project.

2 suggestions:

I added the Draw() method to the cpObject class (empty function, virtual) so that I could put all my controls in a std::list and draw then in a loop.

I need an image button that has 4 states (normal, mouseover,pressed, disabled). I have this already done, but outside the cpGUI system. If there is interest I will move it into the namespace and hook it up.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on October 06, 2009, 09:12:13 pm
Quote from: "madmark"
Love this and I already have it in my current project.

2 suggestions:

I added the Draw() method to the cpObject class (empty function, virtual) so that I could put all my controls in a std::list and draw then in a loop.

I need an image button that has 4 states (normal, mouseover,pressed, disabled). I have this already done, but outside the cpGUI system. If there is interest I will move it into the namespace and hook it up.

I'm glad it's working out for you.

Those are pretty good and interesting suggestions.  It might be good to have a disabled option for all types of controls where they are still shown, but grayed out and not usable.  I'll keep these things in mind, but I'm not sure when I'll be ready to have another release.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: coolhome on October 07, 2009, 04:35:48 am
Very nice. I was making a GUI class for my own little collection of tools for my games. Although im reworking the core of my own little engine. Keep up the good work.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: BobTheFish on November 26, 2009, 02:11:23 pm
I like this GUI class and I can compile and run the example (cpGUI-example).

When the program closes (for example when I click the close box or one of the buttons) it throws an unhandled access read violation.
I've tried the 1.5 release and the latest snapshot with the same result.

Debug takes me to line 769 of Image.cpp, which says:
Code: [Select]
GLCheck(glDeleteTextures(1, &Texture));

I'm surprised I couldn't find this problem mentioned anywhere else since I'm running the unmodified example...
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: panithadrum on November 26, 2009, 07:41:51 pm
I appreaciate your work, but don't you find that one lib per gui component is too much? It would be better and faster just to have one lib for all!
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: BobTheFish on November 26, 2009, 11:39:27 pm
I forgot to say that I'm using WinXP, Visual-C++ 2008 Express, and the dynamic SFML.

Another question about cpGUI: is there a built in file select dialog? If not, read on.

I'm thinking I could implement a simple one using a listbox, but I don't know how to do file operations in a cross-platform way. For example I could use system("dir") to get the contents of a directory, but this approach is valid only for Windows systems.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Nexus on November 27, 2009, 02:37:50 pm
Quote from: "BobTheFish"
but I don't know how to do file operations in a cross-platform way.
I recommend Boost.Filesystem (http://www.boost.org/doc/libs/1_40_0/libs/filesystem/doc/index.htm). But you need the Boost C++ Libraries (which isn't a bad choice, anyway).
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: BobTheFish on November 27, 2009, 04:29:51 pm
Ok, thanks.

More important at the moment is that access violation; I can't really have a program that crashes every time it exits. And I'd really like to use cpGUI, so I need to figure out how to fix it.

Any suggestions?
Title: Question
Post by: caro1302 on November 28, 2009, 04:19:34 am
Hi,

I have a question about your project.

I'm trying to use your project with a SFML project I am creating.
I am using Visual Studio 2008.

I am a beginner and I'm not pretty sure where and which informations I am supposed to put for links. I tried to put in Linker/Input with SFML libs

in Release mode: cpGUI.lib
in Debug mode: cpGUI-d.lib

I also put in Options/Project and Solutions/VC++ Directories in Include Files the path to the cpGUI\include folder.

And include "#include <cpGUI.h>" in main file.

I'm not sure where I am supposed to put the cpGUI folder. Is it in the same directory as my solution, is it in the folder where I have my .cpp and .h files or is it somewhere in the SFML-1.5 folder?

I got the following errors in Debug mode that looks like this:
Error   61   error LNK2019: unresolved external symbol "__declspec(dllimport) public: class sf::String & __thiscall sf::String::operator=(class sf::String const &)" (__imp_??4String@sf@@QAEAAV01@ABV01@@Z) referenced in function "public: virtual void __thiscall cp::cpObject::SetFontSize(unsigned int)" (?SetFontSize@cpObject@cp@@UAEXI@Z)   cpGUI-d.lib


There is somebody to help me with this basic problems?
Thanks!

Sorry for my english! :)
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Laurent on November 28, 2009, 10:09:09 am
Please don't duplicate questions, as it duplicates answers too.

For those who want to answer, please do it there:
http://www.sfml-dev.org/forum/viewtopic.php?p=12248#12248
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: BobTheFish on November 29, 2009, 11:21:03 am
In case anyone else has the same problem as me:

I suspect it was being caused by the notorious default font bug. Since there's no way to avoid the default font being loaded by cpGUI I'd assumed the author(s) would have accounted for it.

The only other way to avoid the crash as far as I know is to use static linking, so I did that.[/i]
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on December 04, 2009, 12:05:49 am
Quote from: "BobTheFish"
In case anyone else has the same problem as me:

I suspect it was being caused by the notorious default font bug. Since there's no way to avoid the default font being loaded by cpGUI I'd assumed the author(s) would have accounted for it.

The only other way to avoid the crash as far as I know is to use static linking, so I did that.[/i]
Sorry for taking so long to answer.  I haven't been able to reproduce your problem.

I can tell you that cpGUI is not made for dynamic linking.  It's only made for either static linking or actually integrating the code into your project.  You can static link to cpGUI at the same time you're dynamically linking to SFML.

I'm glad it worked when you did that.


Quote from: "panithadrum"
I appreaciate your work, but don't you find that one lib per gui component is too much? It would be better and faster just to have one lib for all!
Reread the wiki.  If you only link to cpGUI.lib and include cpGUI.h, it includes everything in one file.  

I also made each control available in their own lib as an alternative because people who wanted to pick and choose controls asked me to do that to cut down on bloat.  So you can have it either way; you don't have to use all those libs.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Svenstaro on January 06, 2010, 09:36:38 pm
It appears you forgot to add
Code: [Select]
#include <stdexcept> to cpGUI_base.h and cpGUI.h. Did nobody else notice?
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: model76 on February 16, 2010, 02:00:25 am
Hello forrestcupp, and thanks for making this! Awesome job!

I think I found a small bug: If you have a Drop Down Box with scroll bar, and then scroll it by left-clicking the up/down arrows, or by dragging the scroll-position-indicator-thingie (Isn't that the official name of such a thing?), then the drop-down closes on mouse-up.

So in effect, you can only really scroll it with the mouse wheel.

[EDIT]
Um, further investigation shows that this is probably not a bug, but rather a me that should read the manual better... Sorry.  :oops:
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: model76 on February 27, 2010, 08:54:33 pm
Hi again,

After playing about with cpGUI for a bit, I decided to add the possibility to change the color of the button and arrow on the drop down object.
Here is the patch:
Code: [Select]
// For the header

void SetFont(std::string filename, unsigned int size);
void SetBackgroundColor(sf::Color color);
void SetDownButtonBackgroundColor(sf::Color color);
Code: [Select]
// Implementation

// Sets the color and outline color of the down arrow.
void cpDropDownBox::SetDownArrowColor(sf::Color color, sf::Color outlineColor)
{
sf::Shape newArrow;

newArrow.AddPoint(PosX+Width-Height+Height/3, PosY+Height/3, color, outlineColor);
newArrow.AddPoint(PosX+Width-Height+Height*2/3, PosY+Height/3, color, outlineColor);
newArrow.AddPoint(PosX+Width-Height+Height/2, PosY+Height*2/3, color, outlineColor);
newArrow.SetOutlineWidth(1.f);

downArrow = newArrow;
}

// Sets the color of the down arrow.
// The outline color is automtically set to match the background.
// Warning: The outline color will not be kept in sync if the background changes!
void cpDropDownBox::SetDownArrowColor(sf::Color color)
{
SetDownArrowColor(color, btnBackground);
}

// Sets the background color of the down button.
void cpDropDownBox::SetDownButtonBackgroundColor( sf::Color color )
{
downBtn->SetBackgroundColor( color );
}
Oh, and I hereby release the code into the public domain, so anyone can use it, anyway they like. :)

EDIT:

And here is one for the wish list: A pure cpLabel object with the usual abilities to set colors and font, and so on. That would be very useful!
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: nulloid on April 05, 2010, 02:01:09 am
I ran into a small bug: when I set the position of a cpImageButton, the sprite doesn't move with the button. Very easy to fix it, just add this line to the code:

Code: [Select]
/// Sets the image button's position coordinates in the window
void cpImageButton::SetPosition(float posx, float posy)
{
cpObject::SetPosition(posx, posy);
sprite.SetPosition(posx + 1, posy + 1); //This is the additional line
CreateRects("");
}
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: m0refi4 on April 20, 2010, 07:02:07 pm
Hm I somehow can't get cpGUI to run. I always get undefined references. Would be great if someone could help me out here  :?
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: nulloid on April 22, 2010, 12:38:09 am
Read the wiki. It says: "When creating your own project, make sure to put the cpGUI.h & cpGUI.cpp files in your project and #include „cpGUI.h“. " That's all you need. At least it worked for me ;)
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: m0refi4 on April 22, 2010, 12:43:37 am
Quote from: "nulloid"
Read the wiki. It says: "When creating your own project, make sure to put the cpGUI.h & cpGUI.cpp files in your project and #include „cpGUI.h“. " That's all you need. At least it worked for me ;)


Well Ive done the most stupid thing ever since I added all the source files and headers to my project and wondered why I'd get so many multiple definitions..

Works fine now, thanks ;p
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: forrestcupp on April 22, 2010, 03:11:27 pm
Quote from: "m0refi4"
Quote from: "nulloid"
Read the wiki. It says: "When creating your own project, make sure to put the cpGUI.h & cpGUI.cpp files in your project and #include „cpGUI.h“. " That's all you need. At least it worked for me ;)


Well Ive done the most stupid thing ever since I added all the source files and headers to my project and wondered why I'd get so many multiple definitions..

Works fine now, thanks ;p
I answered your pm before I saw what you did here.

cpGUI.h & cpGUI.cpp include all the classes needed for everything.  The other header and cpp files are for the people who want to pick and choose what controls they want to use to streamline their program.  Some people didn't want to have to have everything in their program when they are only using one or two controls.

I'm glad you figured it out.
Title: Status Update
Post by: Recruit0 on June 24, 2010, 01:41:20 am
Status Update

We will get around to creating a mailing list or other form of public communication later. For now this forum should be used to contact us if you want to reach us.
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: model76 on July 07, 2010, 10:42:24 pm
Hi, nice to see someone picked it up.

I played around with the code quite a bit, and added a bunch of features, so I was thinking maybe you new people would like to have my files?
Just drop me a PM if you do. The changes should be well enough documented.

Oh, and see you back in action in about a year, forestcupp! Unless you get another one in the mean time... ;)
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: Recruit0 on July 08, 2010, 05:16:50 pm
We're primarily concerned with bug fixes for the old API since we're creating a new one. What features did you add?
Title: cpGUI - A new object oriented GUI toolkit based on SFML 1.5
Post by: carsaxy on October 30, 2011, 12:33:41 pm
Thanks!
Do I have to build this library with cmake before use it?