Skip to content

Commit

Permalink
HaikuDepot: More work on custom TextView
Browse files Browse the repository at this point in the history
 * TextLayout produces some first visible results...
  • Loading branch information
stippi committed Aug 14, 2013
1 parent 156881a commit 0f71004
Show file tree
Hide file tree
Showing 10 changed files with 626 additions and 295 deletions.
1 change: 1 addition & 0 deletions src/apps/haiku-depot/Jamfile
Expand Up @@ -25,6 +25,7 @@ Application HaikuDepot :
support.cpp

TextLayout.cpp
TextStyle.cpp
TextView.cpp

: be translation libcolumnlistview.a libshared.a $(TARGET_LIBSUPC++)
Expand Down
10 changes: 5 additions & 5 deletions src/apps/haiku-depot/PackageInfoView.cpp
Expand Up @@ -22,6 +22,7 @@
#include <StringView.h>

#include "PackageManager.h"
#include "TextView.h"


#undef B_TRANSLATION_CONTEXT
Expand Down Expand Up @@ -733,12 +734,11 @@ class RatingItemView : public BGroupView {
fPackageVersionView->SetFont(&versionFont);
fPackageVersionView->SetHighColor(kLightBlack);

fTextView = new BTextView("rating text");
fTextView = new TextView("rating text");
fTextView->SetViewColor(ViewColor());
fTextView->MakeEditable(false);
fTextView->SetText(rating.Comment());
const float textInset = be_plain_font->Size();
fTextView->SetInsets(0.0f, floorf(textInset / 2), textInset, 0.0f);
// const float textInset = be_plain_font->Size();
// fTextView->SetInsets(0.0f, floorf(textInset / 2), textInset, 0.0f);

BLayoutBuilder::Group<>(this)
.Add(fAvatarView, 0.2f)
Expand All @@ -763,7 +763,7 @@ class RatingItemView : public BGroupView {
RatingView* fRatingView;
BStringView* fRatingLabelView;
BStringView* fPackageVersionView;
BTextView* fTextView;
TextView* fTextView;
};


Expand Down
100 changes: 100 additions & 0 deletions src/apps/haiku-depot/textview/GlyphInfo.h
@@ -0,0 +1,100 @@
/*
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef GLYPH_INFO_H
#define GLYPH_INFO_H

#include "TextStyle.h"


class GlyphInfo {
public:
GlyphInfo()
:
charCode(0),
x(0.0f),
y(0.0f),
advanceX(0.0f),
maxAscend(0.0f),
maxDescend(0.0f),
lineIndex(0),
style()
{
}

GlyphInfo(uint32 charCode, float x, float y, float advanceX,
float maxAscend, float maxDescend, int lineIndex,
const TextStyleRef& style)
:
charCode(charCode),
x(x),
y(y),
advanceX(advanceX),
maxAscend(maxAscend),
maxDescend(maxDescend),
lineIndex(lineIndex),
style(style)
{
}

GlyphInfo(const GlyphInfo& other)
:
charCode(other.charCode),
x(other.x),
y(other.y),
advanceX(other.advanceX),
maxAscend(other.maxAscend),
maxDescend(other.maxDescend),
lineIndex(other.lineIndex),
style(other.style)
{
}

GlyphInfo& operator=(const GlyphInfo& other)
{
charCode = other.charCode;
x = other.x;
y = other.y;
advanceX = other.advanceX;
maxAscend = other.maxAscend;
maxDescend = other.maxDescend;
lineIndex = other.lineIndex;
style = other.style;
return *this;
}

bool operator==(const GlyphInfo& other) const
{
return charCode == other.charCode
&& x == other.x
&& y == other.y
&& advanceX == other.advanceX
&& maxAscend == other.maxAscend
&& maxDescend == other.maxDescend
&& lineIndex == other.lineIndex
&& style == other.style;
}

bool operator!=(const GlyphInfo& other) const
{
return !(*this == other);
}

public:
uint32 charCode;

float x;
float y;
float advanceX;

float maxAscend;
float maxDescend;

int lineIndex;

TextStyleRef style;
};


#endif // GLYPH_INFO_H
80 changes: 80 additions & 0 deletions src/apps/haiku-depot/textview/LineInfo.h
@@ -0,0 +1,80 @@
/*
* Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef LINE_INFO_H
#define LINE_INFO_H

#include "List.h"


class LineInfo {
public:
LineInfo()
:
textOffset(0),
y(0.0f),
height(0.0f),
maxAscent(0.0f),
maxDescent(0.0f)
{
}

LineInfo(int textOffset, float y, float height, float maxAscent,
float maxDescent)
:
textOffset(textOffset),
y(y),
height(height),
maxAscent(maxAscent),
maxDescent(maxDescent)
{
}

LineInfo(const LineInfo& other)
:
textOffset(other.textOffset),
y(other.y),
height(other.height),
maxAscent(other.maxAscent),
maxDescent(other.maxDescent)
{
}

LineInfo& operator=(const LineInfo& other)
{
textOffset = other.textOffset;
y = other.y;
height = other.height;
maxAscent = other.maxAscent;
maxDescent = other.maxDescent;
return *this;
}

bool operator==(const LineInfo& other) const
{
return textOffset == other.textOffset
&& y == other.y
&& height == other.height
&& maxAscent == other.maxAscent
&& maxDescent == other.maxDescent;
}

bool operator!=(const LineInfo& other) const
{
return !(*this == other);
}

public:
int textOffset;
float y;
float height;
float maxAscent;
float maxDescent;
};


typedef List<LineInfo, false> LineInfoList;


#endif // LINE_INFO_H

0 comments on commit 0f71004

Please sign in to comment.