Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

19 May, 2024: Line wrapping has been changed to be more consistent with Usenet standards.
 If you find that it is broken please let me know here rocksolid.nodes.help


devel / comp.lang.c++ / Design of alternative to self-destroying GUI widgets

SubjectAuthor
o Design of alternative to self-destroying GUI widgetsAlf P. Steinbach

1
Design of alternative to self-destroying GUI widgets

<udfo4k$3j8ic$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=1353&group=comp.lang.c%2B%2B#1353

  copy link   Newsgroups: comp.lang.c++
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: alf.p.st...@gmail.com (Alf P. Steinbach)
Newsgroups: comp.lang.c++
Subject: Design of alternative to self-destroying GUI widgets
Date: Fri, 8 Sep 2023 20:11:31 +0200
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <udfo4k$3j8ic$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 8 Sep 2023 18:11:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c6c938929b2db1a55211416cf07112b8";
logging-data="3777100"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PVLwcc6JSOjUkMHFS+Qli"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.0
Cancel-Lock: sha1:94ME/QO3Mm80j+Y2vNMccPjhZDA=
Content-Language: en-US
 by: Alf P. Steinbach - Fri, 8 Sep 2023 18:11 UTC

Due to a question in Reddit's main beginners' C++ group (about parallel
implementation class hierarchies) I sat down and tried to code up a
portable widget definitions, such that the low level OS-specific widget
that provides the implementation of a portable widget, exists from
successful construction of the portable widget object, until destruction
of the portable widget object, where it's that high level destruction
that effects the low level OS-specific widget destruction and not vice
versa.

Avoiding self-destruction avoids the need to allocate widget objects
dynamically, which I think is desirable for ease of use.

But then e.g. a main window object will need to cause its own
destruction by informing the event loop to finish up, whereas some other
top level window must do something else.

So far I ended up with code like this:

#include "gui.hpp"

auto main() -> int
{
auto event_dispatcher = gui::Event_dispatcher();
auto window = gui::Main_window( [&]{
event_dispatcher.finish(); } );

window.set_startup_displaystate();
event_dispatcher.dispatch_events();
}

Is that a reasonable design? I'm not sure how to fix the ugliness that
user code has to connect things that ideally should Just Work.

I considered for a while a kind of design where the high level object
could instead transition to zombie state where the low level OS specific
widget is destroyed, but it felt wrong and Microsoft-ish.

- Alf


devel / comp.lang.c++ / Design of alternative to self-destroying GUI widgets

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor