Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions src/dll/src/ContextMenu.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include <pch.h>
#include "Include/Theme.h"
#include "Include/ContextMenu.h"
Expand Down Expand Up @@ -2175,6 +2174,11 @@ namespace Nilesoft
rcblock.top += _theme.back.margin.top;
rcblock.bottom -= _theme.back.margin.bottom;

// Ensure we have at least minimal height for the item
if (rcblock.height() < 4) {
rcblock.bottom = rcblock.top + 4;
}

if(mii->cch > 0 || !menu->has_col)
{
rcblock.left += _theme.back.margin.left;
Expand All @@ -2186,6 +2190,11 @@ namespace Nilesoft
rcblock.right -= _theme.back.margin.right + dpi(3);
}

// Ensure proper width for the item
if (rcblock.width() <= 0) {
rcblock.right = rcblock.left + 10;
}

const auto width = rcblock.width();
const auto height = rcblock.height();

Expand All @@ -2195,6 +2204,14 @@ namespace Nilesoft
rcimg.top = rcblock.top + ((height - image_size) / 2);
rcimg.bottom = rcimg.top + image_size;

// Fix for last item - ensure image rectangle has valid dimensions
if (rcimg.bottom > rc->bottom) {
rcimg.bottom = rc->bottom - 1;
if (rcimg.height() < 4) {
rcimg.top = rcimg.bottom - 4;
}
}

if(mii->cch > 0 || !menu->has_col)
{
if(mii->cch == 0)
Expand Down Expand Up @@ -2233,6 +2250,11 @@ namespace Nilesoft
border_color = _theme.back.border.nor_dis;
}

// Ensure we don't draw outside the item's rectangle
RECT clipRect = *rc;
dc.save_dc();
dc.intersect_clip_rect(clipRect);

//dc.draw_fill_rounded_rect(rcblock, _theme.back.radius+2, 0,0);
//draw_rect(&dc, rcblock.point(), { width, height }, 0xff000000, {}, _theme.back.radius);
//draw_rect(&dc, rcblock.point(), { width, height }, _theme.background.color, {}, _theme.back.radius);
Expand All @@ -2241,6 +2263,8 @@ namespace Nilesoft
back_color.a = op;
draw_rect(&dc, rcblock.point(), { width, height }, back_color, border_color, _theme.back.radius);
}

dc.restore_dc();
}

auto has_checked_image = menu->draw.checks && menu->draw.images && (_theme.image.display >= 2);
Expand Down Expand Up @@ -3588,7 +3612,7 @@ namespace Nilesoft

//New feature "showdelay" to change the menu show delay time and it is applied immediately without saving the value in the registry.
//Gets or sets the time, in milliseconds, that the system waits before displaying a shortcut menu when the mouse cursor is over a submenu item.
//New-Item -Path HKCU:\Software\Control Panel\Desktop -Name MenuShowDelay -Force -Value 200
//New-Item -Path "HKCU:\Software\Control Panel\Desktop" -Name MenuShowDelay -Force -Value 200
if(_context.eval_number(sets->showdelay, obj))
{
::SystemParametersInfoW(SPI_GETMENUSHOWDELAY, 0, &_showdelay[0], 0);
Expand Down
Loading