From 1b041ecccfbe44a4f50ffc086e3996e2b6eea4f7 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 8 Feb 2024 22:35:09 +0100 Subject: C++11: Use default member initializers This patch is not exhaustive. --- src/gui/widgets/browserbox.cpp | 27 ++++++++++----------------- src/gui/widgets/browserbox.h | 24 ++++++++++++------------ src/gui/widgets/layout.h | 4 ++-- 3 files changed, 24 insertions(+), 31 deletions(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 2fe3b5b1..bc424962 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -36,19 +36,8 @@ #include BrowserBox::BrowserBox(unsigned int mode, bool opaque): - gcn::Widget(), - mMode(mode), mHighMode(UNDERLINE | BACKGROUND), - mShadows(false), - mOutline(false), - mOpaque(opaque), - mUseLinksAndUserColors(true), - mSelectedLink(-1), - mMaxRows(0), - mHeight(0), - mWidth(0), - mYStart(0), - mUpdateTime(-1), - mAlwaysUpdate(true) + mMode(mode), + mOpaque(opaque) { setFocusable(true); addMouseListener(this); @@ -58,7 +47,7 @@ BrowserBox::~BrowserBox() { } -void BrowserBox::setLinkHandler(LinkHandler* linkHandler) +void BrowserBox::setLinkHandler(LinkHandler *linkHandler) { mLinkHandler = linkHandler; } @@ -244,20 +233,24 @@ void BrowserBox::clearRows() struct MouseOverLink { - MouseOverLink(int x, int y) : mX(x), mY(y) - { } + MouseOverLink(int x, int y) + : mX(x), mY(y) + {} bool operator() (BrowserLink &link) const { return (mX >= link.x1 && mX < link.x2 && mY >= link.y1 && mY < link.y2); } + int mX, mY; }; void BrowserBox::mousePressed(gcn::MouseEvent &event) { - if (!mLinkHandler) return; + if (!mLinkHandler) + return; + auto i = find_if(mLinks.begin(), mLinks.end(), MouseOverLink(event.getX(), event.getY())); diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 5f29e72a..6d09f77b 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -198,20 +198,20 @@ class BrowserBox : public gcn::Widget, using LinkIterator = Links::iterator; Links mLinks; - LinkHandler *mLinkHandler; + LinkHandler *mLinkHandler = nullptr; unsigned int mMode; - unsigned int mHighMode; - bool mShadows; - bool mOutline; + unsigned int mHighMode = UNDERLINE | BACKGROUND; + bool mShadows = false; + bool mOutline = false; bool mOpaque; - bool mUseLinksAndUserColors; - int mSelectedLink; - unsigned int mMaxRows; - int mHeight; - int mWidth; - int mYStart; - int mUpdateTime; - bool mAlwaysUpdate; + bool mUseLinksAndUserColors = true; + int mSelectedLink = -1; + unsigned int mMaxRows = 0; + int mHeight = 0; + int mWidth = 0; + int mYStart = 0; + int mUpdateTime = -1; + bool mAlwaysUpdate = true; }; #endif diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 8fd7a405..1c6faf89 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -167,7 +167,7 @@ class LayoutCell LEFT, RIGHT, CENTER, FILL }; - LayoutCell(): mType(NONE) {} + LayoutCell() = default; ~LayoutCell(); @@ -263,7 +263,7 @@ class LayoutCell char mExtent[2]; char mAlign[2]; char mNbFill[2]; - char mType; + char mType = NONE; }; /** -- cgit v1.2.3-70-g09d2