Git Product home page Git Product logo

Comments (5)

optimisme avatar optimisme commented on September 22, 2024

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.

gcasa avatar gcasa commented on September 22, 2024

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.

optimisme avatar optimisme commented on September 22, 2024

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.

Screenshot 2023-12-22 at 06 46 42

from libs-gui.

fredkiefer avatar fredkiefer commented on September 22, 2024

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.

optimisme avatar optimisme commented on September 22, 2024

At least different values for horizontal and vertical panning. But why not use NSEdgeInsets?

from libs-gui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.