On Thursday 19 July 2001 09:56, Jean-Marc Lasgouttes wrote:
> >>>>> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes:
>
> >> I will also need a way of toggling or, alternatively, to know
> >> whether an inset is open or closed. Is that possible?
> >>
> >> JMarc
>
> Angus> Does this cover it? Angus
>
> Angus, I tried yesterday to implement this stuff, and miserably failed
> :( It would help me a lot if you could do a sample implementation of
> this idea for one inset (pick the one you prefer :).
>
> Currently, I have implemented inset toggling for collapsable insets
> only. What remains to be done is
>
> 1/ implement it for insets which have a dialog
>
> 2/ see what to do with others, like math inset. What would be a
> reasonable open/close action? Toggle the math panel?
Aren't things as simple as this:
We want a member variable in the inset:
enum DialogStatus {
DIALOG_OPEN,
DIALOG_CLOSED
};
DialogStatus status;
I think that things will be cleanest if this variable is set by the dialog:
template <class Inset, class Params>
void ControlInset<Inset, Params>::hide()
{
if (params_) {
delete params_;
params_ = 0;
}
clearDaughterParams();
if (inset_) {
inset_.status = DIALOG_CLOSED;
inset_ = 0;
}
ih_.disconnect();
disconnect();
view().hide();
}
template <class Inset, class Params>
void ControlInset<Inset, Params>::connectInset(Inset * inset)
{
// If connected to another inset, disconnect from it.
if (inset_) {
ih_.disconnect();
inset_ = 0;
}
if (inset) {
inset_ = inset;
inset_.status = DIALOG_OPEN;
ih_ = inset->hideDialog.connect(
SigC::slot(this, &ControlInset::hide));
}
connect();
}
Finally, we need a method Inset::toggle():
void Inset::toggle()
{
if (status == DIALOG_OPEN)
hideDialog();
else
emit();
}
Angus