mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-29 15:32:36 +00:00
d403d750f0
Avoid color copies for rendering Draw calls in GUIRenderer::UpdateDrawCallCache, CButton::Draw, CChart::DrawAxes, CDropDown::Draw, CList::DrawList, COList::DrawList, refs #1984,8f4f8e240f,3028551b91,a905fbbc98. Avoid color copies during XML loading in CGUI::Xeromyces_ReadImage, CGUI::Xeromyces_ReadEffects, COList::HandleAdditionalChildren. Add CGUI::HasPreDefinedColor and mark m_PreDefinedColors, CGUI::GetPreDefinedColor, IGUIButtonBehavior::ChooseColor() as const for consistency with the other "databases", refs3028551b91. Mark CGUIColor as NONCOPYABLE to add compiler errors if there is an unexplicit copy, refs3028551b91. Explicit ugly copy in CGUI::Xeromyces_ReadColor and CGUIColor::ParseString. Deregister copying <CGUIColor>GetSetting functions, refs8f4f8e240f. Uses the const ref GetSetting from3dfa23cd25. This was SVN commit r22694.
62 lines
1.7 KiB
C++
62 lines
1.7 KiB
C++
/* Copyright (C) 2019 Wildfire Games.
|
|
* This file is part of 0 A.D.
|
|
*
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef INCLUDED_GUICOLOR
|
|
#define INCLUDED_GUICOLOR
|
|
|
|
#include "graphics/Color.h"
|
|
#include "ps/CStr.h"
|
|
|
|
class CGUI;
|
|
|
|
/**
|
|
* Same as the CColor class, but this one can also parse colors predefined in the GUI page (such as "yellow").
|
|
*/
|
|
struct CGUIColor : CColor
|
|
{
|
|
// Take advantage of compiler warnings if unintentionally copying this
|
|
NONCOPYABLE(CGUIColor);
|
|
|
|
// Defines move semantics so that the structs using the class can use it.
|
|
MOVABLE(CGUIColor);
|
|
|
|
CGUIColor() : CColor() {}
|
|
|
|
CGUIColor(float r, float g, float b, float a) : CColor(r, g, b, a) {}
|
|
|
|
/**
|
|
* Returns this color if it has been set, otherwise the given fallback color.
|
|
*/
|
|
const CGUIColor& operator||(const CGUIColor& fallback) const
|
|
{
|
|
if (*this)
|
|
return *this;
|
|
return fallback;
|
|
}
|
|
|
|
/**
|
|
* Load color depending on current GUI page.
|
|
*/
|
|
bool ParseString(const CGUI* pGUI, const CStr& value, int defaultAlpha = 255);
|
|
|
|
/**
|
|
* Ensure that all users check for predefined colors.
|
|
*/
|
|
bool ParseString(const CStr& value, int defaultAlpha = 255) = delete;
|
|
};
|
|
#endif // INCLUDED_GUICOLOR
|