diff --git a/src/gui/dttview/TLGOptions.cc b/src/gui/dttview/TLGOptions.cc index 22f3bf40320608d6ef5686e2a5bed01327f89efe..1c6c92d8675ea52149ddc8331cc64a190326eca0 100644 --- a/src/gui/dttview/TLGOptions.cc +++ b/src/gui/dttview/TLGOptions.cc @@ -10,6 +10,7 @@ // #include <TAttTextCanvas.h> #include <TGListBox.h> #include <TGMsgBox.h> +#include <TGTableLayout.h> static const int my_debug = 0 ; @@ -1133,14 +1134,14 @@ namespace ligogui { { // Layout hints fL1 = new TGLayoutHints (kLHintsLeft | kLHintsTop, 2, 2, 2, 2); - fL2 = new TGLayoutHints (kLHintsRight | kLHintsBottom, 2, 12, 2, 2); + fL2 = new TGLayoutHints (kLHintsRight | kLHintsTop, 2, 12, 2, 2); fL3 = new TGLayoutHints (kLHintsLeft | kLHintsCenterY, 0, 3, 2, 2); fL4 = new TGLayoutHints (kLHintsExpandX | kLHintsCenterY, 0, 0, 2, 2); fL5 = new TGLayoutHints (kLHintsExpandX | kLHintsTop, 0, 0, 2, 0); fL6 = new TGLayoutHints (kLHintsExpandX | kLHintsTop, 0, 0, 2, -4); fL7 = new TGLayoutHints (kLHintsExpandX | kLHintsTop, 0, 0, 0, 4); fL8 = new TGLayoutHints (kLHintsExpandX | kLHintsExpandY | kLHintsTop, - 0, 0, 0, 4); + 0, 0, 5, 4); fL9 = new TGLayoutHints (kLHintsExpandX | kLHintsTop, 0, 0, 2, -8); // Group frames fG2 = new TGGroupFrame (this, "Units"); @@ -1970,7 +1971,7 @@ namespace ligogui { fL1 = new TGLayoutHints (kLHintsExpandX | kLHintsTop, 0, 0, 4, 4); fL2 = new TGLayoutHints (kLHintsExpandX | kLHintsTop, 0, 0, 4, 0); fL3 = new TGLayoutHints (kLHintsLeft | kLHintsExpandX | - kLHintsBottom, 5, 5, 4, 4); + kLHintsTop, 5, 5, 4, 4); fL4 = new TGLayoutHints (kLHintsRight | kLHintsCenterY, 5, 5, 2, 2); fL5 = new TGLayoutHints (kLHintsExpandX | kLHintsTop, 0, 0, 4, -4); fL6 = new TGLayoutHints (kLHintsExpandX | kLHintsTop, 20, 0, 4, 0); @@ -2662,152 +2663,173 @@ namespace ligogui { OptionLegend_t* optvals) : TLGOptions (p, kGOptLegendName, id, optvals) { - // Layout hints - fL1 = new TGLayoutHints (kLHintsLeft | kLHintsTop, 3, 2, 2, 2); - fL2 = new TGLayoutHints (kLHintsExpandX | kLHintsCenterY, 0, 0, 1, -10); - fL3 = new TGLayoutHints (kLHintsLeft | kLHintsCenterY, 0, 3, 2, 2); - fL4 = new TGLayoutHints (kLHintsExpandX | kLHintsCenterY, 0, 0, 1, 1); - fL5 = new TGLayoutHints (kLHintsExpandX | kLHintsTop, 0, 0, 0, 0); - fL6 = new TGLayoutHints (kLHintsExpandX | kLHintsTop, -2, -2, 4, 2); - fL7 = new TGLayoutHints (kLHintsExpandX | kLHintsTop, 0, 0, 0, 4); - fL8 = new TGLayoutHints (kLHintsExpandX | kLHintsTop, 3, 3, 0, 0); - static TGLayoutHints *fL9 = new TGLayoutHints (kLHintsLeft | kLHintsCenterY, 0, 3, 2, 20); - // group frames - fFS = new TGHorizontalFrame (this, 100, 100); - AddFrame (fFS, fL7); - fGP = new TGGroupFrame (this, "Placement"); - AddFrame (fGP, fL7); - fGS = new TGGroupFrame (this, "Symbol style"); - AddFrame (fGS, fL7); - fGT = new TGGroupFrame (this, "Text"); - AddFrame (fGT, fL7); - // show - fShow = new TGCheckButton (fFS, "Show", kGOptLegendShow); - fShow->Associate (this); - fFS->AddFrame (fShow, fL1); - // placement - fF[0] = new TGHorizontalFrame (fGP, 100, 100); - fGP->AddFrame (fF[0], fL5); - fPlace[3] = new TGRadioButton (fF[0], "Top left ", - kGOptLegendPlace + 3); - fPlace[3]->Associate (this); - fF[0]->AddFrame (fPlace[3], fL3); - fPlace[0] = new TGRadioButton (fF[0], "Top right", - kGOptLegendPlace); - fPlace[0]->Associate (this); - fF[0]->AddFrame (fPlace[0], fL3); - fF[1] = new TGHorizontalFrame (fGP, 100, 100); - fGP->AddFrame (fF[1], fL5); - fPlace[2] = new TGRadioButton (fF[1], "Bottom left ", - kGOptLegendPlace + 2); - fPlace[2]->Associate (this); - fF[1]->AddFrame (fPlace[2], fL3); - fPlace[1] = new TGRadioButton (fF[1], "Bottom right", - kGOptLegendPlace + 1); - fPlace[1]->Associate (this); - fF[1]->AddFrame (fPlace[1], fL3); - fF[2] = new TGHorizontalFrame (fGP, 100, 100); - fGP->AddFrame (fF[2], fL2); - fPlaceLabel[0] = new TGLabel (fF[2], "X:"); - fF[2]->AddFrame (fPlaceLabel[0], fL3); - fXAdj = new TLGNumericControlBox (fF[2], 0, 5, - kGOptLegendXAdjust, kNESRealTwo); - fXAdj->Associate (this); - fF[2]->AddFrame (fXAdj, fL3); - fPlaceLabel[1] = new TGLabel (fF[2], " Y:"); - fF[2]->AddFrame (fPlaceLabel[1], fL3); - fYAdj = new TLGNumericControlBox (fF[2], 0, 5, - kGOptLegendYAdjust, kNESRealTwo); - fYAdj->Associate (this); - fF[2]->AddFrame (fYAdj, fL3); - fPlaceLabel[2] = new TGLabel (fF[2], " Size:"); - fF[2]->AddFrame (fPlaceLabel[2], fL2); - fSize = new TLGNumericControlBox (fF[2], 0, 4, + auto main_vert_layout = new TGVerticalLayout(this); + this->SetLayoutManager(main_vert_layout); + + // show + fShow = new TGCheckButton(this, "Show", kGOptLegendShow); + fShow->Associate (this); + this->AddFrame(fShow); + + // ********* placement group ******** + auto placement_hint = new TGLayoutHints( kLHintsExpandX ); + auto placement_group = new TGGroupFrame(this, "Placement"); + + + auto place_layout = new TGTableLayout(placement_group, 3, 6); + //auto place_layout = new TGVerticalLayout(placement_group); + auto p1 = place_layout; + placement_group->SetLayoutManager(place_layout); + + + + { + //placement radios + auto top_left_hint = new TGTableLayoutHints(0,2,0,1, + kLHintsNormal, + 2,2,2,2 + ); + fPlace_top_left = new TGRadioButton(placement_group, "Top left ", kGOptLegendPlaceTopLeft); + fPlace_top_left->Associate(this); + placement_group->AddFrame(fPlace_top_left, top_left_hint); + + auto top_right_hint = new TGTableLayoutHints(2,4,0,1, + kLHintsNormal, + 2,2,2,2 + ); + fPlace_top_right = new TGRadioButton(placement_group, "Top Right ", kGOptLegendPlaceTopRight); + fPlace_top_right->Associate(this); + placement_group->AddFrame(fPlace_top_right, top_right_hint); + + auto bottom_right_hint = new TGTableLayoutHints(2,4,1,2, + kLHintsNormal, + 2,2,2,2 + ); + fPlace_bottom_right = new TGRadioButton(placement_group, "Bottom Right ", kGOptLegendPlaceBottomRight); + fPlace_bottom_right->Associate(this); + placement_group->AddFrame(fPlace_bottom_right, bottom_right_hint); + + auto bottom_left_hint = new TGTableLayoutHints(0,2,1,2, + kLHintsNormal, + 2,2,2,2 + ); + fPlace_bottom_left = new TGRadioButton(placement_group, "Bottom left ", kGOptLegendPlaceBottomLeft); + fPlace_bottom_left->Associate(this); + placement_group->AddFrame(fPlace_bottom_left, bottom_left_hint); + + //placement tweek controls + auto labelx_hint = new TGTableLayoutHints( 0,1,2,3, + kLHintsCenterY|kLHintsRight + ); + auto place_label_x = new TGLabel(placement_group, "X:"); + placement_group->AddFrame(place_label_x, labelx_hint); + + auto xadj_hint = new TGTableLayoutHints(1,2,2,3, + kLHintsLeft, + 5,0,2,0); + fXAdj = new TLGNumericControlBox(placement_group, 0, 5, kGOptLegendXAdjust, kNESRealTwo); + fXAdj->Associate(this); + placement_group->AddFrame(fXAdj, xadj_hint); + + //placement tweek controls + auto labely_hint = new TGTableLayoutHints( 2,3,2,3, + kLHintsCenterY|kLHintsRight + ); + auto place_label_y = new TGLabel(placement_group, "Y:"); + placement_group->AddFrame(place_label_y, labely_hint); + + auto yadj_hint = new TGTableLayoutHints(3,4,2,3, + kLHintsLeft, + 5,0,2,0); + fYAdj = new TLGNumericControlBox(placement_group, 0, 5, kGOptLegendYAdjust, kNESRealTwo); + fYAdj->Associate(this); + placement_group->AddFrame(fYAdj, yadj_hint); + + auto label_size_hint = new TGTableLayoutHints( 4,5,2,3, + kLHintsCenterY | kLHintsRight + ); + auto label_size = new TGLabel(placement_group, "Size:"); + placement_group->AddFrame(label_size, label_size_hint); + + auto size_hint = new TGTableLayoutHints(5,6,2,3, + kLHintsNormal, + 5,0,2,0 + ); + fSize = new TLGNumericControlBox(placement_group, 0, 4, kGOptLegendTextSize, kNESRealOne, kNEANonNegative); - fSize->Associate (this); - fF[2]->AddFrame (fSize, fL3); - // symbol style - fF[3] = new TGHorizontalFrame (fGS, 100, 100); - fGS->AddFrame (fF[3], fL2); - fSymbolStyle[0] = new TGRadioButton (fF[3], "Same as trace ", - kGOptLegendSymbol); - fSymbolStyle[0]->Associate (this); - fF[3]->AddFrame (fSymbolStyle[0], fL3); - fSymbolStyle[1] = new TGRadioButton (fF[3], "None", - kGOptLegendSymbol + 1); - fSymbolStyle[1]->Associate (this); - fF[3]->AddFrame (fSymbolStyle[1], fL3); - // text selection - fF[5] = new TGVerticalFrame(fGT, 1, 1); - fF[4] = new TGHorizontalFrame (fF[5], 100, 150); - fF[5]->AddFrame (fF[4], fL2); - fTextSel[0] = new TGRadioButton (fF[4], "Auto ", - kGOptLegendTextSel); - fTextSel[0]->Associate (this); - fF[4]->AddFrame (fTextSel[0], fL9); - fTextSel[1] = new TGRadioButton (fF[4], "User:", - kGOptLegendTextSel + 1); - fTextSel[1]->Associate (this); - fF[4]->AddFrame (fTextSel[1], fL9); - - // User text selection tabs - fTextTab = new TGTabTraces (fF[5]); - fTextTab->Associate (this); - fF[5]->AddFrame (fTextTab, fL6); - for (int i = 0; i < kMaxTraces; i++) { - char label[4]; - sprintf (label, "%i", i); - fTextTab->AddTab (label); - } - - // User text - fGT->AddFrame(fF[5], fL2); - fText = new TLGTextEntry (fF[5], "", kGOptLegendText); - fText->Associate (this); - fF[5]->AddFrame (fText, fL8); + fSize->Associate(this); + placement_group->AddFrame(fSize, size_hint); + } + this->AddFrame (placement_group, placement_hint); - - fCurTrace = 0; - UpdateOptions(); - } + // ************ Symbol Style ************ + auto symb_style_group = new TGGroupFrame(this, "Symbol style"); + + auto symb_style_layout = new TGHorizontalLayout(symb_style_group); + symb_style_group->SetLayoutManager(symb_style_layout); + + { + fSymbolStyleSame = new TGRadioButton( + symb_style_group, + "Same as trace ", + kGOptLegendSymbolSame); + fSymbolStyleSame->Associate(this); + symb_style_group->AddFrame(fSymbolStyleSame); + + fSymbolStyleNone = new TGRadioButton( + symb_style_group, + "None ", + kGOptLegendSymbolNone); + fSymbolStyleNone->Associate(this); + symb_style_group->AddFrame(fSymbolStyleNone); + } + this->AddFrame (symb_style_group, new TGLayoutHints(kLHintsExpandX)); + + // ************ Text ******************** + auto text_group = new TGGroupFrame(this, "Text"); + this->AddFrame (text_group, new TGLayoutHints(kLHintsExpandX)); + + auto text_layout = new TGTableLayout(text_group,3,4); + text_group->SetLayoutManager(text_layout); + + { + auto text_auto_hint = new TGTableLayoutHints(0,1,0,1); + fTextSelAuto = new TGRadioButton(text_group, "Auto ", + kGOptLegendTextSelAuto); + fTextSelAuto->Associate(this); + text_group->AddFrame(fTextSelAuto, text_auto_hint); + + auto text_user_hint = new TGTableLayoutHints(1,2,0,1); + fTextSelUser = new TGRadioButton(text_group, "User ", + kGOptLegendTextSelUser); + fTextSelUser->Associate(this); + text_group->AddFrame(fTextSelUser, text_user_hint); + + auto text_tab_hint = new TGTableLayoutHints(0,4,1,2, + kLHintsNormal|kLHintsExpandX, + 0,0,5,0); + fTextTab = new TGTabTraces(text_group); + fTextTab->Associate (this); + text_group->AddFrame (fTextTab, text_tab_hint); + for (int i = 0; i < kMaxTraces; i++) { + char label[4]; + sprintf (label, "%i", i); + fTextTab->AddTab (label); + } + + auto text_hint = new TGTableLayoutHints(0,4,2,3, + kLHintsExpandX|kLHintsLeft, + 0,0,5,0); + fText = new TLGTextEntry(text_group, "", + kGOptLegendText); + fText->Associate (this); + text_group->AddFrame (fText, text_hint); + fText->Resize(400,25); + } -//______________________________________________________________________________ - TLGOptionLegend::~TLGOptionLegend () - { - for (int i = 0; i < 4; i++) { - delete fPlace[i]; - } - delete fPlaceLabel[0]; - delete fPlaceLabel[1]; - delete fPlaceLabel[2]; - delete fXAdj; - delete fYAdj; - delete fSize; - delete fSymbolStyle[0]; - delete fSymbolStyle[1]; - delete fTextSel[0]; - delete fTextSel[1]; - delete fTextTab; - delete fText; - delete fShow; - delete fFS; - delete fGP; - delete fGS; - delete fGT; - for (int i = 0; i < 5; i++) { - delete fF[i]; - } - delete fL1; - delete fL2; - delete fL3; - delete fL4; - delete fL5; - delete fL6; - delete fL7; - delete fL8; } //______________________________________________________________________________ @@ -2817,20 +2839,67 @@ namespace ligogui { //cerr << "TLGOptionLegend::UpdateOptions()" << endl ; fShow->SetState (vals->fShow ? kButtonDown : kButtonUp); - for (int i = 0; i < 4; i++) { - fPlace[i]->SetState (i == vals->fPlacement ? - kButtonDown : kButtonUp); + + // ** placement ** + + if(vals->fPlacement == kLegendTopLeft) { + fPlace_top_left->SetState(kButtonDown); + } + else { + fPlace_top_left->SetState(kButtonUp); + } + + if(vals->fPlacement == kLegendTopRight) { + fPlace_top_right->SetState(kButtonDown); + } + else { + fPlace_top_right->SetState(kButtonUp); + } + + if(vals->fPlacement == kLegendBottomRight) { + fPlace_bottom_right->SetState(kButtonDown); + } + else { + fPlace_bottom_right->SetState(kButtonUp); } + + if(vals->fPlacement == kLegendBottomLeft) { + fPlace_bottom_left->SetState(kButtonDown); + } + else { + fPlace_bottom_left->SetState(kButtonUp); + } + fXAdj->SetNumber (vals->fXAdjust); fYAdj->SetNumber (vals->fYAdjust); fSize->SetNumber (vals->fSize); - for (int i = 0; i < 2; i++) { - fSymbolStyle[i]->SetState (i == vals->fSymbolStyle ? - kButtonDown : kButtonUp); + + // *** Symbols *** + if(vals->fSymbolStyle == kLegendSameAsTrace) { + fSymbolStyleSame->SetState(kButtonDown); } - for (int i = 0; i < 2; i++) { - fTextSel[i]->SetState (i == vals->fTextStyle ? - kButtonDown : kButtonUp); + else { + fSymbolStyleSame->SetState(kButtonUp); + } + if(vals->fSymbolStyle == kLegendNone) { + fSymbolStyleNone->SetState(kButtonDown); + } + else { + fSymbolStyleNone->SetState(kButtonUp); + } + + // **** TEXT **** + if(vals->fTextStyle == kLegendAutoText) { + fTextSelAuto->SetState(kButtonDown); + } + else { + fTextSelAuto->SetState(kButtonUp); + } + if(vals->fTextStyle == kLegendUserText) { + fTextSelUser->SetState(kButtonDown); + } + else { + fTextSelUser->SetState(kButtonUp); } if ((fCurTrace < 0) || (fCurTrace >= kMaxTraces)) { fCurTrace = 0; @@ -2845,10 +2914,9 @@ namespace ligogui { Long_t parm2) { OptionLegend_t* vals = (OptionLegend_t*) fOptionValues; - - if ((fCurTrace >= 0) && (fCurTrace < kMaxTraces)) { - vals->fText[fCurTrace] = fText->GetText(); - } + + + // check buttons if ((GET_MSG (msg) == kC_COMMAND) && (GET_SUBMSG (msg) == kCM_CHECKBUTTON)) { @@ -2860,45 +2928,34 @@ namespace ligogui { else if ((GET_MSG (msg) == kC_COMMAND) && (GET_SUBMSG (msg) == kCM_RADIOBUTTON)) { // placement - if ((parm1 >= kGOptLegendPlace) && - (parm1 < kGOptLegendPlace + 4)) { - Int_t id = parm1 - kGOptLegendPlace; - if (id == vals->fPlacement) { - return kTRUE; - } - vals->fPlacement = (ELegendPlacement) id; - for (int i = 0; i < 4; i++) { - fPlace[i]->SetState (i == vals->fPlacement ? - kButtonDown : kButtonUp); - } - } - // symbol style - else if ((parm1 >= kGOptLegendSymbol) && - (parm1 < kGOptLegendSymbol + 2)) { - Int_t id = parm1 - kGOptLegendSymbol; - if (id == vals->fSymbolStyle) { - return kTRUE; - } - vals->fSymbolStyle = (ELegendStyle) id; - for (int i = 0; i < 2; i++) { - fSymbolStyle[i]->SetState (i == vals->fSymbolStyle ? - kButtonDown : kButtonUp); - } - } - // text style - else if ((parm1 >= kGOptLegendTextSel) && - (parm1 < kGOptLegendTextSel + 2)) { - Int_t id = parm1 - kGOptLegendTextSel; - if (id == vals->fTextStyle) { - return kTRUE; - } - vals->fTextStyle = (ELegendText) id; - for (int i = 0; i < 2; i++) { - fTextSel[i]->SetState (i == vals->fTextStyle ? - kButtonDown : kButtonUp); - } - fText->SetState (vals->fTextStyle == kLegendUserText); + switch(parm1) + { + case kGOptLegendPlaceTopLeft: + vals->fPlacement = kLegendTopLeft; + break; + case kGOptLegendPlaceTopRight: + vals->fPlacement = kLegendTopRight; + break; + case kGOptLegendPlaceBottomLeft: + vals->fPlacement = kLegendBottomLeft; + break; + case kGOptLegendPlaceBottomRight: + vals->fPlacement = kLegendBottomRight; + break; + case kGOptLegendSymbolSame: + vals->fSymbolStyle = kLegendSameAsTrace; + break; + case kGOptLegendSymbolNone: + vals->fSymbolStyle = kLegendNone; + break; + case kGOptLegendTextSelAuto: + vals->fTextStyle = kLegendAutoText; + break; + case kGOptLegendTextSelUser: + vals->fTextStyle = kLegendUserText; + break; } + UpdateOptions(); } // tab widget else if ((GET_MSG (msg) == kC_COMMAND) && @@ -2906,7 +2963,7 @@ namespace ligogui { if ((parm1 >= 0) && (parm1 < kMaxTraces)) { if (fCurTrace != parm1) { fCurTrace = parm1; - fText->SetText (vals->fText[fCurTrace]); + fText->SetText(vals->fText[fCurTrace]); } } return kTRUE; @@ -2923,7 +2980,14 @@ namespace ligogui { else if (parm1 == kGOptLegendTextSize) { vals->fSize = fSize->GetNumber(); } + else if (parm1 == kGOptLegendText) { + //this should only happen on text change + if ((fCurTrace >= 0) && (fCurTrace < kMaxTraces)) { + vals->fText[fCurTrace] = fText->GetText(); + } + } } + return TLGOptions::ProcessMessage (msg, parm1, parm2); } @@ -3785,6 +3849,7 @@ extern "C" &fOptionValues->fParam); fTabParam->Associate (this); fTab[9]->AddFrame (fTabParam, fL); + } //______________________________________________________________________________ diff --git a/src/gui/dttview/TLGOptions.hh b/src/gui/dttview/TLGOptions.hh index 214357bd2668556b7b26fe5063a503c0a2abef1a..f99c74f62b11b3db81b19472ac801caf7eb290ab 100644 --- a/src/gui/dttview/TLGOptions.hh +++ b/src/gui/dttview/TLGOptions.hh @@ -52,6 +52,7 @@ #include <TAttAxis.h> #include "TLGFrame.hh" #include "TLGMultiTab.hh" +#include "ComponentHolder.h" class PlotMap; @@ -120,7 +121,7 @@ namespace ligogui { const int kOptionWidth = 440; // JCB // JCB const int kOptionWidth = 300; /// Height of option panel - const int kOptionHeight = 280; + const int kOptionHeight = 353; //280 /// Option Message const int kC_OPTION = 120; @@ -352,7 +353,12 @@ namespace ligogui { /// Widget ID of legend text const int kGOptLegendText = 800; /// Widget ID of legend palcement - const int kGOptLegendPlace = 801; + const int kGOptLegendPlaceStart = 801; + const int kGOptLegendPlaceTopRight = 801; + const int kGOptLegendPlaceBottomRight = 802; + const int kGOptLegendPlaceBottomLeft = 803; + const int kGOptLegendPlaceTopLeft = 804; + /// Widget ID of legend X adjust const int kGOptLegendXAdjust = 805; /// Widget ID of legend Y adjust @@ -360,9 +366,13 @@ namespace ligogui { /// Widget ID of legend text size const int kGOptLegendTextSize = 807; /// Widget ID of legend symbol style - const int kGOptLegendSymbol = 808; + const int kGOptLegendSymbolStart = 808; + const int kGOptLegendSymbolSame = 808; + const int kGOptLegendSymbolNone = 809; /// Widget ID of legend text selection - const int kGOptLegendTextSel = 810; + const int kGOptLegendTextSelStart = 810; + const int kGOptLegendTextSelAuto = 810; + const int kGOptLegendTextSelUser = 811; /// Widget ID of legend show const int kGOptLegendShow = 812; @@ -1468,57 +1478,37 @@ namespace ligogui { protected: /// Currently selected trace Int_t fCurTrace; - /// Frame for show - TGCompositeFrame* fFS; - /// Placement group - TGGroupFrame* fGP; - /// Symbol style group - TGGroupFrame* fGS; - /// Text group - TGGroupFrame* fGT; - /// Line frames - TGCompositeFrame* fF[6]; + + + /// Text selection tabs - TGTab* fTextTab; + TGTab * fTextTab; /// User text entry - TLGTextEntry* fText; + TLGTextEntry * fText; /// Show button - TGButton* fShow; + TGButton * fShow; /// Placement radio buttons - TGButton* fPlace[4]; - /// Placement labels - TGLabel* fPlaceLabel[3]; - /// X adjust - TLGNumericControlBox* fXAdj; + TGButton * fPlace_top_left; + TGButton * fPlace_top_right; + TGButton * fPlace_bottom_left; + TGButton * fPlace_bottom_right; + + /// X adjust + TLGNumericControlBox * fXAdj; /// Y adjust - TLGNumericControlBox* fYAdj; + TLGNumericControlBox * fYAdj; /// Size - TLGNumericControlBox* fSize; + TLGNumericControlBox * fSize; /// Symbol style radio buttons - TGButton* fSymbolStyle[2]; + TGButton * fSymbolStyleSame; + TGButton * fSymbolStyleNone; /// Text selection radio buttons - TGButton* fTextSel[2]; - /// Layout hints for top/left - TGLayoutHints* fL1; - /// Layout hints for centerY/expandX - TGLayoutHints* fL2; - /// Layout hints for centerY/left - TGLayoutHints* fL3; - /// Layout hints for centerY/expandX - TGLayoutHints* fL4; - /// Layout hints for top/expandX (extended top paddding) - TGLayoutHints* fL5; - /// Layout hints for centerY/expandX (alt. padding) - TGLayoutHints* fL6; - /// Layout hints for top/expandX (no x padding) - TGLayoutHints* fL7; - /// Layout hints for top/expandX (alt. padding) - TGLayoutHints* fL8; - + TGButton * fTextSelAuto; + TGButton * fTextSelUser; + public: TLGOptionLegend (const TGWindow* p, Int_t id, OptionLegend_t* optvals); - virtual ~TLGOptionLegend (); virtual void UpdateOptions (); virtual Bool_t ProcessMessage (Long_t msg, Long_t parm1, diff --git a/src/gui/dttview/TLGPad.cc b/src/gui/dttview/TLGPad.cc index 4b11deb44eb10aaffc3ed496064010ca9cb198e9..869f7bea2be545818760cac9e73ec27f58d08fb6 100644 --- a/src/gui/dttview/TLGPad.cc +++ b/src/gui/dttview/TLGPad.cc @@ -1019,7 +1019,7 @@ namespace ligogui { // big enough for option panel? Bool_t hide = fPad->fHidePanel; if ((padsize.fWidth < 100 + pansize.fWidth) || - (padsize.fHeight < 25 + pansize.fHeight)) { + (padsize.fHeight < pansize.fHeight)/2) { if (!fPad->fHidePanel) { hide = kTRUE; } @@ -1073,7 +1073,7 @@ namespace ligogui { Int_t diagy = hidey + hidesize.fHeight + pad_top; TGDimension diagsize = hidesize; Int_t tabx = hidex; - Int_t taby = pany + panh - pansize.fHeight; + Int_t taby = pany + 25; // panh - pansize.fHeight; TGDimension tabsize = pansize; // move all frames to their location @@ -1236,6 +1236,7 @@ namespace ligogui { } fL = new TGLayoutHints (kLHintsLeft | kLHintsCenterY, 2, 2, 2, 2); + // get button pictures fPicHide = fClient->GetPicture ("arrow_left.xpm"); @@ -1374,6 +1375,7 @@ namespace ligogui { fStoreOptions, fStoreOptionsMax, &fXUnitList, &fYUnitList); fOptionTabs->Associate (this); + //TGLayoutHints *hint = new TGLayoutHints(kLHintsTop); AddFrame (fOptionTabs, fL); // move off screen to avoid flickering fOptionTabs->Move (-10000, -10000); diff --git a/src/gui/ligogui/ComponentHolder.h b/src/gui/ligogui/ComponentHolder.h new file mode 100644 index 0000000000000000000000000000000000000000..8a3746bc06c9338730d4bfd70edfc6d55e1c3d23 --- /dev/null +++ b/src/gui/ligogui/ComponentHolder.h @@ -0,0 +1,56 @@ +// +// Created by erik.vonreis on 8/13/20. +// + +#ifndef CDS_CRTOOLS_COMPONENTHOLDER_H +#define CDS_CRTOOLS_COMPONENTHOLDER_H + +#include <list> +#include <memory> + +using namespace std; + +/// Hold components that need lifetime as long as ComponentHolder +/// but aren't used after creation +/// The main purpose of this class is to keep alive GUI components that +/// are referenced only at window creation but can't be deleted +/// until the window closes +/// +/// Create components of any subtype of T with make_shared +/// and add it with << operator or add_component method. +/// \tparam T +template<class T> +class ComponentHolder { + +private: + list<shared_ptr<T>> components; + +public: + ComponentHolder() = default; + + ComponentHolder(const ComponentHolder &) = delete; + + void operator=(const ComponentHolder &) = delete; + + template<class S> + shared_ptr<S> add_component(shared_ptr<S> comp) + { + components.emplace_back(dynamic_pointer_cast<T>(comp)); + + return comp; + } + + /// Call like so: shared_ptr<S> local_ptr = comp_holder << make_shared<S>( ... + /// \tparam S a subclass of T + /// \param comp A shared ointer to an object of type S that you wish to + /// live as long as ComponentHodler + /// \return The same shared pointer passed as an argument. + template<class S> + shared_ptr<S> operator<<(std::shared_ptr<S> comp) + { + return add_component(comp); + } + +}; + +#endif // CDS_CRTOOLS_COMPONENTHOLDER_H