diff options
author | Morten Johan Sørvig <morten.sorvig@digia.com> | 2014-02-13 14:14:44 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-20 22:12:47 +0100 |
commit | 3b8b47db6aaeb333f106cff57cc712b01d828302 (patch) | |
tree | ddc23c12694293279f0fb5aba33f23d5b280e13d /src/plugins/platforms/cocoa/qcocoawindow.mm | |
parent | 2bc7a40048ada41c59ddac0988bb2e04c227a18d (diff) |
Set unified toolbar height accurately.
Add registerContentBorderArea() to the Cocoa native
interface which allows registering multiple "unified
toolbar" areas for each window.
Use this function in QToolBarLayout::setGeometry()
to register the area for each TopToolBarArea toolbar.
Task-number: QTBUG-36700
Change-Id: I52efcc5662556bb94f25f504be3710d0491f79b9
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Reviewed-by: Denis Dzyubenko <denis@ddenis.info>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index d8ec144ad2..bbd5dd7311 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1540,15 +1540,46 @@ void QCocoaWindow::setContentBorderThickness(int topThickness, int bottomThickne applyContentBorderThickness(m_nsWindow); } +void QCocoaWindow::registerContentBorderArea(quintptr identifier, int upper, int lower) +{ + m_contentBorderAreas.insert(identifier, BorderRange(upper, lower)); + + // Find consecutive registered border areas, starting from the top. + QList<BorderRange> ranges = m_contentBorderAreas.values(); + std::sort(ranges.begin(), ranges.end()); + m_topContentBorderThickness = 0; + foreach (BorderRange range, ranges) { + // Is this sub-range adjacent to or overlaping the + // existing total border area range? If so merge + // it into the total range, + if (range.upper <= (m_topContentBorderThickness + 1)) + m_topContentBorderThickness = qMax(m_topContentBorderThickness, range.lower); + else + break; + } + + m_bottomContentBorderThickness = 0; // (not supported) + if (m_drawContentBorderGradient) + applyContentBorderThickness(m_nsWindow); +} + +void QCocoaWindow::enableContentBorderArea(bool enable) +{ + m_drawContentBorderGradient = enable; + applyContentBorderThickness(m_nsWindow); +} + void QCocoaWindow::applyContentBorderThickness(NSWindow *window) { if (!window) return; - if (m_drawContentBorderGradient) - [window setStyleMask:[window styleMask] | NSTexturedBackgroundWindowMask]; - else + if (!m_drawContentBorderGradient) { [window setStyleMask:[window styleMask] & ~NSTexturedBackgroundWindowMask]; + return; + } + + [window setStyleMask:[window styleMask] | NSTexturedBackgroundWindowMask]; if (m_topContentBorderThickness > 0) { [window setContentBorderThickness:m_topContentBorderThickness forEdge:NSMaxYEdge]; |