summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-06-21 02:23:37 +0300
committerAndrei Karas <akaras@inbox.ru>2017-06-21 02:23:37 +0300
commitb5c71a87d2a0c2c6981331d5958b474162934532 (patch)
tree7856fc9f506476f302755ba185a08dadd2d35516 /src/gui/widgets
parentce2eb9e56d8c54fd26023e073cb29b3bb3b60de2 (diff)
downloadmv-b5c71a87d2a0c2c6981331d5958b474162934532.tar.gz
mv-b5c71a87d2a0c2c6981331d5958b474162934532.tar.bz2
mv-b5c71a87d2a0c2c6981331d5958b474162934532.tar.xz
mv-b5c71a87d2a0c2c6981331d5958b474162934532.zip
Remove browserboxmode.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/browserbox.cpp121
-rw-r--r--src/gui/widgets/browserbox.h3
-rw-r--r--src/gui/widgets/browserbox_unittest.cc1
-rw-r--r--src/gui/widgets/tabs/chat/chattab.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_colors.cpp2
5 files changed, 45 insertions, 84 deletions
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 486ad9ebd..592283910 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -60,7 +60,6 @@ int BrowserBox::mInstances = 0;
mColors[1][ColorName::color] = getThemeColor(ThemeColorId::color##_OUTLINE)
BrowserBox::BrowserBox(const Widget2 *const widget,
- const BrowserBoxModeT mode,
const Opaque opaque,
const std::string &skin) :
Widget(widget),
@@ -72,7 +71,6 @@ BrowserBox::BrowserBox(const Widget2 *const widget,
mLinks(),
mLinkHandler(nullptr),
mSkin(nullptr),
- mMode(mode),
mHighlightMode(0),
mSelectedLink(-1),
mMaxRows(0),
@@ -283,87 +281,58 @@ void BrowserBox::addRow(const std::string &row, const bool atTop)
}
}
- // Auto size mode
- if (mMode == BrowserBoxMode::AUTO_SIZE)
- {
- std::string plain = newRow;
- // workaround if used only one string started from bold
- // width for this string can be calculated wrong
- // this workaround fix width if string start from bold sign
- const bool startBold = (plain.find("##B") == 0);
- for (idx1 = plain.find("##");
- idx1 != std::string::npos;
- idx1 = plain.find("##"))
- {
- plain.erase(idx1, 3);
- }
-
- // Adjust the BrowserBox size
- const int w = startBold ?
- boldFont->getWidth(plain) : font->getWidth(plain) + 2 * mPadding;
- if (w > getWidth())
- setWidth(w);
- }
-
const int fontHeight = font->getHeight();
- if (mMode == BrowserBoxMode::AUTO_WRAP)
+ unsigned int y = 0;
+ unsigned int nextChar;
+ const char *const hyphen = "~";
+ const unsigned int hyphenWidth = CAST_U32(
+ font->getWidth(hyphen));
+ unsigned int x = 0;
+
+ FOR_EACH (TextRowCIter, i, mTextRows)
{
- unsigned int y = 0;
- unsigned int nextChar;
- const char *const hyphen = "~";
- const unsigned int hyphenWidth = CAST_U32(
- font->getWidth(hyphen));
- unsigned int x = 0;
-
- FOR_EACH (TextRowCIter, i, mTextRows)
+ std::string tempRow = *i;
+ for (uint32_t j = 0, sz = CAST_U32(tempRow.size());
+ j < sz;
+ j++)
{
- std::string tempRow = *i;
- for (uint32_t j = 0, sz = CAST_U32(tempRow.size());
- j < sz;
- j++)
- {
- const std::string character = tempRow.substr(j, 1);
- x += CAST_U32(font->getWidth(character));
- nextChar = j + 1;
+ const std::string character = tempRow.substr(j, 1);
+ x += CAST_U32(font->getWidth(character));
+ nextChar = j + 1;
- // Wraping between words (at blank spaces)
- if (nextChar < sz && tempRow.at(nextChar) == ' ')
- {
- int nextSpacePos = CAST_U32(
- tempRow.find(' ', (nextChar + 1)));
- if (nextSpacePos <= 0)
- nextSpacePos = CAST_U32(sz) - 1U;
-
- const unsigned int nextWordWidth =
- CAST_U32(font->getWidth(
- tempRow.substr(nextChar,
- (CAST_U32(nextSpacePos) - nextChar))));
-
- if ((x + nextWordWidth + 10)
- > CAST_U32(getWidth()))
- {
- x = mNewLinePadding; // Ident in new line
- y += 1;
- j ++;
- }
- }
- // Wrapping looong lines (brutal force)
- else if ((x + 2 * hyphenWidth)
- > CAST_U32(getWidth()))
+ // Wraping between words (at blank spaces)
+ if (nextChar < sz && tempRow.at(nextChar) == ' ')
+ {
+ int nextSpacePos = CAST_U32(
+ tempRow.find(' ', (nextChar + 1)));
+ if (nextSpacePos <= 0)
+ nextSpacePos = CAST_U32(sz) - 1U;
+
+ const unsigned int nextWordWidth =
+ CAST_U32(font->getWidth(
+ tempRow.substr(nextChar,
+ (CAST_U32(nextSpacePos) - nextChar))));
+
+ if ((x + nextWordWidth + 10)
+ > CAST_U32(getWidth()))
{
x = mNewLinePadding; // Ident in new line
y += 1;
+ j ++;
}
}
+ // Wrapping looong lines (brutal force)
+ else if ((x + 2 * hyphenWidth)
+ > CAST_U32(getWidth()))
+ {
+ x = mNewLinePadding; // Ident in new line
+ y += 1;
+ }
}
-
- setHeight(fontHeight * (CAST_S32(
- CAST_U32(mTextRows.size()) + y)));
- }
- else
- {
- setHeight(fontHeight * CAST_S32(mTextRows.size()));
}
+
+ setHeight(fontHeight * (CAST_S32(
+ CAST_U32(mTextRows.size()) + y)));
mUpdateTime = 0;
updateHeight();
}
@@ -789,8 +758,7 @@ int BrowserBox::calcHeight()
width = font->getWidth(part);
// Auto wrap mode
- if (mMode == BrowserBoxMode::AUTO_WRAP &&
- wWidth > 0 &&
+ if (wWidth > 0 &&
width > 0 &&
(x + CAST_U32(width) + 10) > wWidth)
{
@@ -856,11 +824,8 @@ int BrowserBox::calcHeight()
else
width = font->getWidth(part);
- if (mMode == BrowserBoxMode::AUTO_WRAP &&
- (width == 0 && !processed))
- {
+ if (width == 0 && !processed)
break;
- }
x += CAST_U32(width);
if (x > mDataWidth)
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index 60635c8de..04cff5aff 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -26,7 +26,6 @@
#include "enums/simpletypes/opaque.h"
-#include "enums/gui/browserboxmode.h"
#include "enums/gui/colorname.h"
#include "gui/browserlink.h"
@@ -54,7 +53,6 @@ class BrowserBox final : public Widget,
* Constructor.
*/
BrowserBox(const Widget2 *const widget,
- const BrowserBoxModeT mode,
const Opaque opaque,
const std::string &skin);
@@ -180,7 +178,6 @@ class BrowserBox final : public Widget,
LinkHandler *mLinkHandler;
Skin *mSkin;
- BrowserBoxModeT mMode;
unsigned int mHighlightMode;
int mSelectedLink;
unsigned int mMaxRows;
diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc
index f151e1524..e32eaa68a 100644
--- a/src/gui/widgets/browserbox_unittest.cc
+++ b/src/gui/widgets/browserbox_unittest.cc
@@ -93,7 +93,6 @@ TEST_CASE("BrowserBox tests", "browserbox")
Widget::setGlobalFont(new Font("/usr/share/fonts/truetype/"
"ttf-dejavu/DejaVuSans-Oblique.ttf", 18));
BrowserBox *const box = new BrowserBox(nullptr,
- BrowserBoxMode::AUTO_WRAP,
Opaque_true,
"");
box->setWidth(100);
diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp
index 91df77ded..358fd8c44 100644
--- a/src/gui/widgets/tabs/chat/chattab.cpp
+++ b/src/gui/widgets/tabs/chat/chattab.cpp
@@ -69,7 +69,7 @@ ChatTab::ChatTab(const Widget2 *const widget,
const std::string &logName,
const ChatTabTypeT &type) :
Tab(widget),
- mTextOutput(new BrowserBox(this, BrowserBoxMode::AUTO_WRAP, Opaque_true,
+ mTextOutput(new BrowserBox(this, Opaque_true,
"browserbox.xml")),
mScrollArea(new ScrollArea(this, mTextOutput, Opaque_false)),
mChannelName(channel),
diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp
index f4efb2832..4f2b35113 100644
--- a/src/gui/widgets/tabs/setup_colors.cpp
+++ b/src/gui/widgets/tabs/setup_colors.cpp
@@ -55,7 +55,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) :
mColorBox(CREATEWIDGETR(ListBox, this, userPalette, "")),
mScroll(new ScrollArea(this, mColorBox,
Opaque_true, "setup_colors_background.xml")),
- mPreview(new BrowserBox(this, BrowserBoxMode::AUTO_WRAP, Opaque_true,
+ mPreview(new BrowserBox(this, Opaque_true,
"browserbox.xml")),
mTextPreview(new TextPreview(this, gettext(rawmsg))),
mPreviewBox(new ScrollArea(this, mPreview, Opaque_true,