1 /* 2 * DQt - D bindings for the Qt Toolkit 3 * 4 * GNU Lesser General Public License Usage 5 * This file may be used under the terms of the GNU Lesser 6 * General Public License version 3 as published by the Free Software 7 * Foundation and appearing in the file LICENSE.LGPL3 included in the 8 * packaging of this file. Please review the following information to 9 * ensure the GNU Lesser General Public License version 3 requirements 10 * will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 11 */ 12 module qt.gui.brush; 13 extern(C++): 14 15 import qt.config; 16 import qt.core.atomic; 17 import qt.core.global; 18 import qt.core.list; 19 import qt.core.metamacros; 20 import qt.core.namespace; 21 import qt.core.pair; 22 import qt.core.point; 23 import qt.core.typeinfo; 24 import qt.core.variant; 25 import qt.gui.color; 26 import qt.gui.image; 27 import qt.gui.pixmap; 28 import qt.gui.transform; 29 import qt.helpers; 30 31 struct QBrushDataPointerDeleter 32 { 33 /+void operator ()(QBrushData* d) const/+ noexcept+/;+/ 34 mixin(CREATE_CONVENIENCE_WRAPPERS); 35 } 36 37 /// Binding for C++ class [QBrush](https://doc.qt.io/qt-6/qbrush.html). 38 @Q_RELOCATABLE_TYPE extern(C++, class) struct /+ Q_GUI_EXPORT +/ QBrush 39 { 40 public: 41 @disable this(); 42 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 43 ref typeof(this) rawConstructor(); 44 static typeof(this) create() 45 { 46 typeof(this) r = typeof(this).init; 47 r.rawConstructor(); 48 return r; 49 } 50 51 this(/+ Qt:: +/qt.core.namespace.BrushStyle bs); 52 this(ref const(QColor) color, /+ Qt:: +/qt.core.namespace.BrushStyle bs=/+ Qt:: +/qt.core.namespace.BrushStyle.SolidPattern); 53 this(/+ Qt:: +/qt.core.namespace.GlobalColor color, /+ Qt:: +/qt.core.namespace.BrushStyle bs=/+ Qt:: +/qt.core.namespace.BrushStyle.SolidPattern); 54 55 this(ref const(QColor) color, ref const(QPixmap) pixmap); 56 this(/+ Qt:: +/qt.core.namespace.GlobalColor color, ref const(QPixmap) pixmap); 57 this(ref const(QPixmap) pixmap); 58 this(ref const(QImage) image); 59 60 @disable this(this); 61 this(ref const(QBrush) brush); 62 63 this(ref const(QGradient) gradient); 64 65 ~this(); 66 /+ref QBrush operator =(ref const(QBrush) brush);+/ 67 /+ QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QBrush) +/ 68 /+ inline void swap(QBrush &other) noexcept 69 { qSwap(d, other.d); } +/ 70 71 /+auto opCast(T : QVariant)() const;+/ 72 73 pragma(inline, true) /+ Qt:: +/qt.core.namespace.BrushStyle style() const { return d.style; } 74 void setStyle(/+ Qt:: +/qt.core.namespace.BrushStyle); 75 76 pragma(inline, true) QTransform transform() const { return d.transform; } 77 void setTransform(ref const(QTransform) ); 78 79 QPixmap texture() const; 80 void setTexture(ref const(QPixmap) pixmap); 81 82 QImage textureImage() const; 83 void setTextureImage(ref const(QImage) image); 84 85 pragma(inline, true) ref const(QColor) color() const { return d.color; } 86 void setColor(ref const(QColor) color); 87 pragma(inline, true) void setColor(/+ Qt:: +/qt.core.namespace.GlobalColor acolor) 88 { auto tmp = QColor(acolor); setColor(tmp); } 89 90 const(QGradient)* gradient() const; 91 92 bool isOpaque() const; 93 94 /+bool operator ==(ref const(QBrush) b) const;+/ 95 /+pragma(inline, true) bool operator !=(ref const(QBrush) b) const { return !(operator==(b)); }+/ 96 97 //alias DataPtr = /+ std:: +/unique_ptr!(QBrushData, QBrushDataPointerDeleter); 98 99 private: 100 /+ friend class QRasterPaintEngine; +/ 101 /+ friend class QRasterPaintEnginePrivate; +/ 102 /+ friend struct QSpanData; +/ 103 /+ friend class QPainter; +/ 104 /+ friend bool Q_GUI_EXPORT qHasPixmapTexture(const QBrush& brush); +/ 105 void detach(/+ Qt:: +/qt.core.namespace.BrushStyle newStyle); 106 //void init_(ref const(QColor) color, /+ Qt:: +/qt.core.namespace.BrushStyle bs); 107 QBrushData* /*DataPtr*/ d; 108 109 public: 110 pragma(inline, true) bool isDetached() const { return d.ref_.loadRelaxed() == 1; } 111 //pragma(inline, true) ref DataPtr data_ptr() { return d; } 112 mixin(CREATE_CONVENIENCE_WRAPPERS); 113 } 114 115 /+ Q_DECLARE_SHARED(QBrush) 116 117 /***************************************************************************** 118 QBrush stream functions 119 *****************************************************************************/ 120 121 #ifndef QT_NO_DATASTREAM 122 Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QBrush &); 123 Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QBrush &); 124 #endif 125 126 #ifndef QT_NO_DEBUG_STREAM 127 Q_GUI_EXPORT QDebug operator<<(QDebug, const QBrush &); 128 #endif +/ 129 130 struct QBrushData 131 { 132 QAtomicInt ref_; 133 /+ Qt:: +/qt.core.namespace.BrushStyle style; 134 QColor color; 135 QTransform transform; 136 } 137 138 139 /******************************************************************************* 140 * QGradients 141 */ 142 extern(C++, class) struct QGradientPrivate; 143 144 alias QGradientStop = qt.core.pair.QPair!(qreal, QColor); 145 alias QGradientStops = QList!(QGradientStop); 146 147 /// Binding for C++ class [QGradient](https://doc.qt.io/qt-6/qgradient.html). 148 extern(C++, class) struct /+ Q_GUI_EXPORT +/ QGradient 149 { 150 mixin(Q_GADGET); 151 public: 152 enum Type { 153 LinearGradient, 154 RadialGradient, 155 ConicalGradient, 156 NoGradient 157 } 158 /+ Q_ENUM(Type) +/ 159 160 enum Spread { 161 PadSpread, 162 ReflectSpread, 163 RepeatSpread 164 } 165 /+ Q_ENUM(Spread) +/ 166 167 enum CoordinateMode { 168 LogicalMode, 169 StretchToDeviceMode, 170 ObjectBoundingMode, 171 ObjectMode 172 } 173 /+ Q_ENUM(CoordinateMode) +/ 174 175 enum InterpolationMode { 176 ColorInterpolation, 177 ComponentInterpolation 178 } 179 180 enum Preset { 181 WarmFlame = 1, 182 NightFade = 2, 183 SpringWarmth = 3, 184 JuicyPeach = 4, 185 YoungPassion = 5, 186 LadyLips = 6, 187 SunnyMorning = 7, 188 RainyAshville = 8, 189 FrozenDreams = 9, 190 WinterNeva = 10, 191 DustyGrass = 11, 192 TemptingAzure = 12, 193 HeavyRain = 13, 194 AmyCrisp = 14, 195 MeanFruit = 15, 196 DeepBlue = 16, 197 RipeMalinka = 17, 198 CloudyKnoxville = 18, 199 MalibuBeach = 19, 200 NewLife = 20, 201 TrueSunset = 21, 202 MorpheusDen = 22, 203 RareWind = 23, 204 NearMoon = 24, 205 WildApple = 25, 206 SaintPetersburg = 26, 207 PlumPlate = 28, 208 EverlastingSky = 29, 209 HappyFisher = 30, 210 Blessing = 31, 211 SharpeyeEagle = 32, 212 LadogaBottom = 33, 213 LemonGate = 34, 214 ItmeoBranding = 35, 215 ZeusMiracle = 36, 216 OldHat = 37, 217 StarWine = 38, 218 HappyAcid = 41, 219 AwesomePine = 42, 220 NewYork = 43, 221 ShyRainbow = 44, 222 MixedHopes = 46, 223 FlyHigh = 47, 224 StrongBliss = 48, 225 FreshMilk = 49, 226 SnowAgain = 50, 227 FebruaryInk = 51, 228 KindSteel = 52, 229 SoftGrass = 53, 230 GrownEarly = 54, 231 SharpBlues = 55, 232 ShadyWater = 56, 233 DirtyBeauty = 57, 234 GreatWhale = 58, 235 TeenNotebook = 59, 236 PoliteRumors = 60, 237 SweetPeriod = 61, 238 WideMatrix = 62, 239 SoftCherish = 63, 240 RedSalvation = 64, 241 BurningSpring = 65, 242 NightParty = 66, 243 SkyGlider = 67, 244 HeavenPeach = 68, 245 PurpleDivision = 69, 246 AquaSplash = 70, 247 SpikyNaga = 72, 248 LoveKiss = 73, 249 CleanMirror = 75, 250 PremiumDark = 76, 251 ColdEvening = 77, 252 CochitiLake = 78, 253 SummerGames = 79, 254 PassionateBed = 80, 255 MountainRock = 81, 256 DesertHump = 82, 257 JungleDay = 83, 258 PhoenixStart = 84, 259 OctoberSilence = 85, 260 FarawayRiver = 86, 261 AlchemistLab = 87, 262 OverSun = 88, 263 PremiumWhite = 89, 264 MarsParty = 90, 265 EternalConstance = 91, 266 JapanBlush = 92, 267 SmilingRain = 93, 268 CloudyApple = 94, 269 BigMango = 95, 270 HealthyWater = 96, 271 AmourAmour = 97, 272 RiskyConcrete = 98, 273 StrongStick = 99, 274 ViciousStance = 100, 275 PaloAlto = 101, 276 HappyMemories = 102, 277 MidnightBloom = 103, 278 Crystalline = 104, 279 PartyBliss = 106, 280 ConfidentCloud = 107, 281 LeCocktail = 108, 282 RiverCity = 109, 283 FrozenBerry = 110, 284 ChildCare = 112, 285 FlyingLemon = 113, 286 NewRetrowave = 114, 287 HiddenJaguar = 115, 288 AboveTheSky = 116, 289 Nega = 117, 290 DenseWater = 118, 291 Seashore = 120, 292 MarbleWall = 121, 293 CheerfulCaramel = 122, 294 NightSky = 123, 295 MagicLake = 124, 296 YoungGrass = 125, 297 ColorfulPeach = 126, 298 GentleCare = 127, 299 PlumBath = 128, 300 HappyUnicorn = 129, 301 AfricanField = 131, 302 SolidStone = 132, 303 OrangeJuice = 133, 304 GlassWater = 134, 305 NorthMiracle = 136, 306 FruitBlend = 137, 307 MillenniumPine = 138, 308 HighFlight = 139, 309 MoleHall = 140, 310 SpaceShift = 142, 311 ForestInei = 143, 312 RoyalGarden = 144, 313 RichMetal = 145, 314 JuicyCake = 146, 315 SmartIndigo = 147, 316 SandStrike = 148, 317 NorseBeauty = 149, 318 AquaGuidance = 150, 319 SunVeggie = 151, 320 SeaLord = 152, 321 BlackSea = 153, 322 GrassShampoo = 154, 323 LandingAircraft = 155, 324 WitchDance = 156, 325 SleeplessNight = 157, 326 AngelCare = 158, 327 CrystalRiver = 159, 328 SoftLipstick = 160, 329 SaltMountain = 161, 330 PerfectWhite = 162, 331 FreshOasis = 163, 332 StrictNovember = 164, 333 MorningSalad = 165, 334 DeepRelief = 166, 335 SeaStrike = 167, 336 NightCall = 168, 337 SupremeSky = 169, 338 LightBlue = 170, 339 MindCrawl = 171, 340 LilyMeadow = 172, 341 SugarLollipop = 173, 342 SweetDessert = 174, 343 MagicRay = 175, 344 TeenParty = 176, 345 FrozenHeat = 177, 346 GagarinView = 178, 347 FabledSunset = 179, 348 PerfectBlue = 180, 349 350 NumPresets 351 } 352 /+ Q_ENUM(Preset) +/ 353 354 @disable this(); 355 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 356 ref typeof(this) rawConstructor(); 357 static typeof(this) create() 358 { 359 typeof(this) r = typeof(this).init; 360 r.rawConstructor(); 361 return r; 362 } 363 364 this(Preset); 365 ~this(); 366 367 Type type() const { return m_type; } 368 369 pragma(inline, true) void setSpread(Spread aspread) 370 { m_spread = aspread; } 371 Spread spread() const { return m_spread; } 372 373 void setColorAt(qreal pos, ref const(QColor) color); 374 375 void setStops(ref const(QGradientStops) stops); 376 QGradientStops stops() const; 377 378 CoordinateMode coordinateMode() const; 379 void setCoordinateMode(CoordinateMode mode); 380 381 InterpolationMode interpolationMode() const; 382 void setInterpolationMode(InterpolationMode mode); 383 384 /+bool operator ==(ref const(QGradient) gradient) const;+/ 385 /+pragma(inline, true) bool operator !=(ref const(QGradient) other) const 386 { return !operator==(other); }+/ 387 388 union QGradientData { 389 struct generated_qbrush_0 { 390 qreal x1; qreal y1; qreal x2; qreal y2; 391 }generated_qbrush_0 linear; 392 struct generated_qbrush_1 { 393 qreal cx; qreal cy; qreal fx; qreal fy; qreal cradius; qreal fradius; 394 }generated_qbrush_1 radial; 395 struct generated_qbrush_2 { 396 qreal cx; qreal cy; qreal angle; 397 }generated_qbrush_2 conical; 398 } 399 400 private: 401 /+ friend class QLinearGradient; +/ 402 /+ friend class QRadialGradient; +/ 403 /+ friend class QConicalGradient; +/ 404 /+ friend class QBrush; +/ 405 406 Type m_type = Type.NoGradient; 407 Spread m_spread = Spread.PadSpread; 408 QGradientStops m_stops; 409 QGradientData m_data; 410 CoordinateMode m_coordinateMode = CoordinateMode.LogicalMode; 411 InterpolationMode m_interpolationMode = InterpolationMode.ColorInterpolation; 412 mixin(CREATE_CONVENIENCE_WRAPPERS); 413 } 414 415 /// Binding for C++ class [QLinearGradient](https://doc.qt.io/qt-6/qlineargradient.html). 416 extern(C++, class) struct /+ Q_GUI_EXPORT +/ QLinearGradient 417 { 418 public QGradient base0; 419 alias base0 this; 420 public: 421 @disable this(); 422 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 423 ref typeof(this) rawConstructor(); 424 static typeof(this) create() 425 { 426 typeof(this) r = typeof(this).init; 427 r.rawConstructor(); 428 return r; 429 } 430 431 this(ref const(QPointF) start, ref const(QPointF) finalStop); 432 this(qreal xStart, qreal yStart, qreal xFinalStop, qreal yFinalStop); 433 ~this(); 434 435 QPointF start() const; 436 void setStart(ref const(QPointF) start); 437 pragma(inline, true) void setStart(qreal x, qreal y) { auto tmp = QPointF(x, y); setStart(tmp); } 438 439 QPointF finalStop() const; 440 void setFinalStop(ref const(QPointF) stop); 441 pragma(inline, true) void setFinalStop(qreal x, qreal y) { auto tmp = QPointF(x, y); setFinalStop(tmp); } 442 mixin(CREATE_CONVENIENCE_WRAPPERS); 443 } 444 445 446 /// Binding for C++ class [QRadialGradient](https://doc.qt.io/qt-6/qradialgradient.html). 447 extern(C++, class) struct /+ Q_GUI_EXPORT +/ QRadialGradient 448 { 449 public QGradient base0; 450 alias base0 this; 451 public: 452 @disable this(); 453 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 454 ref typeof(this) rawConstructor(); 455 static typeof(this) create() 456 { 457 typeof(this) r = typeof(this).init; 458 r.rawConstructor(); 459 return r; 460 } 461 462 this(ref const(QPointF) center, qreal radius, ref const(QPointF) focalPoint); 463 this(qreal cx, qreal cy, qreal radius, qreal fx, qreal fy); 464 465 this(ref const(QPointF) center, qreal radius); 466 this(qreal cx, qreal cy, qreal radius); 467 468 this(ref const(QPointF) center, qreal centerRadius, ref const(QPointF) focalPoint, qreal focalRadius); 469 this(qreal cx, qreal cy, qreal centerRadius, qreal fx, qreal fy, qreal focalRadius); 470 471 ~this(); 472 473 QPointF center() const; 474 void setCenter(ref const(QPointF) center); 475 pragma(inline, true) void setCenter(qreal x, qreal y) { auto tmp = QPointF(x, y); setCenter(tmp); } 476 477 QPointF focalPoint() const; 478 void setFocalPoint(ref const(QPointF) focalPoint); 479 pragma(inline, true) void setFocalPoint(qreal x, qreal y) { auto tmp = QPointF(x, y); setFocalPoint(tmp); } 480 481 qreal radius() const; 482 void setRadius(qreal radius); 483 484 qreal centerRadius() const; 485 void setCenterRadius(qreal radius); 486 487 qreal focalRadius() const; 488 void setFocalRadius(qreal radius); 489 mixin(CREATE_CONVENIENCE_WRAPPERS); 490 } 491 492 493 /// Binding for C++ class [QConicalGradient](https://doc.qt.io/qt-6/qconicalgradient.html). 494 extern(C++, class) struct /+ Q_GUI_EXPORT +/ QConicalGradient 495 { 496 public QGradient base0; 497 alias base0 this; 498 public: 499 @disable this(); 500 pragma(mangle, defaultConstructorMangling(__traits(identifier, typeof(this)))) 501 ref typeof(this) rawConstructor(); 502 static typeof(this) create() 503 { 504 typeof(this) r = typeof(this).init; 505 r.rawConstructor(); 506 return r; 507 } 508 509 this(ref const(QPointF) center, qreal startAngle); 510 this(qreal cx, qreal cy, qreal startAngle); 511 ~this(); 512 513 QPointF center() const; 514 void setCenter(ref const(QPointF) center); 515 pragma(inline, true) void setCenter(qreal x, qreal y) { auto tmp = QPointF(x, y); setCenter(tmp); } 516 517 qreal angle() const; 518 void setAngle(qreal angle); 519 mixin(CREATE_CONVENIENCE_WRAPPERS); 520 } 521