lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Ellipses in menus


From: Vadim Zeitlin
Subject: Re: [lmi] Ellipses in menus
Date: Tue, 10 Nov 2015 14:37:16 +0100

On Mon, 19 Oct 2015 03:36:00 +0000 Greg Chicares <address@hidden> wrote:

GC> On 2015-10-18 19:34, Vadim Zeitlin wrote:
GC> > On Sun, 18 Oct 2015 16:56:36 +0000 Greg Chicares <address@hidden> wrote:
GC> > 
GC> > GC>   20151018T1612Z Refactor
GC> > GC> Removed irregularities: two File menus used as <object_ref> without
GC> > GC> explanation, and a third written inline with explanation.
GC> > GC> 
GC> > GC> Is there a more tasteful way to do this? Ideally we'd code "File | 
Open"
GC> > GC> once and only once.
GC> > 
GC> >  I think the best way to do this would be to have a single file menu, with
GC> > all the items, and then remove those that we don't need after loading it.
GC> > As usual, patches doing this could be made available if there is any
GC> > interest in them.
GC> 
GC> Yes, please: I'm definitely interested. Or, more precisely, I will become
GC> interested after Halloween. Skeleton::AdjustMenus() already does something
GC> similar.

 Thanks for the pointer, I've indeed decided to reuse this function to do
the file menu adjustments as well as it seemed logical to keep all of them
in a single place. This did require adding a new ViewEx::CanBePrinted()
method to allow assigning the proper menu to each view, but IMO it makes
sense to have it anyhow.

 Other than that, I'm not too happy with the loop iterating over the menu
items and deleting the unwanted ones, but I'm afraid it's the best that can
be done with the current API: the problem is that the items themselves have
no relationship to each other and we can't ask the item for the next one,
so we have to iterate over the list of all of them and, as usual when
iterating and removing at the same time, the code is somewhat of a mess.
An alternative could be to iterate once to find the IDs of all the items to
delete and then just delete them by ID in a loop. This would be O(N^2) but
we don't care about this for N=4, the real problem is that we'd still have
to write a third loop cleaning up the consecutive separators and I thought
that one complicated loop was, on balance, preferable, to 3 slightly
simpler ones. But please let me know if you disagree.

 As usual, I've tested this with both MSVC and MinGW and I did by opening
or creating new documents of all possible types and verifying that the file
menu contained the expected items. I also checked that this was the case on
startup, i.e. for the main frame menu when there are no children.

 Please let me know if you have any questions about or improvements to this
patch, thanks in advance,
VZ

Attachment: 0001-Use-a-single-file-menu-adjusted-in-the-code.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]