summaryrefslogtreecommitdiff
path: root/src/gui/widgets/button.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-07-15Render font outlines using TTF_SetFontOutlineThorbjørn Lindeijer1-11/+9
Rather than rendering the same texture 4 additional times, render a specific outline version of the text. While reducing the number of times the text is drawn, it does increase font texture use. Result is a generally prettier outline due to rendering it properly at sharp corners of the characters. The shadow for outlined text is now also thicker, as appropriate. As part of this change, the `TextRenderer` class was merged into the `Graphics` and `TrueTypeFont` classes. There seemed to be little point in having a separate function for this, apart from needing more static casts to `Graphics*`. Also fixed an issue where the font style was not being restored after adjusting the font scale, when using an older SDL_ttf than 2.0.18. Closes #87
2025-03-31GUI: Support customizing widget text format through themeThorbjørn Lindeijer1-20/+28
The following widgets now support setting the font, text color, outline color and shadow color through the theme: * Button * Tab * Window (title) * ProgressBar The text format can be specified differently per skin state.
2025-03-24Expanded GUI theming capabilitiesThorbjørn Lindeijer1-1/+3
* Moved previously hardcoded values for frame size, padding and title bar height to the Skin. * Added support for rendering colored rectangles (used for scroll bar background). * Scroll bar width is now determined by its skin. * Added separate skins for horizontal and vertical scroll bars and horizontal and vertical scroll markers and added a skin for the shortcut box. * Added support for hovered state on window close button.
2025-03-24Define the GUI theme in XMLThorbjørn Lindeijer1-11/+9
Now all images used by the various UI widgets are defined in a `theme.xml`, removing hardcoded requirements on the size of images, borders and sub-images and their locations. The `colors.xml` file was merged into this new file as well. The `<img>` element defines either a plain image, or a 9-scale that is automatically rendered at the size of the widget when any of the `left`, `right`, `top` or `bottom` attributes are given. The `x`, `y`, `width` and `height` attributes determine the sub-rectangle within the image referenced by `src`. `x` and `y` default to 0 and `width` and `height` default to the imge size. The `<state>` element defines in which state its images are used by setting its `selected`, `disabled`, `hovered` or `focused` attributes to either `true` or `false`. Only the first matching state is rendered. The `Text` and `SpeechBubble` classes now use the same skin to draw the bubble, as well as using a newly introduced `BUBBLE_TEXT` color from the theme palette.
2025-03-14Moved widget drawing code into ThemeThorbjørn Lindeijer1-77/+15
This is cleaner overall since now each widget type no longer needs to keep track of its own instances and updating of the GUI alpha. It also introduces a single point from where the GUI theme support can be enhanced. Theme is no longer a singleton, though for now there is a single instance owned by the Gui singleton. Widgets adjusted to delegate their painting to the Theme: * Button * Tab * TextField * CheckBox * RadioButton * Slider * DropDown * ProgressBar * ScrollArea * ResizeGrip * PlayerBox (by subclassing ScrollArea) The Window and Popup widgets already use the theme through the Skin class. They can actually use a different skin per instance, though this feature is only used by the SpeechBubble.
2025-02-26Plugged a few more memory leaksThorbjørn Lindeijer1-14/+3
* DebugWindow and SkillDialog were not deleting their tabs nor their tab widgets. * TabbedArea was not deleting its arrow buttons. * Button was deleting its TextPopup on deletion of the last Button instance, which was wrong because it was also being deleted by the WindowContainer. Also removed some misplaced event forwarding to the TextPopup. TabbedArea is tricky because it does not automatically delete added tabs or their widgets. Tab instances are only deleted when they were added by name. Issues found by Valgrind memory analyzer.
2025-02-26Use ResourceRef for all resource typesThorbjørn Lindeijer1-43/+25
All ResourceManager functions that load resources now return respective ResourceRef values, which helps to make sure resources are properly cleaned up. The Sound class was cleaned up and now also allows SoundEffect resources to be unloaded. The Animation class now keeps its ImageSet loaded only as long as necessary. Previously, SimpleAnimation and ParticleEmitter would keep the ImageSet loaded indefinitely by never decreasing its reference count. Reduced duplicated animation loading code between SimpleAnimation and ParticleEmitter.
2025-01-20Made client config statically typedThorbjørn Lindeijer1-1/+1
This makes accessing the config values much faster, since it no longer needs to do a lookup nor string conversion, which means we could remove some needless copying of the values. Overall it makes it easier to find out where settings are used and it puts the defaults along with the declaration. Options with default values are no longer saved to the config file. This does not include unrecognized options, which are kept around to provide some compatibility with older clients. While most basic options have kept the same name, more complicated settings like window geometry, shortcuts, outfits, etc. now have their own XML elements. Older clients will ignore these and erase them when saving the configuration.
2024-08-04Small code simplification in Button::initThorbjørn Lindeijer1-10/+7
2024-03-12General code cleanupsThorbjørn Lindeijer1-2/+1
* Use default member initializers * Use range-based for loops * Avoid needless pointer references for ShopItem::mDuplicates * Removed type aliases that are only used once or twice * Removed more unused includes * Removed some unused functions * Removed superfluous .c_str() * Rely on default copy and assignment operators for Vector class * Use std::unique_ptr in some places * Removed duplicated mPlayerMoney updating in SellDialog * Removed duplicated Game::handleInput call * Removed unused SDLInput::mMouseInWindow * Removed remnant of manual widget positioning in HelpWindow * Removed superfluous initialization of static pointers
2024-02-13General code cleanupsThorbjørn Lindeijer1-2/+1
* Removing unused includes * Use member initialization * Use range-based for loops * Use nullptr * Removed no longer used aliases * Use override * Don't use else after return * Use '= delete' to remove implicit members * Use std::string::empty instead of comparing to ""
2024-01-29Removed unused includes in various filesThorbjørn Lindeijer1-1/+0
2024-01-29Apply C++11 fixitsThorbjørn Lindeijer1-2/+1
modernize-loop-convert modernize-deprecated-headers
2024-01-26Apply C++11 fixitsThorbjørn Lindeijer1-6/+6
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using
2024-01-24Fixed compilation issues and use of deprecated C++ featuresThorbjørn Lindeijer1-1/+1
* Fixed compiler errors due to dynamic exception specifications * Replace std::auto_ptr with std::unique_ptr * Replace std::mem_fun with std::mem_fn * Prefix for_each with std:: (apparently not needed before) * Just use lambda instead of std::bind2nd * Removed usages of std::unary_function
2012-02-03Changed the setup button at login stage to use the icon.Yohann Ferreira1-3/+5
I also made the button not readjust its size when deleted to avoid a crash. Reviewed-by: Erik Schilling
2012-01-26Updated copyrights to 2012Thorbjørn Lindeijer1-1/+1
2011-11-12Removed hiding of button popup when setting the text to emptyYohann Ferreira1-7/+0
The text is never set to an empty string, especially not while the mouse is over the button. The popup will be updated or hidden by mouseMoved anyway. Reviewed-by: Thorbjorn Lindeijer
2011-11-12Fixed the button popup incorrectly shown when loading the window menu.Yohann Ferreira1-3/+1
This was due to a small logic error when setting the popup text. Reviewed-by: Erik Schilling
2011-09-28Small changes requested by o11c - part 1.Yohann Ferreira1-2/+3
2011-08-11Made the button icon only shown when the icon file is valid.Yohann Ferreira1-6/+7
And falls back to the text based caption otherwise.
2011-08-11Changed the Social button to an image one.Yohann Ferreira1-3/+6
I also made the client able to keep the old behaviour, and i changed the button api to not require the icon frames size as it could easily guess them.
2011-08-11Added textpopup on mouse hovering support to buttons.Yohann Ferreira1-1/+57
I added a use of it to the menu buttons.
2011-06-16Fix the off-by-one error reported in the issue comments.Yohann Ferreira1-2/+1
Trivial fix.
2011-06-16Added image support to the button widgets.Yohann Ferreira1-21/+134
Resolves: Mana-mantis #96. Reviewed-by: Crush. Note that the option to set the image position next to the text is still needed and will be handled in another issue.
2010-08-03Move Theme and UserPalette to the resources folderJared Adams1-1/+1
Reviewed-by: Yohann Ferreira
2010-07-28Centralized configuration default values using the VariableData system.Yohann Ferreira1-2/+2
Please note that I didn't turned all the getValue() call into new ones, simply because I have to have config object initiated which is not forcefully the case the branding file. Resolves: Manasource Mantis #170.
2010-03-12Split Palette into Theme and UserPaletteJared Adams1-2/+2
Themes can now control the colors they use. Colors in the Viewport (being names, particles, etc) can still be changed by the user. Also make ProgressBars more easily colored. DyePalette was made more flexible in the process. Also fixes comparing strings of different lengths insensitively. Reviewed-by: Thorbjørn Lindeijer
2010-03-05Rename SkinLoader to ThemeJared Adams1-3/+3
Also merge the guialpha ConfigListener into Theme. Reviewed-by: Thorbjørn Lindeijer
2010-02-28Make the gui more themeable and distribute two themesJared Adams1-7/+5
The older gray theme and the new wood theme are available as themes. The gray theme needs some new graphics for hilights. Add a theme option for branding and add path/to/branding/data to the PhysFS search path. Reviewed-by: Thorbjørn Lindeijer Reviewed-by: Chuck Miller
2010-02-22Modify copyright headersFreeyorp1-1/+2
2010-02-20License header update for The Mana ClientThorbjørn Lindeijer1-4/+3
2010-02-07Updated Copyright year to 2010!Bertram1-1/+1
Also added the update copyright tool from the Wormux Team. ( And not forgetting credit's due. :P )
2010-01-11Cleanup GUI classesJared Adams1-3/+3
Moved remaining widgets into widgets folder, standardized include order, moved TextRenderer out.
2009-09-02Added a minimum alpha opacity value handle in SkinLoader and made use of it.Bertram1-12/+21
Part 1 of 3 for Mantis #847 Only a few controls follow minimum opacity value at login stage. Part 2 will make all other controls do the same. Part 3 will try to set default gui opacity value as a constant.
2009-08-01makes the colour for buttons and disabled buttons configurableMaximilian Philipps1-1/+4
2009-04-07Moved basic widgets into the gui/widgets directoryBjørn Lindeijer1-0/+181
In an attempt to make the GUI code a little more structured, basic widgets are now put in gui/widgets. Many includes were also cleaned up.