Changeset View
Changeset View
Standalone View
Standalone View
kstyle/breezehelper.h
Show All 25 Lines | |||||
26 | #include "config-breeze.h" | 26 | #include "config-breeze.h" | ||
27 | 27 | | |||
28 | #include <KColorScheme> | 28 | #include <KColorScheme> | ||
29 | #include <KSharedConfig> | 29 | #include <KSharedConfig> | ||
30 | 30 | | |||
31 | #include <QPainterPath> | 31 | #include <QPainterPath> | ||
32 | #include <QWidget> | 32 | #include <QWidget> | ||
33 | 33 | | |||
34 | #if BREEZE_HAVE_X11 | | |||
35 | #include <xcb/xcb.h> | | |||
36 | #endif | | |||
37 | | ||||
38 | namespace Breeze | 34 | namespace Breeze | ||
39 | { | 35 | { | ||
40 | 36 | | |||
41 | //* breeze style helper class. | 37 | //* breeze style helper class. | ||
42 | /** contains utility functions used at multiple places in both breeze style and breeze window decoration */ | 38 | /** contains utility functions used at multiple places in both breeze style and breeze window decoration */ | ||
43 | class Helper | 39 | class Helper | ||
44 | { | 40 | { | ||
45 | public: | 41 | public: | ||
▲ Show 20 Lines • Show All 237 Lines • ▼ Show 20 Line(s) | |||||
283 | //* return dpi-aware pixmap of given size | 279 | //* return dpi-aware pixmap of given size | ||
284 | virtual QPixmap highDpiPixmap( int width, int height ) const; | 280 | virtual QPixmap highDpiPixmap( int width, int height ) const; | ||
285 | 281 | | |||
286 | //* return device pixel ratio for a given pixmap | 282 | //* return device pixel ratio for a given pixmap | ||
287 | virtual qreal devicePixelRatio( const QPixmap& ) const; | 283 | virtual qreal devicePixelRatio( const QPixmap& ) const; | ||
288 | 284 | | |||
289 | //@} | 285 | //@} | ||
290 | 286 | | |||
291 | //*@name X11 utilities | | |||
292 | //@{ | | |||
293 | | ||||
294 | #if BREEZE_HAVE_X11 | | |||
295 | | ||||
296 | //* create xcb atom | | |||
297 | xcb_atom_t createAtom( const QString& ) const; | | |||
298 | | ||||
299 | #endif | | |||
300 | | ||||
301 | //@} | | |||
302 | | ||||
303 | //* frame radius | 287 | //* frame radius | ||
304 | constexpr qreal frameRadius( const int penWidth = PenWidth::NoPen, const qreal bias = 0 ) const | 288 | constexpr qreal frameRadius( const int penWidth = PenWidth::NoPen, const qreal bias = 0 ) const | ||
305 | { return qMax( Metrics::Frame_FrameRadius - (0.5 * penWidth) + bias, 0.0 ); } | 289 | { return qMax( Metrics::Frame_FrameRadius - (0.5 * penWidth) + bias, 0.0 ); } | ||
306 | 290 | | |||
307 | //* frame radius with new pen width | 291 | //* frame radius with new pen width | ||
308 | constexpr qreal frameRadiusForNewPenWidth( const qreal oldRadius, const int penWidth ) const | 292 | constexpr qreal frameRadiusForNewPenWidth( const qreal oldRadius, const int penWidth ) const | ||
309 | { return qMax( oldRadius - (0.5 * penWidth), 0.0 ); } | 293 | { return qMax( oldRadius - (0.5 * penWidth), 0.0 ); } | ||
310 | 294 | | |||
311 | //* return a QRectF with the appropriate size for a rectangle with a pen stroke | 295 | //* return a QRectF with the appropriate size for a rectangle with a pen stroke | ||
312 | QRectF strokedRect( const QRectF &rect, const int penWidth = PenWidth::Frame ) const; | 296 | QRectF strokedRect( const QRectF &rect, const int penWidth = PenWidth::Frame ) const; | ||
313 | 297 | | |||
314 | //* return a QRectF with the appropriate size for a rectangle with a pen stroke | 298 | //* return a QRectF with the appropriate size for a rectangle with a pen stroke | ||
315 | QRectF strokedRect( const QRect &rect, const int penWidth = PenWidth::Frame ) const; | 299 | QRectF strokedRect( const QRect &rect, const int penWidth = PenWidth::Frame ) const; | ||
316 | 300 | | |||
317 | protected: | 301 | protected: | ||
318 | 302 | | |||
319 | //* initialize | | |||
320 | void init(); | | |||
321 | | ||||
322 | //* return rounded path in a given rect, with only selected corners rounded, and for a given radius | 303 | //* return rounded path in a given rect, with only selected corners rounded, and for a given radius | ||
323 | QPainterPath roundedPath( const QRectF&, Corners, qreal ) const; | 304 | QPainterPath roundedPath( const QRectF&, Corners, qreal ) const; | ||
324 | 305 | | |||
325 | private: | 306 | private: | ||
326 | 307 | | |||
327 | //* configuration | 308 | //* configuration | ||
328 | KSharedConfig::Ptr _config; | 309 | KSharedConfig::Ptr _config; | ||
329 | 310 | | |||
330 | //*@name brushes | 311 | //*@name brushes | ||
331 | //@{ | 312 | //@{ | ||
332 | KStatefulBrush _viewFocusBrush; | 313 | KStatefulBrush _viewFocusBrush; | ||
333 | KStatefulBrush _viewHoverBrush; | 314 | KStatefulBrush _viewHoverBrush; | ||
334 | KStatefulBrush _viewNegativeTextBrush; | 315 | KStatefulBrush _viewNegativeTextBrush; | ||
335 | //@} | 316 | //@} | ||
336 | 317 | | |||
337 | //*@name windeco colors | 318 | //*@name windeco colors | ||
338 | //@{ | 319 | //@{ | ||
339 | QColor _activeTitleBarColor; | 320 | QColor _activeTitleBarColor; | ||
340 | QColor _activeTitleBarTextColor; | 321 | QColor _activeTitleBarTextColor; | ||
341 | QColor _inactiveTitleBarColor; | 322 | QColor _inactiveTitleBarColor; | ||
342 | QColor _inactiveTitleBarTextColor; | 323 | QColor _inactiveTitleBarTextColor; | ||
343 | //@} | 324 | //@} | ||
344 | 325 | | |||
345 | #if BREEZE_HAVE_X11 | | |||
346 | | ||||
347 | //* atom used for compositing manager | | |||
348 | xcb_atom_t _compositingManagerAtom; | | |||
349 | | ||||
350 | #endif | | |||
351 | | ||||
352 | }; | 326 | }; | ||
353 | 327 | | |||
354 | } | 328 | } | ||
355 | 329 | | |||
356 | #endif | 330 | #endif |