Ticket #4102 (closed enhancement: fixed)

Opened 3 months ago

Last modified 8 weeks ago

[PATCH] Dialogs and menus have shadows

Reported by: kybl Owned by: andrew_b
Priority: minor Milestone: 4.8.26
Component: mc-core Version: master
Keywords: Cc:
Blocked By: Blocking:
Branch state: merged Votes for changeset: committed-master

Description

Hi,
I like Midnight Commander very much but I think that - comparing with Norton Commander, Volkov Commander, or Far Manager - it is not as "nice" from the user experience perspective. I will try to fix that in several next pull requests (if there will be an interest).

One of the things that are not so important but I miss it a lot, is the dialog "shadows". It is something that makes dialogs and menus "above" the rest of the screen, dialogs are not such flat. You can know them from all Norton, Volkov, and Far, which use them by default (and AFAIK there is not even an option to disable them).

Here is a patch that adds an option to enable dialog shadows (it is disabled by default, though).

It works as follows:

  • there is a new option in Options => Configuration... => Dialog shadows
  • it uses a new color in skin: [core] => shadow
  • when a dialog or menu is opened, the background is changed to the shadow color on the right and bottom part of the dialog. Just like dialog would create a shadow on the background (see screenshots)
  • it works for all dialogs and menus, even in mcedit, etc.

It works basically in the same way how other commanders do. And it is nicer :-)

I tested it in both Slang and Ncurses on Linux, in both "konsole" emulator, and terminal. The first patch contains code itself, man update, Czech translation. The second patch contains all skins update. Hopefully, it should be usable as-is.

Please let me know if you have any comments. Thanks.

Attachments

dialog-shadow-code.patch (18.5 KB) - added by kybl 3 months ago.
Patch for source code
dialog-shadows-skins.patch (14.3 KB) - added by kybl 3 months ago.
Patch for all skins
window-with-shadow.png (44.9 KB) - added by kybl 3 months ago.
window with a shadow, default skin
menu.png (46.5 KB) - added by kybl 3 months ago.
menu with a shadow, default skin
window-on-window-other-skin.png (50.2 KB) - added by kybl 3 months ago.
window on a window with shadows, seasons-summer skin
editor.png (36.2 KB) - added by kybl 3 months ago.
shadows in mcedit
dialog-shadow-2.patch (29.9 KB) - added by andrew_b 3 months ago.
mcedit-windows.png (21.7 KB) - added by andrew_b 3 months ago.
shadows-in-editor-MDI.png (56.6 KB) - added by kybl 3 months ago.
shadows in MDI in mcedit (see text inside screenshot)

Change History

Changed 3 months ago by kybl

Patch for source code

Changed 3 months ago by kybl

Patch for all skins

Changed 3 months ago by kybl

window with a shadow, default skin

Changed 3 months ago by kybl

menu with a shadow, default skin

Changed 3 months ago by kybl

window on a window with shadows, seasons-summer skin

Changed 3 months ago by kybl

shadows in mcedit

comment:1 follow-up: ↓ 2 Changed 3 months ago by zaytsev

Wow, that looks very cool, what do you think, Andrew?

comment:2 in reply to: ↑ 1 Changed 3 months ago by andrew_b

Replying to zaytsev:

Wow, that looks very cool, what do you think, Andrew?

Really cool.

I made some modifications in the original patch:

  • made dialog_shadows option a member of mc_global_t::vfs
  • moved "Dialog shadows" checkbox to "Appearance" dialog window. Shadows are on by default. Checkbox is disabled in case of BW mode. The changing of checkbox state is visualized immediately.
  • made some changes in tty functions.

Patch was not fully tested.

Changed 3 months ago by andrew_b

comment:3 Changed 3 months ago by andrew_b

What about applied shadows to editor windows?

comment:4 follow-up: ↓ 5 Changed 3 months ago by kybl

Thanks! I like that it is as cool for you as for me!

I made some modifications in the original patch:

Seems good!

Shadows are on by default.

Great! :-)

What about applied shadows to editor windows?

What do you mean by "editor windows"? I don't understand.

comment:5 in reply to: ↑ 4 ; follow-up: ↓ 6 Changed 3 months ago by andrew_b

Replying to kybl:

