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 {
|
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<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()) {
|
if(fnt.IsItalic() || fnt.IsBold()) {
|
||||||
CTFontSymbolicTraits symbolicTraits = 0;
|
CTFontSymbolicTraits symbolicTraits = 0;
|
||||||
if(fnt.IsBold())
|
if(fnt.IsBold())
|
||||||
symbolicTraits |= kCTFontBoldTrait;
|
symbolicTraits |= kCTFontBoldTrait;
|
||||||
if(fnt.IsItalic())
|
if(fnt.IsItalic())
|
||||||
symbolicTraits |= kCTFontItalicTrait;
|
symbolicTraits |= kCTFontItalicTrait;
|
||||||
CGAffineTransform transform = CGAffineTransformIdentity;
|
|
||||||
CFRef<CTFontRef> ctfont = CTFontCreateCopyWithSymbolicTraits(ctfont0, fnt.GetHeight(),
|
CFRef<CTFontRef> ctfont = CTFontCreateCopyWithSymbolicTraits(ctfont0, fnt.GetHeight(),
|
||||||
&transform, symbolicTraits, symbolicTraits);
|
&transform, symbolicTraits, symbolicTraits);
|
||||||
if(ctfont)
|
if(ctfont)
|
||||||
|
|
@ -27,10 +28,11 @@ CTFontRef CT_Font0(Font fnt, bool& synth)
|
||||||
return ctfont0.Detach();
|
return ctfont0.Detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
CTFontRef CT_Font(Font fnt)
|
CTFontRef CT_Font(Font fnt, int angle = 0)
|
||||||
{
|
{
|
||||||
struct Entry {
|
struct Entry {
|
||||||
Font font;
|
Font font;
|
||||||
|
int angle;
|
||||||
CTFontRef ctfont = NULL;
|
CTFontRef ctfont = NULL;
|
||||||
bool synth = false;
|
bool synth = false;
|
||||||
|
|
||||||
|
|
@ -43,12 +45,12 @@ CTFontRef CT_Font(Font fnt)
|
||||||
const int FONTCACHE = 64;
|
const int FONTCACHE = 64;
|
||||||
static Entry cache[FONTCACHE];
|
static Entry cache[FONTCACHE];
|
||||||
for(int i = 0; i < FONTCACHE; i++)
|
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;
|
return cache[i].ctfont;
|
||||||
Entry& e = cache[Random(FONTCACHE)];
|
Entry& e = cache[Random(FONTCACHE)];
|
||||||
e.Free();
|
e.Free();
|
||||||
e.font = fnt;
|
e.font = fnt;
|
||||||
e.ctfont = CT_Font0(fnt, e.synth);
|
e.ctfont = CT_Font0(fnt, angle, e.synth);
|
||||||
return e.ctfont;
|
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,
|
void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font font, Color ink,
|
||||||
int n, const int *dx)
|
int n, const int *dx)
|
||||||
{
|
{
|
||||||
// DLOG("angle " << angle << ", text " << text << ", ink " << ink);
|
Set(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
CFRef<CGFontRef> cgFont = CTFontCopyGraphicsFont(CT_Font(font), NULL);
|
CFRef<CGFontRef> cgFont = CTFontCopyGraphicsFont(CT_Font(font, 0), NULL);
|
||||||
|
|
||||||
CGContextSetFont(cgHandle, cgFont);
|
CGContextSetFont(cgHandle, cgFont);
|
||||||
|
|
||||||
Point off = GetOffset();
|
Point off = GetOffset();
|
||||||
x += off.x;
|
if(angle) {
|
||||||
y = top - y - font.GetAscent() - off.y;
|
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<CGGlyph> g(n);
|
||||||
Buffer<CGPoint> p(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());
|
CGContextSetFontSize(cgHandle, font.GetHeight());
|
||||||
CGContextShowGlyphsAtPositions(cgHandle, g, p, n);
|
CGContextShowGlyphsAtPositions(cgHandle, g, p, n);
|
||||||
|
|
||||||
|
if(angle)
|
||||||
|
CGContextSetTextMatrix(cgHandle, CGAffineTransformIdentity);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,44 +1,36 @@
|
||||||
sooner:
|
sooner:
|
||||||
|
|
||||||
- opening FindInFiles, then selecting folder - pushing buttons does not exit dialog
|
|
||||||
|
|
||||||
- package organizer initial size too small
|
|
||||||
- minimize, maximaze
|
- minimize, maximaze
|
||||||
|
- numpad Enter does not do K_ENTER
|
||||||
- Ctrl+Shift+F wrong initial focus
|
- Sort fonts
|
||||||
- menubar does not loose focus after click outside (or rather ActiveFocus does not work)
|
|
||||||
|
|
||||||
- not all additional cursors are correct
|
- not all additional cursors are correct
|
||||||
- Synthetise fonts
|
- Synthetise fonts
|
||||||
- Sort fonts
|
|
||||||
- fix package organiser link options (joining link options missing space)
|
- 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?
|
- progress for assist opens too much, probably problem with delay?
|
||||||
|
|
||||||
later:
|
later:
|
||||||
|
|
||||||
|
- package organizer initial size too small
|
||||||
- void WakeUpGuiThread(void)
|
- void WakeUpGuiThread(void)
|
||||||
- fullscreen mode issues
|
- fullscreen mode issues
|
||||||
- CommonFontInfo GetFontInfoSys(Font font) metrics
|
- CommonFontInfo GetFontInfoSys(Font font) metrics
|
||||||
- GetGlyphInfoSys metrics
|
- GetGlyphInfoSys metrics
|
||||||
- ROTATED TEXT
|
|
||||||
- EndSession ?
|
- EndSession ?
|
||||||
- ignoreclick
|
- ignoreclick
|
||||||
- event flags
|
- event flags
|
||||||
|
|
||||||
- CachedSetColorKeepAlpha optimize out
|
- CachedSetColorKeepAlpha optimize out
|
||||||
- use NSView:needsToDrawRect: for IsPaintingOp
|
- use NSView:needsToDrawRect: for IsPaintingOp
|
||||||
- implement missing Draw ops
|
|
||||||
- set application icons
|
- set application icons
|
||||||
- fix resizing arrows
|
- fix resizing arrows
|
||||||
- RenderCharacterSys
|
|
||||||
|
|
||||||
- multimonitor support
|
- multimonitor support
|
||||||
|
|
||||||
- SerializePlacement - probably improve
|
- 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::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::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)
|
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:
|
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
|
- PrinterJob
|
||||||
- reference/Reports - missing text
|
- reference/Reports - missing text
|
||||||
- doubleclick interval: https://developer.apple.com/documentation/appkit/nsevent/1528384-doubleclickinterval?language=objc
|
- doubleclick interval: https://developer.apple.com/documentation/appkit/nsevent/1528384-doubleclickinterval?language=objc
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue