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 <QX11Info> | | |||
36 | #include <xcb/xcb.h> | | |||
37 | #endif | | |||
38 | | ||||
39 | namespace Breeze | 34 | namespace Breeze | ||
40 | { | 35 | { | ||
41 | 36 | | |||
42 | //* breeze style helper class. | 37 | //* breeze style helper class. | ||
43 | /** 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 */ | ||
44 | class Helper | 39 | class Helper | ||
45 | { | 40 | { | ||
46 | public: | 41 | public: | ||
▲ Show 20 Lines • Show All 237 Lines • ▼ Show 20 Line(s) | |||||
284 | //* return dpi-aware pixmap of given size | 279 | //* return dpi-aware pixmap of given size | ||
285 | virtual QPixmap highDpiPixmap( int width, int height ) const; | 280 | virtual QPixmap highDpiPixmap( int width, int height ) const; | ||
286 | 281 | | |||
287 | //* return device pixel ratio for a given pixmap | 282 | //* return device pixel ratio for a given pixmap | ||
288 | virtual qreal devicePixelRatio( const QPixmap& ) const; | 283 | virtual qreal devicePixelRatio( const QPixmap& ) const; | ||
289 | 284 | | |||
290 | //@} | 285 | //@} | ||
291 | 286 | | |||
292 | //*@name X11 utilities | | |||
293 | //@{ | | |||
294 | | ||||
295 | #if BREEZE_HAVE_X11 | | |||
296 | | ||||
297 | //* get xcb connection | | |||
298 | static xcb_connection_t* connection(); | | |||
299 | | ||||
300 | //* create xcb atom | | |||
301 | xcb_atom_t createAtom( const QString& ) const; | | |||
302 | | ||||
303 | #endif | | |||
304 | | ||||
305 | //@} | | |||
306 | | ||||
307 | //* frame radius | 287 | //* frame radius | ||
308 | 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 | ||
309 | { return qMax( Metrics::Frame_FrameRadius - (0.5 * penWidth) + bias, 0.0 ); } | 289 | { return qMax( Metrics::Frame_FrameRadius - (0.5 * penWidth) + bias, 0.0 ); } | ||
310 | 290 | | |||
311 | //* frame radius with new pen width | 291 | //* frame radius with new pen width | ||
312 | constexpr qreal frameRadiusForNewPenWidth( const qreal oldRadius, const int penWidth ) const | 292 | constexpr qreal frameRadiusForNewPenWidth( const qreal oldRadius, const int penWidth ) const | ||
313 | { return qMax( oldRadius - (0.5 * penWidth), 0.0 ); } | 293 | { return qMax( oldRadius - (0.5 * penWidth), 0.0 ); } | ||
314 | 294 | | |||
315 | //* 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 | ||
316 | QRectF strokedRect( const QRectF &rect, const int penWidth = PenWidth::Frame ) const; | 296 | QRectF strokedRect( const QRectF &rect, const int penWidth = PenWidth::Frame ) const; | ||
317 | 297 | | |||
318 | //* 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 | ||
319 | QRectF strokedRect( const QRect &rect, const int penWidth = PenWidth::Frame ) const; | 299 | QRectF strokedRect( const QRect &rect, const int penWidth = PenWidth::Frame ) const; | ||
320 | 300 | | |||
321 | protected: | 301 | protected: | ||
322 | 302 | | |||
323 | //* initialize | | |||
324 | void init(); | | |||
325 | | ||||
326 | //* 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 | ||
327 | QPainterPath roundedPath( const QRectF&, Corners, qreal ) const; | 304 | QPainterPath roundedPath( const QRectF&, Corners, qreal ) const; | ||
328 | 305 | | |||
329 | private: | 306 | private: | ||
330 | 307 | | |||
331 | //* configuration | 308 | //* configuration | ||
332 | KSharedConfig::Ptr _config; | 309 | KSharedConfig::Ptr _config; | ||
333 | 310 | | |||
334 | //*@name brushes | 311 | //*@name brushes | ||
335 | //@{ | 312 | //@{ | ||
336 | KStatefulBrush _viewFocusBrush; | 313 | KStatefulBrush _viewFocusBrush; | ||
337 | KStatefulBrush _viewHoverBrush; | 314 | KStatefulBrush _viewHoverBrush; | ||
338 | KStatefulBrush _viewNegativeTextBrush; | 315 | KStatefulBrush _viewNegativeTextBrush; | ||
339 | //@} | 316 | //@} | ||
340 | 317 | | |||
341 | //*@name windeco colors | 318 | //*@name windeco colors | ||
342 | //@{ | 319 | //@{ | ||
343 | QColor _activeTitleBarColor; | 320 | QColor _activeTitleBarColor; | ||
344 | QColor _activeTitleBarTextColor; | 321 | QColor _activeTitleBarTextColor; | ||
345 | QColor _inactiveTitleBarColor; | 322 | QColor _inactiveTitleBarColor; | ||
346 | QColor _inactiveTitleBarTextColor; | 323 | QColor _inactiveTitleBarTextColor; | ||
347 | //@} | 324 | //@} | ||
348 | 325 | | |||
349 | #if BREEZE_HAVE_X11 | | |||
350 | | ||||
351 | //* atom used for compositing manager | | |||
352 | xcb_atom_t _compositingManagerAtom; | | |||
353 | | ||||
354 | #endif | | |||
355 | | ||||
356 | }; | 326 | }; | ||
357 | 327 | | |||
358 | } | 328 | } | ||
359 | 329 | | |||
360 | #endif | 330 | #endif |