MACGUI: const for some methods

This commit is contained in:
Martin Gerhardy 2021-07-18 14:14:17 +02:00 committed by Eugene Sandulenko
parent b73889d2e0
commit 37de1b3146
4 changed files with 22 additions and 17 deletions

View File

@ -89,7 +89,7 @@ void MacWindow::setActive(bool active) {
_borderIsDirty = true;
}
bool MacWindow::isActive() { return _active; }
bool MacWindow::isActive() const { return _active; }
void MacWindow::resize(int w, int h, bool inner) {
if (_composeSurface->w == w && _composeSurface->h == h)
@ -178,7 +178,7 @@ void MacWindow::blit(ManagedSurface *g, Common::Rect &dest) {
g->transBlitFrom(*_composeSurface, _composeSurface->getBounds(), dest, transcolor);
}
uint32 MacWindow::getBorderFlags() {
uint32 MacWindow::getBorderFlags() const {
uint32 flags = 0;
if (_active)
flags |= kWindowBorderActive;
@ -343,7 +343,7 @@ void MacWindow::fillRect(ManagedSurface *g, int x, int y, int w, int h, int colo
g->fillRect(r, color);
}
WindowClick MacWindow::isInBorder(int x, int y) {
WindowClick MacWindow::isInBorder(int x, int y) const {
if (_innerDims.contains(x, y))
return kBorderInner;
@ -360,7 +360,7 @@ WindowClick MacWindow::isInBorder(int x, int y) {
return kBorderBorder;
}
bool MacWindow::isInCloseButton(int x, int y) {
bool MacWindow::isInCloseButton(int x, int y) const {
int bLeft = kBorderWidth;
int bTop = kBorderWidth;
if (_macBorder.hasOffsets()) {
@ -370,7 +370,7 @@ bool MacWindow::isInCloseButton(int x, int y) {
return (x >= _innerDims.left - bLeft && x < _innerDims.left && y >= _innerDims.top - bTop && y < _innerDims.top);
}
bool MacWindow::isInResizeButton(int x, int y) {
bool MacWindow::isInResizeButton(int x, int y) const {
int bRight = kBorderWidth;
int bBottom = kBorderWidth;
if (_macBorder.hasOffsets()) {
@ -380,7 +380,7 @@ bool MacWindow::isInResizeButton(int x, int y) {
return (x >= _innerDims.right && x < _innerDims.right + bRight && y >= _innerDims.bottom && y < _innerDims.bottom + bBottom);
}
WindowClick MacWindow::isInScroll(int x, int y) {
WindowClick MacWindow::isInScroll(int x, int y) const {
int bTop = kBorderWidth;
int bRight = kBorderWidth;
int bBottom = kBorderWidth;

View File

@ -263,7 +263,7 @@ public:
* Accessor to determine whether a window is active.
* @return True if the window is active.
*/
bool isActive();
bool isActive() const;
/**
* Mutator to change the title of the window.
@ -274,7 +274,7 @@ public:
* Accessor to get the title of the window.
* @return Title.
*/
Common::String getTitle() { return _title; };
const Common::String &getTitle() const { return _title; };
/**
* Highlight the target part of the window.
@ -331,14 +331,14 @@ public:
* Accessor to get the border type.
* @return Border type.
*/
int getBorderType() { return _borderType; };
int getBorderType() const { return _borderType; };
/**
* We should call this method whenever we need border flags
* don't calc border flags yourself
* @return Border flags
*/
uint32 getBorderFlags();
uint32 getBorderFlags() const;
void addDirtyRect(const Common::Rect &r);
void markAllDirty();
@ -360,14 +360,14 @@ private:
void updateInnerDims();
void updateOuterDims();
bool isInCloseButton(int x, int y);
bool isInResizeButton(int x, int y);
WindowClick isInScroll(int x, int y);
bool isInCloseButton(int x, int y) const;
bool isInResizeButton(int x, int y) const;
WindowClick isInScroll(int x, int y) const;
protected:
void drawBorder();
WindowClick isInBorder(int x, int y);
BorderOffsets getBorderOffsets() { return _macBorder.getOffset(); }
WindowClick isInBorder(int x, int y) const;
BorderOffsets getBorderOffsets() const { return _macBorder.getOffset(); }
protected:
ManagedSurface _borderSurface;

View File

@ -110,7 +110,7 @@ void MacWindowBorder::addBorder(TransparentSurface *source, uint32 flags, int ti
setOffsets(_border[flags]->getPadding());
}
bool MacWindowBorder::hasOffsets() {
bool MacWindowBorder::hasOffsets() const {
return _borderOffsets.left > -1 && _borderOffsets.right > -1
&& _borderOffsets.top > -1 && _borderOffsets.bottom > -1;
}
@ -137,6 +137,10 @@ BorderOffsets &MacWindowBorder::getOffset() {
return _borderOffsets;
}
const BorderOffsets &MacWindowBorder::getOffset() const {
return _borderOffsets;
}
void MacWindowBorder::setTitle(const Common::String& title, int width, MacWindowManager *wm) {
_title = title;
const Graphics::Font *font = wm->_fontMan->getFont(Graphics::MacFont(kMacFontChicago, 12));

View File

@ -89,7 +89,7 @@ public:
* Accessor function for the custom offsets.
* @return True if custom offsets have been indicated (setOffsets has been called previously).
*/
bool hasOffsets();
bool hasOffsets() const;
/**
* Mutator method to indicate the custom border offsets.
@ -115,6 +115,7 @@ public:
* @return The desired offset in pixels.
*/
BorderOffsets &getOffset();
const BorderOffsets &getOffset() const;
/**
* Blit the desired border (active or inactive) into a destination surface.