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@gmail.com> Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
This commit is contained in:
parent
4c1d9cf74e
commit
fe55edcaf4
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user