Comments (5)
if I modify the drawMenuRect to add padding, it does not fit inside the available space
- (void) drawMenuRect: (NSRect)rect
inView: (NSView *)view
isHorizontal: (BOOL)horizontal
itemCells: (NSArray *)itemCells
{
int i = 0;
int howMany = [itemCells count];
NSMenuView *menuView = (NSMenuView *)view;
NSRect bounds = [view bounds];
CGFloat padding = 5.0; // Ajusta aquest valor per controlar el padding
[self drawBackgroundForMenuView: menuView
withFrame: bounds
dirtyRect: rect
horizontal: horizontal];
// Draw the menu cells with padding.
for (i = 0; i < howMany; i++)
{
NSRect aRect;
NSMenuItemCell *aCell;
aRect = [menuView rectOfItemAtIndex: i];
// Ajustar el rectangle per afegir padding
if (horizontal) {
aRect.origin.x += padding;
aRect.size.width -= padding * 2;
} else {
aRect.origin.y += padding;
}
if (NSIntersectsRect(rect, aRect) == YES)
{
aCell = [menuView menuItemCellForItemAtIndex: i];
[aCell drawWithFrame: aRect inView: menuView];
}
}
}
from libs-gui.
How does this image relate to the code you are showing here. That's not a theme I recognize. Is the attached image to illustrate what you're trying to achieve?
from libs-gui.
I tried to add some distance between the limits of the menu popover and the list of items.
The size of the menu popover is decided before the drawing (drawMenuRect), so it is not possible to add 'padding' to enclose the list of items at the center of the popover.
Theming needs a way to define each side padding (top, bottom, left, right) and position the list of items properly, like in the example image.
from libs-gui.
Yes, this is a real issue. Would it be sufficient for you to just have a way to influence the _leftBorderOffset or do you really need a different offset for all the different borders?
from libs-gui.
At least different values for horizontal and vertical panning. But why not use NSEdgeInsets?
from libs-gui.
Related Issues (20)
- NSShadow does not work HOT 21
- NSMenu ignores initWithTitle HOT 1
- theming does not allow to disable text movement while clicking a button HOT 2
- theming does not allow to define the border radius of menu items HOT 2
- theming does not allow to define the text color of the overed menu item HOT 2
- theming does not allow to define border radius of menu popover HOT 1
- NSCircularBezelStyle should cut text HOT 5
- Theming must allow define text color per each style HOT 3
- NSRoundedDisclosure ... not reporting an appropiate state HOT 1
- Theming should be able to define 'accept button' style HOT 4
- NSBezierPath does not clip gradients HOT 6
- Support NIBArchive format HOT 3
- CTButtonTypeSwitch does not show mixed state
- Segmentation Fault with autohidesScrollers = YES HOT 5
- Images disappear after Display Resolution Change HOT 2
- hasHorizontalScroller = NO; ignored if autohidesScrollers = YES; HOT 2
- Allow multiple selection on NSSegmentedControl
- Wrong size for NSSegmentedControl sizeToFit
- Add setBezelColor for NSButton
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libs-gui.