Skip to content

Commit

Permalink
draw an outline in edit mode for the JavaScriptDrawableView
Browse files Browse the repository at this point in the history
  • Loading branch information
scheffle committed Jan 21, 2024
1 parent 8b7dbb8 commit 907ab20
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions vstgui/uidescription-scripting/uiscripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,25 @@ void DrawContextObject::onDestroy (CScriptVar* v)
void JavaScriptDrawableView::drawRect (CDrawContext* context, const CRect& rect)
{
if (!scriptObject)
{
auto dashLength = std::round ((getWidth () * 2 + getHeight () * 2) / 40.);
CLineStyle ls (CLineStyle::kLineCapButt, CLineStyle::kLineJoinMiter, 0,
{dashLength, dashLength});

auto lineWidth = 1.;
auto size = getViewSize ();
size.inset (lineWidth / 2., lineWidth / 2.);
context->setLineStyle (ls);
context->setLineWidth (lineWidth);
context->setFrameColor (kBlackCColor);
context->drawRect (size, kDrawStroked);

ls.setDashPhase (dashLength * lineWidth);
context->setLineStyle (ls);
context->setFrameColor (kWhiteCColor);
context->drawRect (size, kDrawStroked);
return;
}
auto scriptContext = scriptObject->getContext ();
if (!scriptContext)
return;
Expand Down

0 comments on commit 907ab20

Please sign in to comment.