mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
CtrCore: Cocoa: Rotated text
git-svn-id: svn://ultimatepp.org/upp/trunk@12187 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
1e8320f379
commit
c17038f51c
2 changed files with 34 additions and 33 deletions
|
|
@ -7,17 +7,18 @@
|
|||
|
||||
namespace Upp {
|
||||
|
||||
CTFontRef CT_Font0(Font fnt, bool& synth)
|
||||
CTFontRef CT_Font0(Font fnt, int angle, bool& synth)
|
||||
{
|
||||
CFRef<CFStringRef> s = CFStringCreateWithCString(NULL, ~fnt.GetFaceName(), kCFStringEncodingUTF8);
|
||||
CFRef<CTFontRef> ctfont0 = CTFontCreateWithName(s, fnt.GetHeight(), NULL);
|
||||
CGAffineTransform transform = angle ? CGAffineTransformMakeRotation(M_2PI * angle / 3600)
|
||||
: CGAffineTransformIdentity;
|
||||
CFRef<CTFontRef> ctfont0 = CTFontCreateWithName(s, fnt.GetHeight(), &transform);
|
||||
if(fnt.IsItalic() || fnt.IsBold()) {
|
||||
CTFontSymbolicTraits symbolicTraits = 0;
|
||||
if(fnt.IsBold())
|
||||
symbolicTraits |= kCTFontBoldTrait;
|
||||
if(fnt.IsItalic())
|
||||
symbolicTraits |= kCTFontItalicTrait;
|
||||
CGAffineTransform transform = CGAffineTransformIdentity;
|
||||
CFRef<CTFontRef> ctfont = CTFontCreateCopyWithSymbolicTraits(ctfont0, fnt.GetHeight(),
|
||||
&transform, symbolicTraits, symbolicTraits);
|
||||
if(ctfont)
|
||||
|
|
@ -27,10 +28,11 @@ CTFontRef CT_Font0(Font fnt, bool& synth)
|
|||
return ctfont0.Detach();
|
||||
}
|
||||
|
||||
CTFontRef CT_Font(Font fnt)
|
||||
CTFontRef CT_Font(Font fnt, int angle = 0)
|
||||
{
|
||||
struct Entry {
|
||||
Font font;
|
||||
int angle;
|
||||
CTFontRef ctfont = NULL;
|
||||
bool synth = false;
|
||||
|
||||
|
|
@ -43,12 +45,12 @@ CTFontRef CT_Font(Font fnt)
|
|||
const int FONTCACHE = 64;
|
||||
static Entry cache[FONTCACHE];
|
||||
for(int i = 0; i < FONTCACHE; i++)
|
||||
if(cache[i].font == fnt)
|
||||
if(cache[i].font == fnt && cache[i].angle == angle)
|
||||
return cache[i].ctfont;
|
||||
Entry& e = cache[Random(FONTCACHE)];
|
||||
e.Free();
|
||||
e.font = fnt;
|
||||
e.ctfont = CT_Font0(fnt, e.synth);
|
||||
e.ctfont = CT_Font0(fnt, angle, e.synth);
|
||||
return e.ctfont;
|
||||
}
|
||||
|
||||
|
|
@ -219,25 +221,24 @@ void RenderCharacterSys(FontGlyphConsumer& sw, double x, double y, int chr, Font
|
|||
void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink,
|
||||
int n, const int *dx)
|
||||
{
|
||||
// DLOG("angle " << angle << ", text " << text << ", ink " << ink);
|
||||
Set(ink); // needs to be here because rotation saves context...
|
||||
if(angle) {
|
||||
// TODO: Fix this!
|
||||
CGContextSaveGState(cgHandle);
|
||||
CGContextRotateCTM(cgHandle, 3 * M_PI * angle / 1800);
|
||||
CGContextTranslateCTM(cgHandle, x, -y);
|
||||
DrawTextOp(0, 0, 0, text, font, ink, n, dx);
|
||||
CGContextRestoreGState(cgHandle);
|
||||
return;
|
||||
}
|
||||
Set(ink);
|
||||
|
||||
CFRef<CGFontRef> cgFont = CTFontCopyGraphicsFont(CT_Font(font), NULL);
|
||||
CFRef<CGFontRef> cgFont = CTFontCopyGraphicsFont(CT_Font(font, 0), NULL);
|
||||
|
||||
CGContextSetFont(cgHandle, cgFont);
|
||||
|
||||
Point off = GetOffset();
|
||||
if(angle) {
|
||||
CGAffineTransform tm = CGAffineTransformMakeTranslation(x + off.x, top - y - off.y);
|
||||
tm = CGAffineTransformRotate(tm, M_2PI * angle / 3600);
|
||||
CGContextSetTextMatrix(cgHandle, tm);
|
||||
x = 0;
|
||||
y = -font.GetAscent();
|
||||
}
|
||||
else {
|
||||
x += off.x;
|
||||
y = top - y - font.GetAscent() - off.y;
|
||||
}
|
||||
|
||||
Buffer<CGGlyph> g(n);
|
||||
Buffer<CGPoint> p(n);
|
||||
|
|
@ -252,6 +253,9 @@ void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font fon
|
|||
|
||||
CGContextSetFontSize(cgHandle, font.GetHeight());
|
||||
CGContextShowGlyphsAtPositions(cgHandle, g, p, n);
|
||||
|
||||
if(angle)
|
||||
CGContextSetTextMatrix(cgHandle, CGAffineTransformIdentity);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,44 +1,36 @@
|
|||
sooner:
|
||||
|
||||
- opening FindInFiles, then selecting folder - pushing buttons does not exit dialog
|
||||
|
||||
- package organizer initial size too small
|
||||
- minimize, maximaze
|
||||
|
||||
- Ctrl+Shift+F wrong initial focus
|
||||
- menubar does not loose focus after click outside (or rather ActiveFocus does not work)
|
||||
- numpad Enter does not do K_ENTER
|
||||
- Sort fonts
|
||||
|
||||
- not all additional cursors are correct
|
||||
- Synthetise fonts
|
||||
- Sort fonts
|
||||
- fix package organiser link options (joining link options missing space)
|
||||
|
||||
- numpad Enter does not do K_ENTER
|
||||
|
||||
- progress for assist opens too much, probably problem with delay?
|
||||
|
||||
later:
|
||||
|
||||
- package organizer initial size too small
|
||||
- void WakeUpGuiThread(void)
|
||||
- fullscreen mode issues
|
||||
- CommonFontInfo GetFontInfoSys(Font font) metrics
|
||||
- GetGlyphInfoSys metrics
|
||||
- ROTATED TEXT
|
||||
- EndSession ?
|
||||
- ignoreclick
|
||||
- event flags
|
||||
|
||||
- CachedSetColorKeepAlpha optimize out
|
||||
- use NSView:needsToDrawRect: for IsPaintingOp
|
||||
- implement missing Draw ops
|
||||
- set application icons
|
||||
- fix resizing arrows
|
||||
- RenderCharacterSys
|
||||
|
||||
- multimonitor support
|
||||
|
||||
- SerializePlacement - probably improve
|
||||
|
||||
- implement missing Draw ops
|
||||
void SystemDraw::DrawPolyPolylineOp(const Point *vertices, int vertex_count, const int *counts, int count_count, int width, Color color, Color doxor)
|
||||
void SystemDraw::DrawPolyPolyPolygonOp(const Point *vertices, int vertex_count, const int *subpolygon_counts, int scc, const int *disjunct_polygon_counts, int dpcc, Color color, int width, Color outline, uint64 pattern, Color doxor)
|
||||
void SystemDraw::DrawArcOp(const Rect& rc, Point start, Point end, int width, Color color)
|
||||
|
|
@ -47,6 +39,11 @@ void SystemDraw::DrawArcOp(const Rect& rc, Point start, Point end, int width, Co
|
|||
|
||||
done:
|
||||
|
||||
- RenderCharacterSys
|
||||
- ROTATED TEXT
|
||||
- opening FindInFiles, then selecting folder - pushing buttons does not exit dialog
|
||||
- menubar does not loose focus after click outside (or rather ActiveFocus does not work)
|
||||
- Ctrl+Shift+F wrong initial focus
|
||||
- PrinterJob
|
||||
- reference/Reports - missing text
|
||||
- doubleclick interval: https://developer.apple.com/documentation/appkit/nsevent/1528384-doubleclickinterval?language=objc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue