Skip to content

Commit

Permalink
Traktor: Show "restore" icon to caption bar when form is maximized.
Browse files Browse the repository at this point in the history
  • Loading branch information
apistol78 committed May 21, 2024
1 parent 90fe910 commit ea39a56
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 2 deletions.
11 changes: 9 additions & 2 deletions code/Ui/CaptionBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,13 @@ void CaptionBar::eventMouseMove(MouseMoveEvent* event)
if (!m_haveCapture)
return;

const Point position = getParent()->clientToScreen(event->getPosition());
Form* parentForm = dynamic_type_cast< Form* >(getAncestor());
if (!parentForm)
return;

const Point position = parentForm->clientToScreen(event->getPosition());
const Rect rc = m_parentRect.offset(position - m_mousePosition);
getParent()->setRect(rc);
parentForm->setRect(rc);

event->consume();
}
Expand All @@ -142,8 +146,11 @@ void CaptionBar::eventSize(SizeEvent* event)
}

{
const Form* parentForm = dynamic_type_cast< const Form* >(getAncestor());
const bool maximized = (parentForm != nullptr) ? parentForm->isMaximized() : false;
const Size sz = m_buttonMaximizeOrRestore->getPreferredSize(Size(0, 0));
m_buttonMaximizeOrRestore->setRect({ Point(r - sz.cx, (h - sz.cy) / 2), Size(sz.cx, sz.cy) });
m_buttonMaximizeOrRestore->setImage(new ui::StyleBitmap(maximized ? L"UI.CaptionRestore" : L"UI.CaptionMaximize"));
r -= sz.cx + pad;
}

Expand Down
103 changes: 103 additions & 0 deletions resources/runtime/themes/Shared/Images/UI/Restore.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions resources/runtime/themes/Shared/StyleSheet.xss
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,10 @@
<first>UI.CaptionMaximize</first>
<second>$(Images.Path)/UI/Maximize.svg</second>
</item>
<item>
<first>UI.CaptionRestore</first>
<second>$(Images.Path)/UI/Restore.svg</second>
</item>
<item>
<first>UI.Checked</first>
<second>$(Images.Path)/UI/Checked.svg</second>
Expand Down

0 comments on commit ea39a56

Please sign in to comment.