From 543346f2f1de2761d801b029bb8c658533aa9950 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 21 Jul 2012 16:57:24 +1000 Subject: Scale factor implemented for RGBAImages to allow for high definition markers on retina displays. --- src/Editor.cxx | 7 ++++++- src/Editor.h | 1 + src/Indicator.cxx | 2 +- src/LineMarker.cxx | 12 ++++++------ src/LineMarker.h | 2 +- src/XPM.cxx | 5 +++-- src/XPM.h | 6 +++++- 7 files changed, 23 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/Editor.cxx b/src/Editor.cxx index 44226d11b..c3f1b984e 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -104,6 +104,7 @@ Editor::Editor() { stylesValid = false; technology = SC_TECHNOLOGY_DEFAULT; + scaleRGBAImage = 100; printMagnification = 0; printColourMode = SC_PRINT_NORMAL; @@ -8159,9 +8160,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { sizeRGBAImage.y = wParam; break; + case SCI_RGBAIMAGESETSCALE: + scaleRGBAImage = wParam; + break; + case SCI_MARKERDEFINERGBAIMAGE: if (wParam <= MARKER_MAX) { - vs.markers[wParam].SetRGBAImage(sizeRGBAImage, reinterpret_cast(lParam)); + vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0, reinterpret_cast(lParam)); vs.CalcLargestMarkerHeight(); }; InvalidateStyleData(); diff --git a/src/Editor.h b/src/Editor.h index 00e4ec3a6..0ae1f115f 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -133,6 +133,7 @@ protected: // ScintillaBase subclass needs access to much of Editor ViewStyle vs; int technology; Point sizeRGBAImage; + float scaleRGBAImage; int printMagnification; int printColourMode; diff --git a/src/Indicator.cxx b/src/Indicator.cxx index 9ea4024bb..bd17c3d1c 100644 --- a/src/Indicator.cxx +++ b/src/Indicator.cxx @@ -95,7 +95,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r rcBox.right = rc.right; // Cap width at 4000 to avoid large allocations when mistakes made int width = Platform::Minimum(rcBox.Width(), 4000); - RGBAImage image(width, rcBox.Height(), 0); + RGBAImage image(width, rcBox.Height(), 1.0, 0); // Draw horizontal lines top and bottom for (int x=0; x(((rcWhole.top + rcWhole.bottom) - image->GetHeight()) / 2); - rcImage.bottom = rcImage.top + image->GetHeight(); - rcImage.left = static_cast(((rcWhole.left + rcWhole.right) - image->GetWidth()) / 2); - rcImage.right = rcImage.left + image->GetWidth(); + rcImage.top = static_cast(((rcWhole.top + rcWhole.bottom) - image->GetScaledHeight()) / 2); + rcImage.bottom = rcImage.top + image->GetScaledHeight(); + rcImage.left = static_cast(((rcWhole.left + rcWhole.right) - image->GetScaledWidth()) / 2); + rcImage.right = rcImage.left + image->GetScaledWidth(); surface->DrawRGBAImage(rcImage, image->GetWidth(), image->GetHeight(), image->Pixels()); return; } diff --git a/src/LineMarker.h b/src/LineMarker.h index 5c73a6217..e226ef5f5 100644 --- a/src/LineMarker.h +++ b/src/LineMarker.h @@ -66,7 +66,7 @@ public: } void SetXPM(const char *textForm); void SetXPM(const char *const *linesForm); - void SetRGBAImage(Point sizeRGBAImage, const unsigned char *pixelsRGBAImage); + void SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage); void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter, typeOfFold tFold, int marginStyle); }; diff --git a/src/XPM.cxx b/src/XPM.cxx index db48ea227..7188c2465 100644 --- a/src/XPM.cxx +++ b/src/XPM.cxx @@ -319,8 +319,8 @@ int XPMSet::GetWidth() { return (width > 0) ? width : 0; } -RGBAImage::RGBAImage(int width_, int height_, const unsigned char *pixels_) : - height(height_), width(width_) { +RGBAImage::RGBAImage(int width_, int height_, float scale_, const unsigned char *pixels_) : + height(height_), width(width_), scale(scale_) { if (pixels_) { pixelBytes.assign(pixels_, pixels_ + CountBytes()); } else { @@ -331,6 +331,7 @@ RGBAImage::RGBAImage(int width_, int height_, const unsigned char *pixels_) : RGBAImage::RGBAImage(const XPM &xpm) { height = xpm.GetHeight(); width = xpm.GetWidth(); + scale = 1; pixelBytes.resize(CountBytes()); for (int y=0; y pixelBytes; public: - RGBAImage(int width_, int height_, const unsigned char *pixels_); + RGBAImage(int width_, int height_, float scale_, const unsigned char *pixels_); RGBAImage(const XPM &xpm); virtual ~RGBAImage(); int GetHeight() const { return height; } int GetWidth() const { return width; } + float GetScale() const { return scale; } + float GetScaledHeight() const { return height / scale; } + float GetScaledWidth() const { return width / scale; } int CountBytes() const; const unsigned char *Pixels() const; void SetPixel(int x, int y, ColourDesired colour, int alpha=0xff); -- cgit v1.2.3