52 gROOT->GetListOfCleanups()->Add(
this);
60 gROOT->GetListOfCleanups()->Remove(
this);
92 auto action_group = Gio::SimpleActionGroup::create();
94 action_group->add_action_with_parameter(
96 Glib::VariantType(
"i"),
97 [
this](
const Glib::VariantBase& parameter) {
98 if (
auto var = Glib::VariantBase::cast_dynamic<Glib::Variant<int>>(parameter)) {
99 int value = var.get();
100 std::cout <<
"Action triggered with integer value: " <<
value << std::endl;
106 auto menu_model = Gio::Menu::create();
108 auto current_section = Gio::Menu::create();
111 auto addSeparator = [&menu_model, ¤t_section]() {
112 menu_model->append_section(current_section);
113 current_section = Gio::Menu::create();
116 auto addMenuAction = [¤t_section, &action_group,
this](
const TString &
text,
int id,
void *arg =
nullptr,
int checked = 0) {
118 if ((
text ==
"DrawClone") || (
text ==
"DrawClass") || (
text ==
"Inspect") ||
119 (
text ==
"SetShowProjectionX") || (
text ==
"SetShowProjectionY") ||
120 (
text ==
"DrawPanel") || (
text ==
"FitPanel"))
126 auto action = Gio::SimpleAction::create_bool(action_name.
Data(), checked > 0);
127 action->signal_activate().connect([action,
this,
id](
const Glib::VariantBase &) {
129 action->get_state(current);
130 action->set_state(Glib::Variant<bool>::create(!current));
131 std::cout <<
"Action triggered with integer value: " <<
id << std::endl;
134 action->set_enabled(enabled);
135 action_group->add_action(action);
137 action_name.
Prepend(
"context.");
138 auto item = Gio::MenuItem::create(
text.Data(), action_name.
Data());
139 current_section->append_item(item);
140 }
else if (enabled) {
141 auto item = Gio::MenuItem::create(
text.Data(),
"");
142 item->set_action_and_target(
"context.action", Glib::Variant<int>::create(
id));
143 current_section->append_item(item);
146 current_section->append(
text.Data(),
"context.dummy");
154 bool last_separ =
true;
161 TIter nextItem(menuItemList);
164 switch (menuItem->GetType()) {
179 TClass *classPtr =
nullptr;
180 TIter next(methodList);
183 while ((method = (
TMethod*) next())) {
184 if (classPtr != method->
GetClass()) {
199 addMenuAction(method->
GetName(), entry++, method);
209 if (
m->GetterMethod()) {
211 TIter nxt(
m->GetOptions());
219 addMenuAction(it->fOptName.Data(), togglelist++, t, t->
GetState() ? 1 : -1);
222 addMenuAction(method->
GetName(), entry++, method);
249 const char* menuItemTitle = menuItem->
GetTitle();
250 if (menuItem->IsToggle()) {
258 if (strlen(menuItemTitle)==0)
259 menuItemTitle = method->
GetName();
260 addMenuAction(menuItemTitle, toggle++, t, t->
GetState() ? 1 : -1);
263 if (strlen(menuItemTitle)==0)
264 menuItemTitle = menuItem->GetFunctionName();
265 addMenuAction(menuItemTitle, userfunction++, menuItem);
275 widget->insert_action_group(
"context", action_group);
277 widget->ShowContextMenu(menu_model, title.
Data(),
x,
y);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char text
Specialized dialog to enter arguments for method exection.
Gtk4DrawArea * GetDrawArea() const
TClass instances represent classes, structs and namespaces in the ROOT type system.
TList * GetMenuList() const
Return the list of menu items associated with the class.
TMethod * GetMethodWithPrototype(const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Find the method with a given prototype.
void GetMenuItems(TList *listitems)
Returns list of methods accessible by context menu.
Global functions class (global functions are obtained from CINT).
void Add(TObject *obj) override
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
TClass * IsA() const override
Method or function calling interface.
TFunction * GetMethod()
Returns the TMethod describing the method to be executed.
Each ROOT class (see TClass) has a linked list of methods.
virtual TDataMember * FindDataMember()
Tries to guess DataMember from comment string and Method's name <==(only if 1 Argument!...
TClass * GetClass() const
EMenuItemKind IsMenuItem() const
TClass * IsA() const override
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
virtual const char * GetTitle() const
Returns title of object.
const char * Data() const
TString & Prepend(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
This class defines toggling facility for both - object's method or variables.
virtual void SetOnValue(Long_t lon)
TMethodCall * GetSetter() const
return setter method request new for the TDataMember while it can be recreated at any time
virtual void SetToggledObject(TObject *obj, TMethod *anymethod)
Initializes it to toggle an object's datamember using this object's method.
virtual void SetState(Bool_t state)
Sets the value of toggle to fOnValue or fOffValue according to passed argument.
virtual Bool_t GetState()
Returns the state of Toggle according to its current value and fOnValue, returns true if they match.