update retinexadd with master 4d6833c

This commit is contained in:
Desmis
2016-01-03 15:48:22 +01:00
parent c9a6f74efa
commit 4e229fe928
58 changed files with 7810 additions and 533 deletions

View File

@@ -19,12 +19,16 @@
* Class created by Jean-Christophe FRISCH, aka 'Hombre'
*/
#include <gtkmm.h>
#include "multilangmgr.h"
#include "popupcommon.h"
#include "../rtengine/safegtk.h"
#include "rtimage.h"
PopUpCommon::PopUpCommon (Gtk::Button* thisButton, const Glib::ustring& label)
: selected (-1) // -1 means that the button is invalid
, menu (0)
, buttonImage (0)
{
button = thisButton;
hasMenu = false;
@@ -41,15 +45,6 @@ PopUpCommon::PopUpCommon (Gtk::Button* thisButton, const Glib::ustring& label)
// Create the global container and put the button in it
buttonGroup = Gtk::manage( new Gtk::HBox(false, 0));
buttonGroup->pack_start(*button, Gtk::PACK_EXPAND_WIDGET, 0);
// Create the list entry
imageFilenames.clear();
images.clear();
sItems.clear();
items.clear();
selected = -1; // -1 : means that the button is invalid
menu = 0;
buttonImage = 0;
buttonHint = "";
}
PopUpCommon::~PopUpCommon ()
@@ -58,83 +53,68 @@ PopUpCommon::~PopUpCommon ()
delete *i;
}
for (std::vector<Gtk::ImageMenuItem*>::iterator i = items.begin(); i != items.end(); ++i) {
delete *i;
}
if (menu) {
delete menu;
}
if (buttonImage) {
delete buttonImage;
}
delete buttonGroup;
delete menu;
delete buttonImage;
}
PopUpCommon::type_signal_changed PopUpCommon::signal_changed()
bool PopUpCommon::addEntry (const Glib::ustring& fileName, const Glib::ustring& label)
{
return message;
}
if (label.empty ())
return false;
bool PopUpCommon::addEntry (Glib::ustring fileName, Glib::ustring label)
{
bool added = false;
// Create the image
RTImage* newImage = new RTImage(fileName);
images.push_back(newImage);
imageFilenames.push_back(fileName);
int currPos = (int)images.size();
// Create the menu item
Gtk::ImageMenuItem* newItem = Gtk::manage(new Gtk::ImageMenuItem (*newImage, label));
if ( label.size() ) {
imageFilenames.push_back(fileName);
sItems.push_back(label);
// Create the image
RTImage* newImage = new RTImage(fileName);
images.push_back(newImage);
int currPos = (int)images.size();
// Create the menu item
Gtk::ImageMenuItem* newItem = new Gtk::ImageMenuItem (*newImage, label);
items.push_back(newItem);
if (selected == -1) {
// Create the menu on the first item
menu = new Gtk::Menu ();
// Create the image for the button
buttonImage = new RTImage(fileName);
// Use the first image by default
imageContainer->pack_start(*buttonImage, Gtk::PACK_EXPAND_WIDGET);
selected = 0;
}
// When there is at least 1 choice, we add the arrow button
if (images.size() == 1) {
Gtk::Button* arrowButton = Gtk::manage( new Gtk::Button() );
RTImage* arrowImage = Gtk::manage( new RTImage("popuparrow.png") );
arrowButton->add(*arrowImage); //menuSymbol);
arrowButton->set_relief (Gtk::RELIEF_NONE);
arrowButton->set_border_width (0);
buttonGroup->pack_start(*arrowButton, Gtk::PACK_SHRINK, 0);
arrowButton->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &PopUpCommon::showMenu) );
hasMenu = true;
}
newItem->signal_activate().connect (sigc::bind(sigc::mem_fun(*this, &PopUpCommon::entrySelected), currPos - 1));
menu->attach (*newItem, 0, 1, currPos - 1, currPos);
// The item has been created
added = true;
if (selected == -1) {
// Create the menu on the first item
menu = new Gtk::Menu ();
// Create the image for the button
buttonImage = new RTImage(fileName);
// Use the first image by default
imageContainer->pack_start(*buttonImage, Gtk::PACK_EXPAND_WIDGET);
selected = 0;
}
return added;
// When there is at least 1 choice, we add the arrow button
if (images.size() == 1) {
Gtk::Button* arrowButton = Gtk::manage( new Gtk::Button() );
RTImage* arrowImage = Gtk::manage( new RTImage("popuparrow.png") );
arrowButton->add(*arrowImage); //menuSymbol);
arrowButton->set_relief (Gtk::RELIEF_NONE);
arrowButton->set_border_width (0);
buttonGroup->pack_start(*arrowButton, Gtk::PACK_SHRINK, 0);
arrowButton->signal_button_release_event().connect_notify( sigc::mem_fun(*this, &PopUpCommon::showMenu) );
hasMenu = true;
}
newItem->signal_activate().connect (sigc::bind(sigc::mem_fun(*this, &PopUpCommon::entrySelected), currPos - 1));
menu->attach (*newItem, 0, 1, currPos - 1, currPos);
return true;
}
// TODO: 'PopUpCommon::removeEntry' method to be created...
void PopUpCommon::entrySelected (int i)
{
if (setSelected((unsigned int)i))
// Emit a a signal if the selected item has changed
{
message.emit(selected);
// Emit a a signal if the selected item has changed
if (setSelected (i))
message (selected);
}
void PopUpCommon::setItemSensitivity (int i, bool isSensitive) {
Gtk::Menu_Helpers::MenuList items = menu->items();
if (i < items.size()) {
items[i].set_sensitive(isSensitive);
}
}
/*
* Set the button image with the selected item
*/
@@ -172,7 +152,12 @@ void PopUpCommon::setButtonHint()
}
if (selected > -1) {
hint += sItems.at(selected);
// HACK: Gtk::MenuItem::get_label does not seem to work reliably.
Gtk::MenuItem& item = menu->items ()[selected];
Gtk::Label* label = dynamic_cast<Gtk::Label*>(item.get_child ());
if (label)
hint += label->get_text ();
}
button->set_tooltip_markup(hint);