hrev52707 adds 1 changeset to branch 'master'
old head: 4c1d9cf74e1c1706922e5b5795e788fb14fe81c9
new head: fe55edcaf462a1c868cc8d1bac1a57370890de34
overview:
https://git.haiku-os.org/haiku/log/?qt=range&q=fe55edcaf462+%5E4c1d9cf74e1c
----------------------------------------------------------------------------
fe55edcaf462: Terminal: Font width can be a fractional value, so we need to use
a float.
Adapt other code accordingly. Minimum changes to fix ticket #11478
In theory also font height could be fractional, so we might need to
review other parts of the code.
Change-Id: Idbdbe38193ca5a32b3d09c7cf9accfc917760cae
Reviewed-on: https://review.haiku-os.org/821
Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>
Reviewed-by: Stephan Aßmus <superstippi@xxxxxx>
[ JackBurton79 <stefano.ceccherini@xxxxxxxxx> ]
----------------------------------------------------------------------------
Revision: hrev52707
Commit: fe55edcaf462a1c868cc8d1bac1a57370890de34
URL: https://git.haiku-os.org/haiku/commit/?id=fe55edcaf462
Author: JackBurton79 <stefano.ceccherini@xxxxxxxxx>
Date: Thu Jan 3 20:43:05 2019 UTC
Committer: Stephan Aßmus <superstippi@xxxxxx>
Commit-Date: Thu Jan 3 21:27:27 2019 UTC
Ticket: https://dev.haiku-os.org/ticket/11478
----------------------------------------------------------------------------
3 files changed, 17 insertions(+), 17 deletions(-)
src/apps/terminal/TermView.cpp | 24 ++++++++++++------------
src/apps/terminal/TermView.h | 6 +++---
src/apps/terminal/TermWindow.cpp | 4 ++--
----------------------------------------------------------------------------
diff --git a/src/apps/terminal/TermView.cpp b/src/apps/terminal/TermView.cpp
index 46b0b5a51e..745f920b6d 100644
--- a/src/apps/terminal/TermView.cpp
+++ b/src/apps/terminal/TermView.cpp
@@ -545,7 +545,7 @@ TermView::TerminalName() const
//! Get width and height for terminal font
void
-TermView::GetFontSize(int* _width, int* _height)
+TermView::GetFontSize(float* _width, float* _height)
{
*_width = fFontWidth;
*_height = fFontHeight;
@@ -631,8 +631,8 @@ void
TermView::GetTermSizeFromRect(const BRect &rect, int *_rows,
int *_columns)
{
- int columns = (rect.IntegerWidth() + 1) / fFontWidth;
- int rows = (rect.IntegerHeight() + 1) / fFontHeight;
+ int columns = int((rect.IntegerWidth() + 1) / fFontWidth);
+ int rows = int((rect.IntegerHeight() + 1) / fFontHeight);
if (_rows)
*_rows = rows;
@@ -738,7 +738,7 @@ TermView::GetTermFont(BFont *font) const
void
TermView::SetTermFont(const BFont *font)
{
- int halfWidth = 0;
+ float halfWidth = 0;
fHalfFont = font;
fBoldFont = font;
@@ -752,7 +752,7 @@ TermView::SetTermFont(const BFont *font)
for (int c = 0x20; c <= 0x7e; c++) {
char buf[4];
sprintf(buf, "%c", c);
- int tmpWidth = (int)fHalfFont.StringWidth(buf);
+ float tmpWidth = fHalfFont.StringWidth(buf);
if (tmpWidth > halfWidth)
halfWidth = tmpWidth;
}
@@ -958,7 +958,7 @@ TermView::_Deactivate()
//! Draw part of a line in the given view.
void
-TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr, char *buf,
+TermView::_DrawLinePart(float x1, float y1, uint32 attr, char *buf,
int32 width, Highlight* highlight, bool cursor, BView *inView)
{
if (highlight != NULL)
@@ -968,8 +968,8 @@ TermView::_DrawLinePart(int32 x1, int32 y1, uint32 attr,
char *buf,
? &fBoldFont : &fHalfFont);
// Set pen point
- int x2 = x1 + fFontWidth * width;
- int y2 = y1 + fFontHeight;
+ float x2 = x1 + fFontWidth * width;
+ float y2 = y1 + fFontHeight;
rgb_color rgb_fore = fTextForeColor;
rgb_color rgb_back = fTextBackColor;
@@ -1238,8 +1238,8 @@ TermView::DetachedFromWindow()
void
TermView::Draw(BRect updateRect)
{
- int32 x1 = (int32)updateRect.left / fFontWidth;
- int32 x2 = std::min((int)updateRect.right / fFontWidth, fColumns - 1);
+ int32 x1 = (int32)(updateRect.left / fFontWidth);
+ int32 x2 = std::min((int)(updateRect.right / fFontWidth), fColumns - 1);
int32 firstVisible = _LineAt(0);
int32 y1 = _LineAt(updateRect.top);
@@ -1444,8 +1444,8 @@ void
TermView::FrameResized(float width, float height)
{
//debug_printf("TermView::FrameResized(%f, %f)\n", width, height);
- int32 columns = ((int32)width + 1) / fFontWidth;
- int32 rows = ((int32)height + 1) / fFontHeight;
+ int32 columns = (int32)((width + 1) / fFontWidth);
+ int32 rows = (int32)((height + 1) / fFontHeight);
if (columns == fColumns && rows == fRows)
return;
diff --git a/src/apps/terminal/TermView.h b/src/apps/terminal/TermView.h
index 88006077b2..364682342a 100644
--- a/src/apps/terminal/TermView.h
+++ b/src/apps/terminal/TermView.h
@@ -76,7 +76,7 @@ public:
void GetTermFont(BFont*
font) const;
void SetTermFont(const
BFont* font);
- void GetFontSize(int* width,
int* height);
+ void GetFontSize(float*
width, float* height);
int Rows() const;
int Columns() const;
BRect SetTermSize(int rows,
int cols,
@@ -194,7 +194,7 @@ private:
void _Activate();
void _Deactivate();
- void _DrawLinePart(int32 x1,
int32 y1, uint32 attr,
+ void _DrawLinePart(float x1,
float y1, uint32 attr,
char*
buffer, int32 width,
Highlight* highlight, bool cursor,
BView*
inView);
@@ -271,7 +271,7 @@ private:
// Font and Width
BFont fHalfFont;
BFont fBoldFont;
- int fFontWidth;
+ float fFontWidth;
int fFontHeight;
int fFontAscent;
struct escapement_delta fEscapement;
diff --git a/src/apps/terminal/TermWindow.cpp b/src/apps/terminal/TermWindow.cpp
index 0791e77c8c..cf9cc8119e 100644
--- a/src/apps/terminal/TermWindow.cpp
+++ b/src/apps/terminal/TermWindow.cpp
@@ -1267,7 +1267,7 @@ TermWindow::_AddTab(Arguments* args, const BString&
currentDirectory)
_GetPreferredFont(font);
view->SetTermFont(&font);
- int width, height;
+ float width, height;
view->GetFontSize(&width, &height);
float minimumHeight = -1;
@@ -1648,7 +1648,7 @@ TermWindow::NextTermView(TermView* view)
void
TermWindow::_ResizeView(TermView *view)
{
- int fontWidth, fontHeight;
+ float fontWidth, fontHeight;
view->GetFontSize(&fontWidth, &fontHeight);
float minimumHeight = -1;