aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Cache.cpp10
-rw-r--r--src/Chatbar.cpp2
-rw-r--r--src/MessageBoard.cpp2
-rw-r--r--src/Text.cpp10
-rw-r--r--src/WebPagePreview.cpp5
5 files changed, 21 insertions, 8 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp
index 15af6e7..cf1510a 100644
--- a/src/Cache.cpp
+++ b/src/Cache.cpp
@@ -126,6 +126,7 @@ namespace dchat
fileContent = getFileContent(filepath);
sf::String webPageTitle;
+ sf::String webPageDescription;
bool foundHtmlContent = false;
preview_state state;
preview_init(&state);
@@ -160,11 +161,12 @@ namespace dchat
else if(state.step_result == PREVIEW_FOUND_TITLE)
{
foundHtmlContent = true;
- webPageTitle = sf::String::fromUtf8(state.title, state.title + state.title_length);
+ webPageTitle = sf::String::fromUtf8(state.meta_content, state.meta_content + state.meta_content_length);
}
- else if(state.step_result == PREVIEW_FOUND_PARAGRAPH)
+ else if(state.step_result == PREVIEW_FOUND_DESCRIPTION)
{
foundHtmlContent = true;
+ webPageDescription = sf::String::fromUtf8(state.meta_content, state.meta_content + state.meta_content_length);
}
} while(offset < fileContent.size);
@@ -173,8 +175,8 @@ namespace dchat
if(foundHtmlContent)
{
- // TODO: Use move semantics for webPageTitle when SFML supports it
- WebPagePreview *webPagePreview = new WebPagePreview(webPageTitle);
+ // TODO: Use move semantics for webPageTitle and webPageDescription when SFML supports it
+ WebPagePreview *webPagePreview = new WebPagePreview(webPageTitle, webPageDescription);
return { webPagePreview, ContentByUrlResult::Type::CACHED };
}
}
diff --git a/src/Chatbar.cpp b/src/Chatbar.cpp
index 5f17c28..bd510f7 100644
--- a/src/Chatbar.cpp
+++ b/src/Chatbar.cpp
@@ -15,7 +15,7 @@ using namespace std;
namespace dchat
{
- const float FONT_SIZE = 20;
+ const float FONT_SIZE = 18.0f;
const float BOX_PADDING_X = 15.0f;
const float BOX_PADDING_Y = 5.0f;
const int BLINK_TIME_VISIBLE_MS = 500;
diff --git a/src/MessageBoard.cpp b/src/MessageBoard.cpp
index bc53ae3..8e1525f 100644
--- a/src/MessageBoard.cpp
+++ b/src/MessageBoard.cpp
@@ -215,7 +215,7 @@ namespace dchat
}
// No need to perform culling here, that is done in @Text draw function
- message->text.setCharacterSize(18 * Settings::getScaling());
+ message->text.setCharacterSize(18.0f * Settings::getScaling());
message->text.setMaxWidth(backgroundSize.x - (AVATAR_DIAMETER + AVATAR_PADDING_SIDE) * Settings::getScaling());
message->text.setPosition(sf::Vector2f(floor(position.x + (AVATAR_DIAMETER + AVATAR_PADDING_SIDE) * Settings::getScaling()), floor(position.y)));
message->text.setLineSpacing(LINE_SPACING);
diff --git a/src/Text.cpp b/src/Text.cpp
index 5191ca5..7503d61 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -845,6 +845,7 @@ namespace dchat
}
*/
+
states.transform.translate(pos);
states.texture = &font->getTexture(characterSize);
target.draw(vertices, states);
@@ -951,6 +952,15 @@ namespace dchat
contentByUrlResult.webPagePreview->title.setLineSpacing(0.0f);
contentByUrlResult.webPagePreview->title.setFillColor(URL_COLOR);
contentByUrlResult.webPagePreview->title.draw(target, cache);
+
+ pos.y += contentByUrlResult.webPagePreview->title.getHeight();
+
+ contentByUrlResult.webPagePreview->description.setCharacterSize(characterSize);
+ contentByUrlResult.webPagePreview->description.setMaxWidth(previewWidth);
+ contentByUrlResult.webPagePreview->description.setPosition(pos);
+ contentByUrlResult.webPagePreview->description.setLineSpacing(0.0f);
+ contentByUrlResult.webPagePreview->description.setFillColor(color);
+ contentByUrlResult.webPagePreview->description.draw(target, cache);
break;
}
}
diff --git a/src/WebPagePreview.cpp b/src/WebPagePreview.cpp
index 0d23285..3922e73 100644
--- a/src/WebPagePreview.cpp
+++ b/src/WebPagePreview.cpp
@@ -3,8 +3,9 @@
namespace dchat
{
- WebPagePreview::WebPagePreview(const sf::String &_title) :
- title(_title, ResourceCache::getFont("fonts/Roboto-Regular.ttf"), 10, 0)
+ WebPagePreview::WebPagePreview(const sf::String &_title, const sf::String &_description) :
+ title(_title, ResourceCache::getFont("fonts/Roboto-Regular.ttf"), 10, 0),
+ description(_description, ResourceCache::getFont("fonts/Roboto-Regular.ttf"), 10, 0)
{
}