mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
FINE I'll do it myself
This commit is contained in:
@@ -105,24 +105,40 @@ RealRect intersect(const RealRect& a, const RealRect& b) {
|
|||||||
RealPoint tl = piecewise_max(a.topLeft(), b.topLeft());
|
RealPoint tl = piecewise_max(a.topLeft(), b.topLeft());
|
||||||
RealPoint br = piecewise_min(a.bottomRight(), b.bottomRight());
|
RealPoint br = piecewise_min(a.bottomRight(), b.bottomRight());
|
||||||
return RealRect(tl, RealSize(br - tl));
|
return RealRect(tl, RealSize(br - tl));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextViewer::drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel_start, size_t sel_end) {
|
void TextViewer::drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel_start, size_t sel_end) {
|
||||||
if (sel_start == sel_end) return;
|
if (sel_start == sel_end) return;
|
||||||
if (sel_end < sel_start) swap(sel_start, sel_end);
|
if (sel_end < sel_start) swap(sel_start, sel_end);
|
||||||
|
#ifdef __WXMSW__
|
||||||
dc.SetBrush(*wxWHITE_BRUSH);
|
dc.SetBrush(*wxWHITE_BRUSH);
|
||||||
dc.SetPen(*wxWHITE_PEN);
|
dc.SetPen(*wxWHITE_PEN);
|
||||||
dc.SetLogicalFunction(wxXOR);
|
dc.SetLogicalFunction(wxXOR);
|
||||||
|
#endif
|
||||||
RealRect prev_rect(0,0,0,0);
|
RealRect prev_rect(0,0,0,0);
|
||||||
FOR_EACH(l, lines) {
|
FOR_EACH(l, lines) {
|
||||||
RealRect rect = l.selectionRectangle(dc, sel_start, sel_end);
|
RealRect rect = l.selectionRectangle(dc, sel_start, sel_end);
|
||||||
if (rect.height > 0) dc.DrawRectangle(rect);
|
if (rect.height > 0) {
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
dc.DrawRectangle(rect);
|
||||||
|
#else
|
||||||
|
dc.DrawInvertRectangle(rect);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
// compensate for overlap between lines
|
// compensate for overlap between lines
|
||||||
RealRect overlap = intersect(rect, prev_rect);
|
RealRect overlap = intersect(rect, prev_rect);
|
||||||
if (overlap.height > 0 && overlap.width > 0) dc.DrawRectangle(overlap);
|
if (overlap.height > 0 && overlap.width > 0) {
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
dc.DrawRectangle(overlap);
|
||||||
|
#else
|
||||||
|
dc.DrawInvertRectangle(overlap);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
prev_rect = rect;
|
prev_rect = rect;
|
||||||
}
|
}
|
||||||
dc.SetLogicalFunction(wxCOPY);
|
#ifdef __WXMSW__
|
||||||
|
dc.SetLogicalFunction(wxCOPY);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
RealRect TextViewer::Line::selectionRectangle(const Rotation& rot, size_t sel_start, size_t sel_end) {
|
RealRect TextViewer::Line::selectionRectangle(const Rotation& rot, size_t sel_start, size_t sel_end) {
|
||||||
|
|||||||
+29
-1
@@ -9,7 +9,8 @@
|
|||||||
#include <util/prec.hpp>
|
#include <util/prec.hpp>
|
||||||
#include <util/rotation.hpp>
|
#include <util/rotation.hpp>
|
||||||
#include <gfx/gfx.hpp>
|
#include <gfx/gfx.hpp>
|
||||||
#include <data/font.hpp>
|
#include <data/font.hpp>
|
||||||
|
#include <wx/rawbmp.h>
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Rotation
|
// ----------------------------------------------------------------------------- : Rotation
|
||||||
|
|
||||||
@@ -276,6 +277,33 @@ void RotatedDC::DrawRoundedRectangle(const RealRect& r, double radius) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RotatedDC::DrawInvertRectangle(const RealRect& r) {
|
||||||
|
wxRect r_ext = trRectToBB(r);
|
||||||
|
|
||||||
|
wxBitmap bmp(r_ext.width, r_ext.height, 24);
|
||||||
|
wxMemoryDC memDC(bmp);
|
||||||
|
memDC.Blit(0, 0, r_ext.width, r_ext.height, &dc, r_ext.x, r_ext.y);
|
||||||
|
memDC.SelectObject(wxNullBitmap);
|
||||||
|
|
||||||
|
wxNativePixelData data(bmp);
|
||||||
|
if (!data) return; // Raw access not available on this platform/bitmap
|
||||||
|
wxNativePixelData::Iterator p(data);
|
||||||
|
for (int j = 0; j < r_ext.height; ++j) {
|
||||||
|
wxNativePixelData::Iterator rowStart = p;
|
||||||
|
for (int i = 0; i < r_ext.width; ++i) {
|
||||||
|
// Invert each channel
|
||||||
|
p.Red() = 255 - p.Red();
|
||||||
|
p.Green() = 255 - p.Green();
|
||||||
|
p.Blue() = 255 - p.Blue();
|
||||||
|
++p; // Move to next pixel in the row
|
||||||
|
}
|
||||||
|
p = rowStart;
|
||||||
|
p.OffsetY(data, 1); // Move to the next row
|
||||||
|
}
|
||||||
|
|
||||||
|
dc.DrawBitmap(bmp, RealPoint(r_ext.x, r_ext.y));
|
||||||
|
}
|
||||||
|
|
||||||
void RotatedDC::DrawCircle(const RealPoint& center, double radius) {
|
void RotatedDC::DrawCircle(const RealPoint& center, double radius) {
|
||||||
wxPoint p = tr(center);
|
wxPoint p = tr(center);
|
||||||
dc.DrawCircle(p.x + 1, p.y + 1, int(trS(radius)));
|
dc.DrawCircle(p.x + 1, p.y + 1, int(trS(radius)));
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ public:
|
|||||||
void DrawLine (const RealPoint& p1, const RealPoint& p2);
|
void DrawLine (const RealPoint& p1, const RealPoint& p2);
|
||||||
void DrawRectangle(const RealRect& r);
|
void DrawRectangle(const RealRect& r);
|
||||||
void DrawRoundedRectangle(const RealRect& r, double radius);
|
void DrawRoundedRectangle(const RealRect& r, double radius);
|
||||||
|
void DrawInvertRectangle(const RealRect& r);
|
||||||
void DrawCircle(const RealPoint& center, double radius);
|
void DrawCircle(const RealPoint& center, double radius);
|
||||||
void DrawEllipse(const RealPoint& center, const RealSize& size);
|
void DrawEllipse(const RealPoint& center, const RealSize& size);
|
||||||
/// Draw an arc of an ellipse, angles are in radians
|
/// Draw an arc of an ellipse, angles are in radians
|
||||||
|
|||||||
Reference in New Issue
Block a user