What about applied shadows to editor windows?

What do you mean by "editor windows"? I don't understand.

mceditor has Multiple-document interface (#2261). See attached screenshot.

Changed 3 months ago by andrew_b

comment:6 in reply to: ↑ 5 ; follow-up: ↓ 8 Changed 3 months ago by kybl

What do you mean by "editor windows"? I don't understand.

mceditor has Multiple-document interface (#2261). See attached screenshot.

Thanks, I see. I never used it in this way, though. I tried to apply shadows at this case as well (patching editor/editraw.c:edit_draw_frame). I'm not sure about the typical scenario but I can imagine screen split to two halves – one file on the left, the other one on the right. Or one on top, one on the bottom. In that case, when I have focus on the left (or top) window, there is shadow through the other window. See screenshot. It is quite misleading.

So, personally, I would not apply window shadows in the editor.

Also, I found that when I move a window partially out of the screen to the left, the shadow on the bottom disappears. It is because there is a check in tty_colorize_area if the top left corner of the shadow is on the screen (yx_in_screenx). Maybe that condition is wrong (or not needed at all - it works fine even without it, at least at S-Lang version). Not sure if that can happen in other scenarios.

Changed 3 months ago by kybl

shadows in MDI in mcedit (see text inside screenshot)

comment:7 Changed 3 months ago by ossi

yeah, the shadows don't mix well with tiled windows and windows that touch screen corners. i'd leave it off the MDI, too.

comment:8 in reply to: ↑ 6 Changed 3 months ago by Roman

Replying to kybl:

Also, I found that when I move a window partially out of the screen to the left, the shadow on the bottom disappears.


Hi,
I tried to fix it. Now everything should be fine.
But I haven't tested this code (only on paper and in my mind).
If you have any questions, please ask.

void 
tty_colorize_area (int y, int x, int rows, int cols, int color) 
{ 
    cchar_t *ctext; 
    wchar_t wch[10];   /* TODO not sure if the length is correct */ 
    attr_t attrs; 
    short color_pair; 

    if (!use_colors || rows <= 0 || cols <= 0 || y >= LINES
            || x >= COLS || (x + cols) <= 0 || (y + rows) <= 0) 
        return;

    if (x < 0)
    {
        cols += x;
        x = 0;
    }
    
    if ((x + cols) > COLS)
    {
        cols = COLS - x;
    }
 
    tty_setcolor (color); 
    ctext = g_malloc (sizeof (cchar_t) * (cols + 1)); 
 
    for (int row = 0; row < rows; row++) 
    { 
        if ((y + row) >= 0 && (y + row) < LINES)
        {
            mvin_wchnstr (y + row, x, ctext, cols); 
    
            for (int col = 0; col < cols; col++) 
            { 
                getcchar (&ctext[col], wch, &attrs, &color_pair, NULL); 
                setcchar (&ctext[col], wch, attrs, color, NULL); 
            } 
    
            mvadd_wchnstr (y + row, x, ctext, cols);
        }
    } 
 
    g_free (ctext); 
}

comment:9 Changed 3 months ago by andrew_b

I think, tty_fill_region(), tty_draw_hline(), and tty_draw_vline() can be used as reference how to draw rectangle area.
See also [e1f2b5b017803ae81312a6195272dfdf644800fb].

comment:10 Changed 2 months ago by zaytsev

I like MDI shadows in RHIDE, but if I understand it correctly this requires a real z-index system, so I would just forego MDI shadows in mcedit...

comment:11 Changed 2 months ago by andrew_b

  • Status changed from new to accepted
  • Owner set to andrew_b
  • Component changed from mc-skin to mc-core
  • Branch state changed from no branch to on review
  • Milestone changed from Future Releases to 4.8.26

comment:12 Changed 8 weeks ago by andrew_b

  • Votes for changeset set to andrew_b
  • Branch state changed from on review to approved

comment:13 Changed 8 weeks ago by andrew_b

  • Status changed from accepted to testing
  • Votes for changeset changed from andrew_b to committed-master
  • Resolution set to fixed
  • Branch state changed from approved to merged

comment:14 Changed 8 weeks ago by andrew_b

  • Status changed from testing to closed
Note: See TracTickets for help on using tickets.