Changeset View
Changeset View
Standalone View
Standalone View
source/gui/IGUIObject.h
/* Copyright (C) 2016 Wildfire Games. | /* Copyright (C) 2017 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 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 | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | public: | ||||
//@{ | //@{ | ||||
/// Get object name, name is unique | /// Get object name, name is unique | ||||
const CStr& GetName() const { return m_Name; } | const CStr& GetName() const { return m_Name; } | ||||
/// Get object name | /// Get object name | ||||
void SetName(const CStr& Name) { m_Name = Name; } | void SetName(const CStr& Name) { m_Name = Name; } | ||||
/// Get object size | |||||
const CRect& GetCachedSize() const { return m_CachedActualSize; } | |||||
vladislavbelov: This should be:
```lang=cpp
const CRect& GetSize() const { ... }
```
Since it doesn't modify… | |||||
// Get Presentable name. | // Get Presentable name. | ||||
// Will change all internally set names to something like "<unnamed object>" | // Will change all internally set names to something like "<unnamed object>" | ||||
CStr GetPresentableName() const; | CStr GetPresentableName() const; | ||||
/** | /** | ||||
* Adds object and its children to the map, it's name being the | * Adds object and its children to the map, it's name being the | ||||
* first part, and the second being itself. | * first part, and the second being itself. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | protected: | ||||
/** | /** | ||||
* Loads a style. | * Loads a style. | ||||
* | * | ||||
* @param Style The style object. | * @param Style The style object. | ||||
*/ | */ | ||||
void LoadStyle(const SGUIStyle& Style); | void LoadStyle(const SGUIStyle& Style); | ||||
/** | |||||
* Returns not the Z value, but the actual buffered Z value, i.e. if it's | |||||
* defined relative, then it will check its parent's Z value and add | |||||
* the relativity. | |||||
* | |||||
* @return Actual Z value on the screen. | |||||
*/ | |||||
virtual float GetBufferedZ() const; | |||||
void SetGUI(CGUI* const& pGUI); | void SetGUI(CGUI* const& pGUI); | ||||
/** | /** | ||||
* Set parent of this object | * Set parent of this object | ||||
*/ | */ | ||||
void SetParent(IGUIObject* pParent) { m_pParent = pParent; } | void SetParent(IGUIObject* pParent) { m_pParent = pParent; } | ||||
/** | /** | ||||
Show All 9 Lines | public: | ||||
CGUI* GetGUI() { return m_pGUI; } | CGUI* GetGUI() { return m_pGUI; } | ||||
const CGUI* GetGUI() const { return m_pGUI; } | const CGUI* GetGUI() const { return m_pGUI; } | ||||
/** | /** | ||||
* Take focus! | * Take focus! | ||||
*/ | */ | ||||
void SetFocus(); | void SetFocus(); | ||||
/** | |||||
* Returns not the Z value, but the actual buffered Z value, i.e. if it's | |||||
* defined relative, then it will check its parent's Z value and add | |||||
* the relativity. | |||||
* | |||||
* @return Actual Z value on the screen. | |||||
*/ | |||||
virtual float GetBufferedZ() const; | |||||
protected: | protected: | ||||
/** | /** | ||||
* Check if object is focused. | * Check if object is focused. | ||||
*/ | */ | ||||
bool IsFocused() const; | bool IsFocused() const; | ||||
/** | /** | ||||
* <b>NOTE!</b> This will not just return m_pParent, when that is | * <b>NOTE!</b> This will not just return m_pParent, when that is | ||||
Show All 27 Lines | protected: | ||||
/** | /** | ||||
* Cached size, real size m_Size is actually dependent on resolution | * Cached size, real size m_Size is actually dependent on resolution | ||||
* and can have different *real* outcomes, this is the real outcome | * and can have different *real* outcomes, this is the real outcome | ||||
* cached to avoid slow calculations in real time. | * cached to avoid slow calculations in real time. | ||||
*/ | */ | ||||
CRect m_CachedActualSize; | CRect m_CachedActualSize; | ||||
/** | /** | ||||
* Like `m_CachedActualSize` above, except this stores a cached | |||||
* value of the combined size of all the children. | |||||
*/ | |||||
CRect m_CachedContentSize; | |||||
/** | |||||
* Send event to this GUI object (HandleMessage and ScriptEvent) | * Send event to this GUI object (HandleMessage and ScriptEvent) | ||||
* | * | ||||
* @param type Type of GUI message to be handled | * @param type Type of GUI message to be handled | ||||
* @param EventName String representation of event name | * @param EventName String representation of event name | ||||
* @return IN_HANDLED if event was handled, or IN_PASS if skipped | * @return IN_HANDLED if event was handled, or IN_PASS if skipped | ||||
*/ | */ | ||||
InReaction SendEvent(EGUIMessageType type, const CStr& EventName); | InReaction SendEvent(EGUIMessageType type, const CStr& EventName); | ||||
▲ Show 20 Lines • Show All 142 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
This should be:
Since it doesn't modify something in the object.
Also are sure that it always returns the right value? Because it returns the cached size. Wouldn't be a situation when the cache isn't updated, but someone calls it.
At least it could be called GetCachedSize(), or it could have some checks.