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

#1
Installation help / Re: Compiling TGUI with VS2015
25 September 2015, 03:07:09
Yep, I am using the files from the .zip. My Button.hpp looks like this:

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// Copyright (C) 2012-2013 Bruno Van de Velde (vdv_b@tgui.eu)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
//    you must not claim that you wrote the original software.
//    If you use this software in a product, an acknowledgment
//    in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
//    and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


#ifndef TGUI_BUTTON_HPP
#define TGUI_BUTTON_HPP


#include <TGUI/ClickableWidget.hpp>

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace tgui
{
    class Container;

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    class TGUI_API Button : public ClickableWidget
    {
      public:

        typedef SharedWidgetPtr<Button> Ptr;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Default constructor
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        Button();


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Copy constructor
        ///
        /// \param copy  Instance to copy
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        Button(const Button& copy);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Destructor
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual ~Button();


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Overload of assignment operator
        ///
        /// \param right  Instance to assign
        ///
        /// \return Reference to itself
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        Button& operator= (const Button& right);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        // Makes a copy of the widget by calling the copy constructor.
        // This function calls new and if you use this function then you are responsible for calling delete.
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual Button* clone();


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Loads the widget.
        ///
        /// \param configFileFilename  Filename of the config file.
        ///
        /// The config file must contain a Button section with the needed information.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        bool load(const std::string& configFileFilename);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Returns the filename of the config file that was used to load the widget.
        ///
        /// \return Filename of loaded config file.
        ///         Empty string when no config file was loaded yet.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        const std::string& getLoadedConfigFile() const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Set the position of the widget
        ///
        /// This function completely overwrites the previous position.
        /// See the move function to apply an offset based on the previous position instead.
        /// The default position of a transformable widget is (0, 0).
        ///
        /// \param x X coordinate of the new position
        /// \param y Y coordinate of the new position
        ///
        /// \see move, getPosition
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void setPosition(float x, float y);
        using Transformable::setPosition;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Changes the size of the button.
        ///
        /// \param width   The new width of the button
        /// \param height  The new height of the button
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void setSize(float width, float height);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Changes the caption of the button.
        ///
        /// \param text  New text to draw on top of the button.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void setText(const sf::String& text);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Returns the caption of the button.
        ///
        /// \return Text that is drawn on top of the button.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        sf::String getText() const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Changes the font of the text.
        ///
        /// When you don't call this function then the global font will be use.
        /// This global font can be changed with the setGlobalFont function from the parent.
        ///
        /// \param font  The new font
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void setTextFont(const sf::Font& font);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Returns the font of the text.
        ///
        /// \return  Pointer to the font that is currently being used
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        const sf::Font* getTextFont() const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Changes the color of the text.
        ///
        /// \param color  New text color
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void setTextColor(const sf::Color& color);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Returns the color of the text.
        ///
        /// \return The current text color
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        const sf::Color& getTextColor() const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Changes the character size of the text.
        ///
        /// \param size  The new text size.
        ///              If the size is set to 0 then the text will be auto-sized to fit inside the button.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void setTextSize(unsigned int size);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Returns the character size of the text.
        ///
        /// \return The current text size.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        unsigned int getTextSize() const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \brief Changes the transparency of the widget.
        ///
        /// \param transparency  The transparency of the widget.
        ///                      0 is completely transparent, while 255 (default) means fully opaque.
        ///
        /// Note that this will only change the transparency of the images. The parts of the widgets that use a color will not
        /// be changed. You must change them yourself by setting the alpha channel of the color.
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void setTransparency(unsigned char transparency);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void keyPressed(sf::Keyboard::Key key);

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void widgetFocused();


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        // This function is a (slow) way to set properties on the widget, no matter what type it is.
        // When the requested property doesn't exist in the widget then the functions will return false.
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual bool setProperty(std::string property, const std::string& value);

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        // This function is a (slow) way to get properties of the widget, no matter what type it is.
        // When the requested property doesn't exist in the widget then the functions will return false.
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual bool getProperty(std::string property, std::string& value) const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        // Returns a list of all properties that can be used in setProperty and getProperty.
        // The second value in the pair is the type of the property (e.g. int, uint, string, ...).
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual std::list< std::pair<std::string, std::string> > getPropertyList() const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      protected:

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        // This function is called when the widget is added to a container.
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void initialize(Container *const container);


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// \internal
        // Draws the widget on the render target.
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      public:

        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// Defines specific triggers to Button.
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        enum ButtonCallbacks
        {
            SpaceKeyPressed      = ClickableWidgetCallbacksCount * 1,     ///< Space key was pressed
            ReturnKeyPressed     = ClickableWidgetCallbacksCount * 2,     ///< Return key was pressed
            AllButtonCallbacks   = ClickableWidgetCallbacksCount * 4 - 1, ///< All triggers defined in Button and its base classes
            ButtonCallbacksCount = ClickableWidgetCallbacksCount * 4
        };


        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      protected:

        std::string m_LoadedConfigFile;

        Texture m_TextureNormal_L;
        Texture m_TextureHover_L;
        Texture m_TextureDown_L;
        Texture m_TextureFocused_L;

        Texture m_TextureNormal_M;
        Texture m_TextureHover_M;
        Texture m_TextureDown_M;
        Texture m_TextureFocused_M;

        Texture m_TextureNormal_R;
        Texture m_TextureHover_R;
        Texture m_TextureDown_R;
        Texture m_TextureFocused_R;

        // If this is true then the L, M and R images will be used.
        // If it is false then the button is just one big image that will be stored in the M image.
        bool m_SplitImage;

        // Is there a separate hover image, or is it a semi-transparent image that is drawn on top of the others?
        bool m_SeparateHoverImage;

        // The SFML text
        sf::Text m_Text;

        // This will store the size of the text ( 0 to auto size )
        unsigned int m_TextSize;


        friend class ChildWindow;
    };

    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#endif // TGUI_BUTTON_HPP



#2
Installation help / Re: Compiling TGUI with VS2015
22 September 2015, 03:34:01
Hm, I seem to be getting errors in the TGUI header files, like

Error   C2238   unexpected token(s) preceding ';'   Byte   E:\OpenGL\include\TGUI\Button.hpp, Line   44

Any suggestions?  I can't seem to figure out why the actual library is erring. 
#3
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 23:07:35
Ah, makes sense, I derped.  I'll look around and see what I can figure out.
#4
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 23:04:03
Hm... I seem to get 269 errors when I try it with my project.  For example:

'load': is not a member of 'tgui::Picture'


but it has methods like askToolTip, so I'm not sure what's going on.  the code worked previously, but I'm not sure what's throwing it off now. 
#5
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 21:47:27
Thank you very much for your help!
#6
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 19:16:23
Thanks so much!  Yeah, I have no idea why it's not working, because that is how the microsoft website says to set up a project for 64 bit.... 

https://www.dropbox.com/sh/fgs8zt7uq10afsg/AABfr7Ita1VGmAZ_W7mCqMiCa?dl=0
#7
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 18:56:34
I have x64 SFML and I used that to build TGUI, but I didn't see an option to change TGUI from 32 bit to 64 bit.  I went into Configuration Manager, tried with Win32, and it threw this error.  I changed the Active Solution Platform to a new one, Changed it from ARM to x64, set all the projects to x64, and it still throws the same error. 
#8
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 18:25:02
OK, it was able to be created with CMake.  However, now when I build in VS2015, I get the following:


Error   LNK1112   module machine type 'x64' conflicts with target machine type 'X86'   tgui   E:\Downloads\TGUI-0.7-alpha1\TGUI-0.7-alpha1\build\src\TGUI\sfml-graphics.lib(sfml-graphics-2.dll)

Any ideas?
#9
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 17:51:39
The file says 2.1 (Major version 2, minor 1).
#10
Installation help / Re: Compiling TGUI with VS2015
20 September 2015, 17:47:57
The path is "E:/OpenGL/include".  Inside that folder is a folder called SFML, and in that folder are all the SFML header and cpp files.
#11
Installation help / Compiling TGUI with VS2015
20 September 2015, 06:52:22
I am trying to compile TGUI for Visual Studio 2015 because the version I was using previously seemed to not work for VS2015.  However, I keep getting this error when I try to use CMAKE:

SFML found but version too low (requested: 2, found: 1.x.x)
CMake Error at CMakeLists.txt:290 (message):
  CMake couldn't find SFML.  Set the SFML_ROOT entry to SFML's root directory
  (containing "include" and "lib" directories).


Configuring incomplete, errors occurred!
See also "E:/Downloads/TGUI/CMakeFiles/CMakeOutput.log".


I am using SFML 2.3.2.
#12
I am using Visual Studio 2015.  I don't remember if I built or downloaded the library, but I've attached the dll to the post (https://www.dropbox.com/sh/5wg3bkmhtskx2av/AAD6rcFwKUJ4I9Bem-UdaHxQa?dl=0).  Here's the code block the line is in:

buttonExit->bindCallback(tgui::Button::LeftMouseClicked);
buttonExit->setCallbackId(1);
buttonApply->bindCallback(tgui::Button::LeftMouseClicked);
buttonApply->setCallbackId(3);
cbResolution->bindCallbackEx(resolutionCallback, tgui::ComboBox::ItemSelected);


and the associated code:

tgui::ComboBox::Ptr cbResolution(mGui);
cbResolution->load("Media/Widgets/Black.conf");
cbResolution->setSize(260, 30);
cbResolution->setPosition(360, 250);
cbResolution->addItem("800x600");
cbResolution->addItem("1024x768");
cbResolution->addItem("1280x800");
cbResolution->addItem("1280x1024");
cbResolution->addItem("1366x768");
cbResolution->addItem("1440x900");
cbResolution->addItem("1600x900");
cbResolution->addItem("1680x1050");
cbResolution->addItem("1920x1080");
#13
I recently updated my computer to windows 10, and have been getting the following error:

Severity Code Description Project File Line
Error LNK2019 unresolved external symbol "__declspec(dllimport) public: void __thiscall tgui::CallbackManager::bindCallbackEx(class std::function<void __cdecl(struct tgui::Callback const &)>,unsigned int)" (__imp_?bindCallbackEx@CallbackManager@tgui@@QAEXV?$function@$$A6AXABUCallback@tgui@@@Z@std@@I@Z) referenced in function "public: virtual void __thiscall GuiOptions::loadWidgets(void)" (?loadWidgets@GuiOptions@@UAEXXZ) Byte E:\GameDev\C++\Byte\Byte\GuiOptions.obj 1


I've gotten unresolved external symbol errors before, but I cannot seem to figure this out.  Any help? 
#14
Help requests / Re: Callbacks with the ComboBox
31 December 2014, 21:12:07
Attempting to bind the callback gives me the following error:

1>e:\gamedev\c++\byte\byte\guioptions.cpp(59): error C3867: 'GuiOptions::resolutionCallback': function call missing argument list; use '&GuiOptions::resolutionCallback' to create a pointer to member

void resolutionCallback(const tgui::Callback& callback);
void GuiOptions::resolutionCallback(const tgui::Callback& callback)
{
selectedResolution = callback.text;
std::cout << selectedResolution << std::endl;
}
#15
Help requests / Callbacks with the ComboBox
29 December 2014, 03:55:19
Hello!  I am attempting to work with callbacks with the ComboBox.  How do I know what is selected in the box?