Closed SamSandq closed 8 months ago
Hi @SamSandq!
Use layout_bgcolor()
in the layout of main panel cover all window area.
You are right, if I do it for the main layout in the main panel it indeed does what I want.
If I don't, and only gve sublayouts colours, their margins are not coloured.
However, leaving sublayouts without colours is fine and achieves what I want.
layout_bgcolor()
and layout_skcolor()
covers the entire layout (included the inner margin defined by layout_margin[2|4]()
.
Is it possible that non-colored margins belong a parent layout? If not, please send a screenshot with layout relations, because would be in issue to review.
Thanks Sam!
Looks like the margins of sublayouts are not coloured, and the parent layout's colours show through. However, the parent's margins are coloured, so there is definitely an inconsistency here. See the picture, where the sublayouts are coloured and the parent is not.
Ok, I will leave this issue open for testing this case.
Layout coloring has been fully testing in this demo: https://nappgui.com/en/howto/drawbig.html#h7 Only detected an issue in Windows drawing order. Please reopen this issue providing compileable code if the problem persists.
I reopen this because I found the problem. Test with
add labels:
Label *lb = label_new("Test1");
layout_label(filtLayout, lb, 6, 0);
label_bgcolor(lb, kCOLOR_GREEN);
Label *lbv = label_new("Test2");
layout_label(filtLayout, lbv, 7, 0);
The result is this (I use it at the top of my app as a testbed, which shows how the colour is bleeding all over the place):
Now correct this by changing in oslabel.m: - (void) drawRect:(NSRect)rect
, line 104:
now:
draw_rect(self->ctx, ekFILL, 0, 0, (real32_t)rect.size.width, (real32_t)rect.size.height);
should be:
NSRect myrect = [self bounds];
draw_rect(self->ctx, ekFILL, 0, 0, (real32_t) myrect.size.width, (real32_t) myrect.size.height);
In other words, one must not exceed the bounds of the control.
The result is now correct:
It is possible that the same problem occurs elsewhere, I have not checked.
In oslabel (macOS), incoming rectangle in drawRect
must be the same of control bounds. If not, is because other issue has this collateral effect. By the images, I can intuit that the Label frame has been changed, but I don't know why. Please report some compilable code in order to debug the origin of the problem. Reviewing all the use of Label in NAppGUI applications, this case does not arise.
The only thing slightly out of the ordinary is that the layout where this happens is a sublayout.
I'll try to get you a full example.
Sam
Den sön 17 mars 2024 kl 16:31 skrev Francisco García Collado < @.***>:
In oslabel (macOS), incoming rectangle in drawRect must be the same of control bounds. If not, is because other issue has this collateral effect. By the images, I can intuit that the Label frame has been changed, but I don't know why. Please report some compilable code in order to debug the origin of the problem. Reviewing all the use of Label in NAppGUI applications, this case does not arise.
label_rect_bounds.png (view on web) https://github.com/frang75/nappgui_src/assets/42999199/c95121a0-a935-4ea8-98a3-10d9c62e8332
— Reply to this email directly, view it on GitHub https://github.com/frang75/nappgui_src/issues/87#issuecomment-2002491600, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMAVI5XJUI3EVSWYGZDOYN3YYWSKXAVCNFSM6AAAAABBZMA4UGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBSGQ4TCNRQGA . You are receiving this because you were mentioned.Message ID: @.***>
I copied your NappHello.c to a clean directory, and added a line below the label.
label_text(label, "Hello!, I'm a label");
label_bgcolor(label, kCOLOR_GREEN);
The result was like this
with my correction it looks like this:
which is what I expected.
OMG! Its the same macOS Sonoma problem that OSView clipping. https://developer.apple.com/documentation/macos-release-notes/appkit-release-notes-for-macos-14#NSView
Fixed in this commit: https://github.com/frang75/nappgui_src/commit/d7930efee0031f8b4269601fe767a695e5e9ff20
Thanks so much for report! I forget that two modules are related. All my tests are in Ventura OS.
I want to give my window a nice grey background colour.
I found the layout_bgcolor() and layout_skcolor() functions that will give my layouts the required colour... however, the layouts also have margins, and these are not coloured.
How can I assign a colour to the margins? I thought that the layout_skcolour should do it but it does not.