[DEV] update plugin

This commit is contained in:
Edouard DUPIN 2014-08-29 22:52:21 +02:00
parent 668570cdc7
commit b889b4aa5a
14 changed files with 127 additions and 26 deletions

View File

@ -191,15 +191,8 @@ void MainWindows::init() {
myMenu->add(idMenuFile, "Save", "THEME:GUI:Save.edf", "menu:save");
myMenu->add(idMenuFile, "Save As ...", "", "menu:save-as");
myMenu->addSpacer();
//myMenu->add(idMenuFile, "Exit", "", ednMsgGuiExit);
myMenu->addSpacer();
myMenu->add(idMenuFile, "Properties", "THEME:GUI:Parameter.edf", "menu:property");
int32_t idMenuEdit = myMenu->addTitle("Edit");
myMenu->add(idMenuEdit, "Undo", "THEME:GUI:Undo.edf", "menu:undo");
myMenu->add(idMenuEdit, "Redo", "THEME:GUI:Redo.edf", "menu:redo");
myMenu->addSpacer();
myMenu->add(idMenuEdit, "Select All","", "menu:select-all");
myMenu->add(idMenuEdit, "Un-Select","", "menu:select-none");
myMenu->add(idMenuEdit, "Goto line ...","", "menu:goto-line");
int32_t idMenuSearch = myMenu->addTitle("Search");
myMenu->add(idMenuSearch, "Search", "THEME:GUI:Search.edf", "menu:search");

View File

@ -397,13 +397,19 @@ namespace appl {
/**
* @brief add a specific shortcut with his description
* @param[in] _descriptiveString Description string of the shortcut
* @param[in] _generateEventId Event generic of the element
* @param[in] _data Associate data wit the event
* @param[in] _generateEventName Event generic of the element
*/
virtual void ext_shortCutAdd(const std::string& _descriptiveString,
const std::string& _generateEventName) {
shortCutAdd(_descriptiveString, _generateEventName);
}
/**
* @brief Remove a specific shortcut with his event name
* @param[in] _generateEventName Event of the element shortcut
*/
virtual void ext_shortCutRm(const std::string& _generateEventName) {
shortCutRemove(_generateEventName);
}
private: // callback fundtions
void onCallbackIsModify();
void onCallbackShortCut(const std::string& _value);

View File

@ -34,6 +34,10 @@ void appl::TextViewerPlugin::init() {
ewol::Object::init();
}
void appl::TextViewerPlugin::init(const std::string& _name) {
ewol::Object::init(_name);
}
appl::TextViewerPlugin::~TextViewerPlugin() {
if (m_isEnable == false) {
return;

View File

@ -21,6 +21,7 @@ namespace appl {
protected:
TextViewerPlugin();
void init();
void init(const std::string& _name);
public:
DECLARE_FACTORY(TextViewerPlugin);
virtual ~TextViewerPlugin();

View File

@ -15,7 +15,12 @@
#define __class__ "TextPluginCopy"
appl::TextPluginCopy::TextPluginCopy() {
appl::TextPluginCopy::TextPluginCopy() :
m_menuIdTitle(-1),
m_menuIdCopy(-1),
m_menuIdCut(-1),
m_menuIdPast(-1),
m_menuIdRemove(-1) {
m_activateOnReceiveShortCut = true;
addObjectType("appl::TextPluginCopy");
}
@ -25,18 +30,15 @@ void appl::TextPluginCopy::init() {
}
void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) {
APPL_ERROR("plop");
// add event :
std::shared_ptr<ewol::widget::Menu> menu = m_menuInterface.lock();
if (menu != nullptr) {
APPL_ERROR("plop 1");
int32_t idMenuEdit = menu->addTitle("Edit");
if (idMenuEdit != -1) {
APPL_ERROR("plop 2 ");
menu->add(idMenuEdit, "Copy", "", "appl::TextPluginCopy::menu:copy");
menu->add(idMenuEdit, "Cut", "", "appl::TextPluginCopy::menu:cut");
menu->add(idMenuEdit, "Paste", "", "appl::TextPluginCopy::menu:past");
menu->add(idMenuEdit, "Remove", "", "appl::TextPluginCopy::menu:remove");
m_menuIdTitle = menu->addTitle("Edit");
if (m_menuIdTitle != -1) {
m_menuIdCopy = menu->add(m_menuIdTitle, "Copy", "", "appl::TextPluginCopy::menu:copy");
m_menuIdCut = menu->add(m_menuIdTitle, "Cut", "", "appl::TextPluginCopy::menu:cut");
m_menuIdPast = menu->add(m_menuIdTitle, "Paste", "", "appl::TextPluginCopy::menu:past");
m_menuIdRemove = menu->add(m_menuIdTitle, "Remove", "", "appl::TextPluginCopy::menu:remove");
}
}
_textDrawer.ext_shortCutAdd("ctrl+x", "appl::TextPluginCopy::cut");
@ -45,7 +47,22 @@ void appl::TextPluginCopy::onPluginEnable(appl::TextViewer& _textDrawer) {
}
void appl::TextPluginCopy::onPluginDisable(appl::TextViewer& _textDrawer) {
// TODO : unknow function ...
_textDrawer.ext_shortCutRm("appl::TextPluginCopy::cut");
_textDrawer.ext_shortCutRm("appl::TextPluginCopy::copy");
_textDrawer.ext_shortCutRm("appl::TextPluginCopy::Paste");
std::shared_ptr<ewol::widget::Menu> menu = m_menuInterface.lock();
if (menu != nullptr) {
menu->remove(m_menuIdRemove);
menu->remove(m_menuIdPast);
menu->remove(m_menuIdCut);
menu->remove(m_menuIdCopy);
menu->remove(m_menuIdTitle);
}
m_menuIdTitle = -1;
m_menuIdCopy = -1;
m_menuIdCut = -1;
m_menuIdPast = -1;
m_menuIdRemove = -1;
}
bool appl::TextPluginCopy::onReceiveShortCut(appl::TextViewer& _textDrawer,

View File

@ -17,6 +17,12 @@
namespace appl {
class TextPluginCopy : public appl::TextViewerPlugin {
private:
int32_t m_menuIdTitle;
int32_t m_menuIdCopy;
int32_t m_menuIdCut;
int32_t m_menuIdPast;
int32_t m_menuIdRemove;
protected:
TextPluginCopy();
void init();

View File

@ -45,7 +45,9 @@ void appl::TextPluginCtags::onPluginEnable(appl::TextViewer& _textDrawer) {
}
void appl::TextPluginCtags::onPluginDisable(appl::TextViewer& _textDrawer) {
// TODO : unknow function ...
_textDrawer.ext_shortCutRm("appl::TextPluginCtags::JumpDestination");
_textDrawer.ext_shortCutRm("appl::TextPluginCtags::JumpBack");
_textDrawer.ext_shortCutRm("appl::TextPluginCtags::OpenCtagsFile");
}
void appl::TextPluginCtags::jumpTo(const std::string& _name) {

View File

@ -25,6 +25,9 @@ namespace appl {
void init() {
appl::TextViewerPlugin::init();
}
void init(const std::string& _name) {
appl::TextViewerPlugin::init(_name);
}
public:
DECLARE_FACTORY(TextViewerPluginData);
virtual ~TextViewerPluginData() {

View File

@ -15,7 +15,10 @@
#undef __class__
#define __class__ "TextPluginHistory"
appl::TextPluginHistory::TextPluginHistory() {
appl::TextPluginHistory::TextPluginHistory() :
m_menuIdTitle(-1),
m_menuIdUndo(-1),
m_menuIdRedo(-1) {
m_activateOnReceiveShortCut = true;
m_activateOnWrite = true;
m_activateOnReplace = true;
@ -29,13 +32,31 @@ void appl::TextPluginHistory::init() {
void appl::TextPluginHistory::onPluginEnable(appl::TextViewer& _textDrawer) {
std::shared_ptr<ewol::widget::Menu> menu = m_menuInterface.lock();
if (menu != nullptr) {
m_menuIdTitle = menu->addTitle("Edit");
if (m_menuIdTitle != -1) {
m_menuIdUndo = menu->add(m_menuIdTitle, "Undo", "THEME:GUI:Undo.edf", "appl::TextPluginHistory::menu:undo");
m_menuIdRedo = menu->add(m_menuIdTitle, "Redo", "THEME:GUI:Redo.edf", "appl::TextPluginHistory::menu:redo");
}
}
// add event :
_textDrawer.ext_shortCutAdd("ctrl+z", "appl::TextPluginHistory::Undo");
_textDrawer.ext_shortCutAdd("ctrl+shift+z", "appl::TextPluginHistory::Redo");
}
void appl::TextPluginHistory::onPluginDisable(appl::TextViewer& _textDrawer) {
// TODO : unknow function ...
_textDrawer.ext_shortCutRm("appl::TextPluginHistory::Undo");
_textDrawer.ext_shortCutRm("appl::TextPluginHistory::Redo");
std::shared_ptr<ewol::widget::Menu> menu = m_menuInterface.lock();
if (menu != nullptr) {
menu->remove(m_menuIdRedo);
menu->remove(m_menuIdUndo);
menu->remove(m_menuIdTitle);
}
m_menuIdTitle = -1;
m_menuIdUndo = -1;
m_menuIdRedo = -1;
}
bool appl::TextPluginHistory::onDataReceiveShortCut(appl::TextViewer& _textDrawer,

View File

@ -36,6 +36,10 @@ namespace appl {
std::vector<History*> m_redo; //!< History storing data
};
class TextPluginHistory : public appl::TextViewerPluginData<appl::PluginHistoryData> {
private:
int32_t m_menuIdTitle;
int32_t m_menuIdUndo;
int32_t m_menuIdRedo;
protected:
TextPluginHistory();
void init();

View File

@ -52,6 +52,11 @@ static std::vector<std::shared_ptr<appl::TextViewerPlugin>>& getListOnCursorMove
return s_list;
}
static std::weak_ptr<appl::TextViewer>& getViewerConnected() {
static std::weak_ptr<appl::TextViewer> s_widget;
return s_widget;
}
void appl::textPluginManager::init() {
}
@ -82,6 +87,7 @@ void appl::textPluginManager::addPlugin(const std::shared_ptr<appl::TextViewerPl
if (_plugin == nullptr) {
return;
}
APPL_DEBUG("Add plugin : " << _plugin->getObjectType());
getList().push_back(_plugin);
if (_plugin->isAvaillableOnEventEntry() == true) {
getListOnEventEntry().push_back(_plugin);
@ -104,9 +110,14 @@ void appl::textPluginManager::addPlugin(const std::shared_ptr<appl::TextViewerPl
if (_plugin->isAvaillableOnCursorMove() == true) {
getListOnCursorMove().push_back(_plugin);
}
std::shared_ptr<appl::TextViewer> viewer = getViewerConnected().lock();
if (viewer != nullptr) {
_plugin->onPluginEnable(*viewer);
}
}
void appl::textPluginManager::connect(appl::TextViewer& _widget) {
getViewerConnected() = std::dynamic_pointer_cast<appl::TextViewer>(_widget.shared_from_this());
for (auto &it : getList()) {
if (it == nullptr) {
continue;
@ -116,6 +127,7 @@ void appl::textPluginManager::connect(appl::TextViewer& _widget) {
}
void appl::textPluginManager::disconnect(appl::TextViewer& _widget) {
getViewerConnected().reset();
for (auto &it : getList()) {
if (it == nullptr) {
continue;

View File

@ -30,7 +30,7 @@ void appl::TextPluginRmLine::onPluginEnable(appl::TextViewer& _textDrawer) {
}
void appl::TextPluginRmLine::onPluginDisable(appl::TextViewer& _textDrawer) {
// TODO : unknow function ...
_textDrawer.ext_shortCutRm("appl::TextPluginRmLine::Rm");
}
bool appl::TextPluginRmLine::onReceiveShortCut(appl::TextViewer& _textDrawer,

View File

@ -15,7 +15,10 @@
#define __class__ "TextPluginSelectAll"
appl::TextPluginSelectAll::TextPluginSelectAll() {
appl::TextPluginSelectAll::TextPluginSelectAll() :
m_menuIdTitle(-1),
m_menuIdSelectAll(-1),
m_menuIdSelectNone(-1) {
m_activateOnReceiveShortCut = true;
addObjectType("appl::TextPluginSelectAll");
}
@ -25,12 +28,31 @@ void appl::TextPluginSelectAll::init() {
}
void appl::TextPluginSelectAll::onPluginEnable(appl::TextViewer& _textDrawer) {
std::shared_ptr<ewol::widget::Menu> menu = m_menuInterface.lock();
if (menu != nullptr) {
m_menuIdTitle = menu->addTitle("Edit");
if (m_menuIdTitle != -1) {
m_menuIdSelectAll = menu->add(m_menuIdTitle, "Select All","", "appl::TextPluginSelectAll::menu:select-all");
m_menuIdSelectNone = menu->add(m_menuIdTitle, "Un-Select","", "appl::TextPluginSelectAll::menu:select-none");
}
}
// add event :
_textDrawer.ext_shortCutAdd("ctrl+a", "appl::TextPluginSelectAll::All");
_textDrawer.ext_shortCutAdd("ctrl+shift+a", "appl::TextPluginSelectAll::None");
}
void appl::TextPluginSelectAll::onPluginDisable(appl::TextViewer& _textDrawer) {
// TODO : unknow function ...
_textDrawer.ext_shortCutRm("appl::TextPluginSelectAll::All");
_textDrawer.ext_shortCutRm("appl::TextPluginSelectAll::None");
std::shared_ptr<ewol::widget::Menu> menu = m_menuInterface.lock();
if (menu != nullptr) {
menu->remove(m_menuIdSelectNone);
menu->remove(m_menuIdSelectAll);
menu->remove(m_menuIdTitle);
}
m_menuIdTitle = -1;
m_menuIdSelectAll = -1;
m_menuIdSelectNone = -1;
}
bool appl::TextPluginSelectAll::onReceiveShortCut(appl::TextViewer& _textDrawer,
@ -45,5 +67,12 @@ bool appl::TextPluginSelectAll::onReceiveShortCut(appl::TextViewer& _textDrawer,
_textDrawer.select(_textDrawer.begin(), _textDrawer.end());
return true;
}
if (_shortCutName == "appl::TextPluginSelectAll::None") {
if (_textDrawer.hasBuffer() == false) {
return false;
}
_textDrawer.unSelect();
return true;
}
return false;
}

View File

@ -20,6 +20,9 @@ namespace appl {
protected:
TextPluginSelectAll();
void init();
int32_t m_menuIdTitle;
int32_t m_menuIdSelectAll;
int32_t m_menuIdSelectNone;
public:
DECLARE_FACTORY(TextPluginSelectAll);
virtual ~TextPluginSelectAll() {