Code::Blocks

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: seb_seb0 on March 28, 2010, 08:34:30 pm

Title: BETA - Image Editor plugin
Post by: seb_seb0 on March 28, 2010, 08:34:30 pm
Hello guys,

 I have started to program a new Code::Blocks plugin.
 Its purpose: open and edit all images / icons directly inside CodeBlocks. It will simplify the creation / update of all kind of small images (useful for toolbars, for example).
 
  It is of course a SIMPLE editor: nothing fancy, it is more a clone of MS Paint than a clone of Photoshop.
  I have attached the source code (a cbplugin) - the archive also contains a compiled version (windows Vista - Codeblocks SVN 6181
 - MingW TDM 4.4.1)

   The current status is : ALPHA
   What is done:
      - basic editor class for images
      - mime handler done - viewing images works
      - a color picker class is done & tested
      - a wxToggleBitmapButton has been done (not available in wxWidgets 2.8.10. It is a copy of the one from wxWidgets 2.9.0)
      - Undo / Redo mechanism implemented & tested
      - Paste implemented & tested
    
    What remains to be done:
      - Copy & Cut (done, but needs testing...)
      - Save & Save As (done, but needs testing...)
      - implement all the tools (draw line, draw rectangle, ... the bulk of what is remaining)
      - better integration with CodeBlocks (title of the tab in wxAUI does not show a "*" when modified)
      - interface with wxSmith (cryogen made a patch for that : the DialogBox for choosing an image should have a new option. see thread http://forums.codeblocks.org/index.php/topic,372.165.html (http://forums.codeblocks.org/index.php/topic,372.165.html) )
      - testing on Linux

    BUGS :
      - reopening the same bmp makes code::blocks quit without warning

    LIST OF CLASSES:
      xpm_color_picker : a color picker class - display a few different colors. Double-click on 1 color allows complete customization
      xpm_editor : the plugin itself (a MIME plugin)
      xpm_editor_base : the Image Editor. Use internally a xpm_editor_panel, which actually does the bulk of the work
      xpm_editor_panel : the GUI interface for the editor (wxSmith item)
      xpm_undo : a class to manage the UNDO & REDO buffers, and performs the REDO / UNDO action
      xpm_imageeditorarray : to keep track of the opened Image Editors in CodeBlocks. I suspect this class is provoking the BUG
      xpm_toggle_bmp_button : a bitmap toggle button (not available in wxWidgets 2.8.10)

Let me know what you think !

Seb

[attachment deleted by admin]
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on March 28, 2010, 08:43:56 pm
Here is a screenshot



[attachment deleted by admin]
Title: Re: Image Editor - new plugin
Post by: rcoll on March 28, 2010, 08:49:03 pm
Excellant! I've had this on my TO-DO list for some time, so I am very glad to see this one.  I'll give it a try, and let you know how it works for me.

Ringo
Title: Re: Image Editor - new plugin
Post by: JGM on March 28, 2010, 08:49:14 pm
whoa this is so cool!  :shock:
Title: Re: Image Editor - new plugin
Post by: danselmi on March 29, 2010, 12:39:28 am
Nice work! thank you.

To show the correct title on the tab:
in XpmEditorBase (derived from EditorBase) add a method:
Code: [Select]
void XpmEditorBase::UpdateModified()
{
    if ( GetModified() )
        SetTitle( _T("*") + GetShortName() );
    else
        SetTitle( GetShortName() );
}
and call it whenever the content changed (Do / Undo / Save / SaveAs ...).

Additionally overwrite EditorBases' virtual void SetFilename(const wxString& filename); with the following implementation:
Code: [Select]
void XpmEditorBase::SetFilename(const wxString& filename)
{
    m_Filename = filename;
    wxFileName fname;
    fname.Assign(m_Filename);
    m_Shortname = fname.GetFullName();
}

Take a look at HexEditor or NassiShneidermanPlugin (see my sig) how it's done. But these steps should do.
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on March 31, 2010, 11:08:56 pm
Thank you danselmi.
I have solved the crashing bug !

I have implemented some of the functionalities now - I will probably post a Beta this week-end.

Now Save & Save As are working, and they are saving in the correct format.
Drawing has been buffered, and flicker is removed.
I have also simplified the plugins itself (removed the xpm_imageeditorarray class). The simpler it is, the easier it will be to maintain.

I have preferred to focus on removing the bug and getting the code base clean and correct, instead of implementing too fast all the features. I do not want to give a buggy plugin...

What remains to do (in this order):
      - better integration with CodeBlocks (title of the tab in wxAUI does not show a "*" when modified) - still to be solved
         Danselmi: I have seen your suggestion, but I did not have the time to do it yet. This will be my next step
      - Selection + Copy & Cut (done, but needs testing...)
      - Pen tool (the simplest one)
      - implement all the tools (draw line, draw rectangle, ... the bulk of what is remaining)
      - interface with wxSmith (cryogen made a patch for that : the DialogBox for choosing an image should have a new option. see thread http://forums.codeblocks.org/index.php/topic,372.165.html )
      - testing on Linux

what I will do on version 2:
     - integrate a configuration panel: Undo buffer, Color Palette, how to handle XPM file by default (use the Text Editor or the Image Editor).

I have put the last version of the project on SourceForge:
https://sourceforge.net/projects/xpmeditor/ (https://sourceforge.net/projects/xpmeditor/)

Let me know what you think.
Best regards,

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on April 10, 2010, 08:50:42 pm
Hello,

I have updated the plugin. It is still not finished, but now it is usable

What is new:
    1 - all bugs solved. No more crashing of CodeBlocks :-) (and the code was simplified. I have solved the problem by copying some parts of the HexEditor plugin).
    2 - Integration with CodeBlocks: all problems of file naming / modification flags solved
    3 - Undo / Redo improved
    4 - Work around a nasty bug in wxWidgets(wxDC.SetUserScale is not accurate - on big zoom factor, I had a 4 pixels error for 400 x 200 bitmaps...). This is what took me the most of my time
    5 - Cut / Copy / Paste implemented & tested
    6 - Save / SaveAs / Load implemented & tested
        All formats supported by wxWidgets are supported by the plugin (most notable: bmp, xpm, png)
    7 - following tools are implemented:
            Rectangle selection
            Polygon selection
            Pen
            Pipette
            Fill
     8 - ColourPicker improved: Left click select the Line colour, right click select the fill colour. A small toggle button can invert this behaviour.

What remain to do:
    1 - implement the rest of the tools
            brush (working on it)
            line
            curve
            eraser
            rectangle
            rounded rectangle
            ellipse
            polygon

    2 - resize selection / stretch selection / drag selection

    3 - add a configuration panel:
            How to handle XPMs (open it as text, as image, or ask the user each time)
            Undo / Redo buffer size
            Color palette (how many colors, and which one).

        All these options are already implemented in the code,and accessible in the main plugin interface
        What remains to do is to create the panel, and add it in the CodeBlocks option (and save the options).

nice to have, but not necessary for 1st release

    4 - add a jpg quality option

    5 - add a color depth option

    6 - add a file filter in the global CodeBlocks file open / save dialog box (it is already crowed with many file types, so I am not sure if it is a good idea)

    7 - testing on Linux & Mac
    
    8 - interface with wxSmith (cryogen made a patch for that : the DialogBox for choosing an image should have a new option. see thread http://forums.codeblocks.org/index.php/topic,372.165.html (http://forums.codeblocks.org/index.php/topic,372.165.html)  )
   
    9 - Transparency : sometimes the transparency mask disappears when using some customed colours

I have updated the code on sourceforge:
https://sourceforge.net/projects/xpmeditor/ (https://sourceforge.net/projects/xpmeditor/)

Let me know what you think.
And do not hesitate to report me any bugs !

Sebastien
Title: Re: Image Editor - new plugin
Post by: danselmi on April 11, 2010, 01:54:25 pm
Hi Sebastien

You made great progress!

A few thoughts:

regards,
danselmi

Title: Re: Image Editor - new plugin
Post by: MortenMacFly on April 11, 2010, 08:02:24 pm
I have updated the code on sourceforge:
https://sourceforge.net/projects/xpmeditor/ (https://sourceforge.net/projects/xpmeditor/)
It took me a while to find out you are not using SVN on sourceforge... (why?!). Now I can give tit a try, too... :)
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on April 11, 2010, 09:43:44 pm
Hello,

I have updated the .7Z archive on Sourceforge. (I have not done it in SVN because I do not know how to do it yet. I will find how, but it takes time, and I prefer to use this time for developping the plugin).
https://sourceforge.net/projects/xpmeditor/ (https://sourceforge.net/projects/xpmeditor/)

EDIT: now the plugin is also available as a SVN repository on sourceforge.

What changed:
  - change the name of all the classes and of the plugin to CamelCase (I have followed the suggestion from DanSelmi)
  - nearly all the tools are implemented !! (only the Text tool is not done)

What remains to do:
  - points 2 to 9 from my previous list.

Optimisations possible:
  - Undo / Redo buffers should be smarter (maybe store only a sub-bitmap and its position...)
  - wxMouseEvent tends so skip some coordinates. I do not know yet if it is my plugin who is slow, or if it comes from wxWidgets.

Once it is done, I will need to test thoroughly before final release.
I will need testers for Linux & Mac

1 side note: the tool is not at all optimized (or you may say otherwise: it is optimized for small bitmaps).
In theory, you can edit a 2000 x 2000 bitmap. In practice, it can be challenging for the CPU. (especially UNDO / REDO buffer which stores the whole bitmap each time).

But as I said, the goal I had in my mind was Toolbars / Menu icons fast edition. They are very often smaller than 2000 x 2000.

Let me know what you think !

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on April 11, 2010, 10:53:37 pm
OK, now it is available on sourceforge, with SVN.
It was not as complicated as I feared.

Sebastien
Title: Re: Image Editor - new plugin
Post by: jens on April 12, 2010, 12:03:56 am
Does not work on linux.
You copied the source of the bitmap-togglebutton from the msw-sources of wxWidgets, that does not work.
And using the sources from src/gtk is not so easy.

No bitmaps shown (OnPaint is never called) and after a click on any button C::B blocks xfce and I have to kill it from a console.

I started to move to wxCustmButton of wxSmithContribItems, bitmaps are shown, but no other functions (yet).
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on April 12, 2010, 09:49:27 pm
Does not work on linux.
You copied the source of the bitmap-togglebutton from the msw-sources of wxWidgets, that does not work.
And using the sources from src/gtk is not so easy.

No bitmaps shown (OnPaint is never called) and after a click on any button C::B blocks xfce and I have to kill it from a console.

I started to move to wxCustmButton of wxSmithContribItems, bitmaps are shown, but no other functions (yet).

  This is good to know - I tried to find a simple solution for having a toolbox of push buttons with bitmap icons, but apparently this one is far from being ideal.
  I do not know wxCustomButton (part of wxThings if I am not mistaken). I have tried a few month ago to compile wxThings with wxWidgets 2.9.0, but without success.
 
  Another possible solution is to use a toolbar with radio buttons - it should do the trick.
  Or use the same solution as wxSmith (I do not know yet what it is using, but it works).

  Currently, I am in the process of cleaning the code of bugs (I do not work on new features for now), so as soon it is finished, I will look into the problem.

  Since you have more experience than me in programming for wxGTK, what is your suggestion / idea ?

Sebastien
Title: Re: Image Editor - new plugin
Post by: jens on April 12, 2010, 10:34:14 pm
I think using wxCustomButton (from wxThings) for a C::B plugin is safe and it's part of the wxSmithContribItems (even if it might not be compilable with wx2.9).

C::B is not fully compatible with wx2.9, even if the core app is compilable in the meantime.
There is still an ugly crash if C::B ends due to problems with the event-handlers of the listcontrol-loggers.

And parts of contrib-plugins do not even compile.

A wx2.9 crash on linux when starting the dialogs that uses wxListBook (editorconf, settings, ...) is fixed in wxWidgets trunk since yesterday : http://trac.wxwidgets.org/ticket/11698#comment:8 (http://trac.wxwidgets.org/ticket/11698#comment:8), that's a big step forward, because there was no easy workaround for that issue (without patching wxWidgets).

Before we switch to wx 2.9 or more likely to 3.0 (as it will be the next release) all incompatibilities will (have to) be fixed.

You can see how to use wxCustombutton in ThreadSearch-plugin (SearchInPanel.*), but I made the changes manually, because dje the original-developer of the ThreadSearch-plugin used glade to create the gui, and I prefer wxSmith (or doing it the old way, by hand).
As you use wxSmith for your panel it should be not so hard to switch to it (and it should work on linux and windows).

I hope the post is not too chaotic, but I have a terrible headache at the moment and can not really think straightforward.
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on April 12, 2010, 10:58:04 pm
Thank you for the answer.
In any case, it is easier to change now, when the plugin is in development than in 6 months, when I will have forgotten everything.
And I prefer to change a few things than having a buggy plugin which work only on my computer.

I will give a try with wxCustomButton, even if I need to modify it a bit for compilation. I will add the relevant files directly to the project to avoid external dependencies (I will look first at ThreadSearch plugin to know how it is done).

I was anyway surprised that it was so difficult to find such a simple control as a bitmap toggle button, while at the same time you find complex control like wxGrid or wxDataView.

I have also thought about a wxToolBar in the wxPanel (not recommended by the docs), or see if wxAUI is usable on wxPanel (apparently you need a wxFrame).

So to sum-up: I will try the wxCustomButton (a copy paste from ThreadSearch plugin, as much as possible).

And keep in mind that I have only a MS Window computer (no LINUX, no Mac) : so any feedback for how the plugin work (or not) on these platforms is welcome
I will try to compile wxGTK on Windows, and Codeblocks as well - maybe I can have a second platform for testing.

Good luck for your headache - I know the problem...
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on April 12, 2010, 11:00:32 pm
I have updated the SVN.
I have corrected some bugs with resizing, and simplified the code.

Title: Re: Image Editor - new plugin
Post by: jens on April 13, 2010, 09:53:31 am
I attach a patch that uses wxCustomButton from
Code: [Select]
wxSmithContribItems[/b] and works for me (linux) and a linux project-file, that can be used if the sources are below src/plugins/contrib.
The project-file has to be renamed to  be usable (remove the .txt-ending).

On windows the build options have to be fixed to find the custombutton lib and header.

[attachment deleted by admin]
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on April 13, 2010, 11:20:56 pm
Hello,

thank you Jens for your patch.
My Internet was down today, so I did not see your patch.
I will try it tomorrow.

Anyway, I have followed your advice, and I have used the wxCustomButton: it works on Window. I have just updated the SVN - you may have a try.
I have copied the relevant code in the plugin - this way, I do not depend on wxSmithContribItems.

Have a nice evening.
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on April 13, 2010, 11:33:28 pm
I have also updated the archive 7z on sourceforge
Question: imagine I consider that my SVN repository on sourceforge is a mess (a lot of useless files, like .obj or some unused bitmaps).
Is there an easy way to clean it ?
I have TortoiseSVN, on Windows Vista
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on April 14, 2010, 11:06:46 pm
Hello,

I have commited some code on the SVN.
Last changes:
     1 - some bugs solved (on resizing, line drawing, ...)
     2 - start implementing Drag 'n' Drop for the selection (no finished and currently buggy. Try it at your own risk...)
     3 - cleaned a bit the code (broke down the big ProcessToolInAction method in several smaller one - it is more manageable)
     4 - IsCursorInSelection method added

What is missing (next)
     1 - finish Drag 'n' Drop
     2 - implement Stretch Selection
     3 - test 1 & 2
     4 - Implement the Text tool (should not be too difficult).

Let me know what you think.
Regards,

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on April 15, 2010, 11:00:10 pm
Hello,

I have commited a revision on SVN (revision 12)

 changes:
    - dragging selection is working
    - copy / paste / cut is also working
    - small improvements in saving / loading (check format)
    - code cleaning (again)

 the 2 first changes make the plugin much more useable

 next topics I will work on:
    - save bitmap under the selection - so when re-dragging the selection, the old image will be restored
    - Text tool
    - resize / stretch selection

@Jens : I do not know if you have time - but if you have and if you want, you can test again the plugin.
            I have seen the patch you sent me 2 days ago, and I have already applied it (use wxCustomButton)*
            Thanks for the help !

Regards,

Sebastien
Title: Re: Image Editor - new plugin
Post by: ollydbg on April 16, 2010, 06:17:22 am
Cool and Great!! :D
I love it!
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on April 18, 2010, 11:27:48 pm
Hello,

I have made an update on the plugin.
What is new:
  - text tool is done - needs debugging
  - dragging selection is working
  - arrows keys move selection, del / suppr / backspace delete it
  - stretching is implemented, needs testing & debugging [edit: does not work at all - need reviewing...]
  - several bug fixes

Nearly everything is done

See todo.txt for an accurate state of the plugin.

Sebastien
Title: Re: Image Editor - new plugin
Post by: danselmi on April 19, 2010, 06:26:13 pm

Is it possible that you missed to add/commit wxResizeCtrl.cpp/wxResizeCtrl.h?

Title: Re: Image Editor - new plugin
Post by: seb_seb0 on April 19, 2010, 08:57:36 pm

Is it possible that you missed to add/commit wxResizeCtrl.cpp/wxResizeCtrl.h?



Yes, it is possible !
I have corrected it now.

I have added a lot more things as well:
  - now stretching selection is working
  - add image / selection rotation
  - Text tool improved (alignement & orientation added)
  - conversion to grey scale or monochrome
  - stretch whole imaging
  - mirroring
  - bluring

Let me know if you have problems !

Sebastien
Title: Re: Image Editor - new plugin
Post by: MortenMacFly on April 30, 2010, 12:05:33 pm
...I think in SVN quite some files are missing. I am at least unable to compile this plugin at all meanwhile... It used to work though.
Title: Re: Image Editor - new plugin
Post by: jens on April 30, 2010, 12:43:34 pm
I had the same problem.
The cause was a non-empty .obj-directory,
.obj was (is) in svn and svn update stopped with an error after trying to update .obj.
All files that came after it (alphabetically I think) have not been updated.
Title: Re: Image Editor - new plugin
Post by: MortenMacFly on April 30, 2010, 01:24:07 pm
I had the same problem.
The cause was a non-empty .obj-directory,
I doubt that this is it. If I look at the project file I see references to missing files not in the SVN tree. If you open the project tree in C::B they are missing, too and obviously the linker won't find them.

Edit: I am talking about SVN trunk, Revision 26.
Title: Re: Image Editor - new plugin
Post by: jens on April 30, 2010, 02:12:07 pm
I had the same problem.
The cause was a non-empty .obj-directory,
I doubt that this is it. If I look at the project file I see references to missing files not in the SVN tree. If you open the project tree in C::B they are missing, too and obviously the linker won't find them.

Edit: I am talking about SVN trunk, Revision 26.
You are right.
I just downloaded trunk on windows and ColourPickerPanel.* and QuickHelp.* are liosted in the project-file, but missing from svn.

But after removing them I have no problems compiling the plugin.
Title: Re: Image Editor - new plugin
Post by: MortenMacFly on April 30, 2010, 02:40:20 pm
But after removing them I have no problems compiling the plugin.
Stupid me :?. I should have tried that. I was thinking they were needed somehow... Works here now, too. :-)
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on April 30, 2010, 11:12:36 pm
Sorry for all the confusion in the SVN repository !

   1 - it is true that I have removed some useless folders like the .obj
   
   2 - After removing so many files, I should have done a test check-out (I am still a newbie with SVN, and I am making mistakes...)
        I will test next time

   3 - I had last week a very heavy work schedule, and I did not have the time to update the plugin. So no opportunity to spot and / or correct the mistakes

   I have just made an update of the SVN (revision 27) - now it is working (I have tested with a fresh check-out)

   Hopefully I will have more time now, to finish the plugin.
   During the last updates, I have added some basic Image manipulation (flipping / rotating / converting to grey scale ...) This  operation are useful when editing a set of similar icons, and / or a set of icon for the same button (grey scaled can be used for disabled bitmap for example).

  I will not add new features - I think the panel is more or less complete.
  The roadmap is now:
     - correcting all the points described in todo.txt
     - finishing implementing the "rotate hue" manipulation (1 good call to wxImage::RotateHue and it is finished)
     - testing, debugging, releasing

  After a first release, I want to:
     - add possibly a configuration panel
     - add a Quick Help dialog
     - review a bit the interface, using either: wxAUI, wxFoldedPanel, hideable panels, ... the area is a bit too much cluttered with the tools to my taste

   Sebastien
 




Title: Re: Image Editor - new plugin
Post by: seb_seb0 on May 02, 2010, 10:43:38 pm
Hello,

I have made updates to the XPMEditor plugin.
The main changes are in the drawing tools:
   1 - WYSIWYG (this was not the case before, since scale factors were not identical ...)
   2 - correct some inaccuracies (problems when dragging selection, copy / paste was 1 pixel too much, ...)
   3 - discovered some bugs in the process, and corrected some of them (the other are documented in the todo.txt file)
   4 - Selection frame is now inverted - the previous was blue. Not really useful when it is located on a blue rectangle...
   5 - the colour of the Grid is now customizable.

SVN is updated (revision 28 - this time I have tested it !)

One quick note: the progress seems to be slow - a drawing editor ought to be simple to program. I stumbled unto many problems, including bugs in wxWidgets (SetUserScale is innacurate).
Since the editor should be optimized for small images with big zoom factors, I have to be careful about accuracy... And it has caused me many problems (solved now), which took most of the programming time this week-end.

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on May 20, 2010, 10:08:08 pm
Hello,

I have updated the plugin.
Here is the list of changes:

   1 - solved bug with resize selection with big zooms
   2 - Invert colours Selection / Image is now possible
   3 - Rotate Hue: from colour to colour (interface improved)
   4 - Bug solved: Undo : mask colour not saved, and resetted to black after Undo.
   5 - Moved some of the widgets to separate panels - it will make it easier to hide / show them

Next in planning, probably in this order (mainly bug solving):
Bugs to be solved:
1 - Copy / Paste:
    before copy : bitmap put in clipboard has a Mask
    after paste : bitmap does not have mask
2 - Zoom + Pen does not work good after moving selection
3 - Selection is not drawn when it is overlapping bitmap edges + zoom
4 - Redraw background: the bottom right corner is not covered when zooming out
5 - Save As: does not update the file status in the Project Manager

Improvements:
1 - improve the interface : allow to hide some widgets, to clear some drawing surface (useful mainly for laptop users, with small screens)
     Partially done - some work remains to do.
2 - Quick Help display

Regards,

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on May 25, 2010, 11:14:37 pm
Hello,

the plugin is not dead.
I have solved several bugs - but currently, due to UI rework, the plugin is currently broken (nothing big, I am just in the middle of a change. Some panels are not resized correctly, hiding the controls...).
Therefore I will not commit the sources until this problem is solved.

I still have a heavy workload at work (a bit less though) so I cannot work as much as I want on this plugin.

In parallel, I have found a way to install Ubuntu 10.4 on my computer (using VirtualBox, to avoid a nasty and potentially dangerous hard disk partionning). I am currently compiling CodeBlocks (last SVN). The goal is to correct myself the most obvious Linux bugs in my plugin (and to learn the tools for programming on Linux as well ! :-) )
So far, so good, it is still compiling (thanks google & the wiki).

I will let you know when I make substancial progress (not before the 28.05 though - I have work appointments

Sebastien
Title: Re: Image Editor - new plugin
Post by: ptDev on May 26, 2010, 08:51:12 am
Hello,
[...]
In parallel, I have found a way to install Ubuntu 10.4 on my computer (using VirtualBox, to avoid a nasty and potentially dangerous hard disk partionning).

Have you tried wubi (http://wubi-installer.org) already? It uses loop-mounting, which means you can dual boot without partitioning the hard disk. I always see emulation as a last resort.
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 11, 2010, 08:49:39 pm
Hello,

I am back - sorry for not giving more feedback, I was overloaded with work.

I have uploaded a working version of the plugin in the svn repository.

So here is the status:
    What is new:
      1 - interface using wxAUI (a panel is managed by wxAUIManager): it allows to move all the controls outside the painting area, for users with small screens
           The plugin will read the wxAUI configuration from CodeBlocks, and will apply the same colours.
           BTW, is there a way to know when the user made a modification to these settings (event generated by CodeBlocks) ?
      2 - Improved the colour picker, for better integration in a resizeable panel
              better size calculation
              scrollbars available
              choose automatically to draw itselft in a vertical or horizontal direction
      3 - use an improved wxFoldPanelBar (contrib lib of wxWidgets 2.8.10) to hide/show the controls
              This improved version use sizers instead of absolute X,Y calculations. Scrollbars are automatically managed
              In addition, there is the possibility to use 3 kinds of caption bars : the normal one, programmed by Jorgen Bodde, or a flat wxButton (like wxSmith) or a wxButton


     Known Bugs:
      1 - Copy / Paste:
           before copy : bitmap put in clipboard has a Mask
           after paste : bitmap does not have mask
      2 - Zoom + Pen does not work good after moving selection
      3 - Selection is not drawn when it is overlapping bitmap edges + zoom
      4 - Redraw background: the bottom right corner is not covered when zooming out

     Planned:
     1 - Tools panel is a bit too big : sizer layout to review
     2 - Implement JPG and PNG compression quality options (not too difficult, wxImage.SetOptions is straightforward)
     3 - Write some help displayed in a dialog box, for quick introduction
     4 - misc improvements which can wait (see the todo.txt)

In parallel, I am trying to install Ubuntu 10.04 on my laptop using Wubi (@ptDev : thanks for the tip !), for improved testing (It is too bad that I can currently only test Windows version.)

I have 2 questions for the Code::Blocks experts here:
     1 - XPMEditor is basically a MIME plugin (derive from cbMimePlugin).
          When opening the codeblocks project from the "Start Here" welcome page, CodeBlocks automatically opens the XPMEditorPanel.cpp file, and also the test.bmp file.
          The plugin is already loaded in Code::Blocks
          The question is : why does code::blocks opens the file "test.bmp" automatically in TEXT mode (as if the file was a source file) ? When I close it and reopen it, the XPMEditor plugin is called, as expected.
(see 1st screenshot)

     2 - I would like to display the images files that the XPMEditor can open in a specific virtual folder (such as "images" or "resources").
(see 2nd screenshot)

Regards,

Sébastien


[attachment deleted by admin]
Title: Re: Image Editor - new plugin
Post by: oBFusCATed on July 12, 2010, 10:02:11 am
     2 - I would like to display the images files that the XPMEditor can open in a specific virtual folder (such as "images" or "resources").
(see 2nd screenshot)
You can define that *.bmp files can go to folder "images", somewhere in the Project menu. The menu option should be something related to file types/file associations.
Title: Re: Image Editor - new plugin
Post by: MortenMacFly on July 12, 2010, 04:18:59 pm
Right click on project, select:
- project tree -> edit file types and categories
-> setup ad desired
Enable:
- project tree -> categorize by file types
(- project tree -> hide folder names)
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 12, 2010, 09:50:12 pm
Right click on project, select:
- project tree -> edit file types and categories
-> setup ad desired
Enable:
- project tree -> categorize by file types
(- project tree -> hide folder names)


Thank you, that worked.
Is it possible to add this programmaticaly ? It is not necessarily needed, since it is very simple to do, but it is for my curiosity...
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 12, 2010, 10:34:33 pm
I have installed Ubuntu 10.04 on dual boot on my laptop.
I have also successfully installed Code::Blocks 10.05 on it (and it is running ! Yeah !)
Now I am fighting with the configuration (I cannot compile anything, because cb cannot find wxWidgets. I would like to help him, but I do not know myself where it is located... )

Please be patient ! Hopefully I will soon be able to test and debug my plugin on Ubuntu !

Sebastien

PS: 1st impression: it is a lot faster than on Vista (same laptop...) Code completions is much more reactive, load time of the codeblocks project took only a few seconds (against 30 seconds approximately on Vista). Do you know why there are so much differences ?
Title: Re: Image Editor - new plugin
Post by: jens on July 12, 2010, 11:03:12 pm
You should install libwxgtk2.8-dev, this will fetch all other needed packages, except for wx-common which includes wx-config.
After installing wx-common (and libwxgtk2.8-dev), you can create a wxwidgets example with the wizard and see how wx-config can be used.
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 12, 2010, 11:30:23 pm
Thank you for the tip !
I have found another solution, using "wx-config" in the command line (copied from Code::Blocks project).

The status is:
  - I have sucessfully compiled Code::Blocks (or I should say, no errors reported). I have not created the "output" directory yet, only "devel"
  - I have successfully compiled my plugin (yeah !!) with one caveat: wxDragImage is deactivated using #if #endif, I have to find another way compatible with wxGTK
    And I cannot load the plugin in code::blocks: I get the error message "this usually happens when plugin & application are built using different versions of SDK", or something like that

Solution I plan to apply:
  - finish the compilation and installation of Code::Blocks (find equivalent of "update.bat" on linux - it is certainly written somewhere on the wiki)
  - use the compiled codeblocks to load my plugin.

Or I may have done something very wrong.

Sebastien

PS: I discovered that linking with wxmsw lib does not work on linux :-)
PS2: I have installed codeblocks 10.05 using the debian packages provided by jens.
Title: Re: Image Editor - new plugin
Post by: ollydbg on July 13, 2010, 01:22:43 am
PS: 1st impression: it is a lot faster than on Vista (same laptop...) Code completions is much more reactive, load time of the codeblocks project took only a few seconds (against 30 seconds approximately on Vista). Do you know why there are so much differences ?
I have a similar experience about the parsing time of CodeCompletion. In the same notebook, Windows Vista is much slower than windows XP. To load the codeblocks.cbp, in Vista, it will take more than 1 minutes, but in XP, it is only 20 seconds. I'm not sure why, but surely XP is faster than Vista. Vista is too "bloat". :D

I have never used any linux like OS though.
Title: Re: Image Editor - new plugin
Post by: jens on July 13, 2010, 09:08:55 am
The equivalent to update.bat is update.
On a console go to the directory, where the main project-file is located and run ./update.
To start your new C::B you can run it through C::B or call the wrapper-script output/run.sh, using the new executable will not work directly.

If you want, I can create a patch tht uses your plugin from inside the contrib-plugins folder and also adds it to the automake system, so you can use the "normal" linux way with ./bootstrap; ./configure [...]; make; sudo make install.
You can use automake to create a test-version of C::B in another folder than the normal C::B is by using a different --prefix when running ./configure (I do this below my homefolder and have several working versions of C::B simultaneously)
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 13, 2010, 11:49:54 pm
Hello,

there are some progress:
  - I have found the "update" script and ran it. The output directory was created, as expected
  - I cannot run codeblocks from output (using "./codeblocks" command line), it complains about "libwxscintilla.so cannot be found".
    Probably a PATH equivalent not set correctly. I will try your tip regarding "--prefix" and look around on Internet for more Linux information
   
    Thank you for your proposal for doing a patch using my plugin: I prefer to find the solution to my problem, this is the best way to learn.

 On the good news :
   - I have solved the problem with wxDragImage. Now the plugin compiles without #if #endif on wxGTK
   - I have commited a XPMEditor_unix.cbp project file on the SVN (using SVN command line on Ubuntu !)
   - I have found a way to create an "Images" virtual folder in the project manager (thanks to Morten for pointing me in the good direction. I just had to look in Code::Blocks sources how it was done).
   - I have updated the code when saving and opening a file: now Image handlers are handled dynamically, this is not anymore a stupid algorithm based on hardcoded file extensions alone. This is not yet complete, but in good way.


And now I have to go to sleep. Good night !

Sébastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 13, 2010, 11:51:02 pm
PS: 1st impression: it is a lot faster than on Vista (same laptop...) Code completions is much more reactive, load time of the codeblocks project took only a few seconds (against 30 seconds approximately on Vista). Do you know why there are so much differences ?
I have a similar experience about the parsing time of CodeCompletion. In the same notebook, Windows Vista is much slower than windows XP. To load the codeblocks.cbp, in Vista, it will take more than 1 minutes, but in XP, it is only 20 seconds. I'm not sure why, but surely XP is faster than Vista. Vista is too "bloat". :D

I have never used any linux like OS though.

I confirm the speed difference between Ubuntu & Windows Vista. I have read somewhere it has something to do with DRM (Digital Rigths Management - anti-piracy).
Title: Re: Image Editor - new plugin
Post by: MortenMacFly on July 14, 2010, 07:18:04 am
 - I have found the "update" script and ran it. The output directory was created, as expected
  - I cannot run codeblocks from output (using "./codeblocks" command line), it complains about "libwxscintilla.
You cannot run C::B directly (that would need a make install, indeed) - but the update script also creates a run.sh script for you. You need to use this to run C::B.
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 14, 2010, 07:20:21 am
To start your new C::B you can run it through C::B or call the wrapper-script output/run.sh, using the new executable will not work directly.

And that will teach me to read correctly the posts.
Thank you jens, now I can start CB.
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 14, 2010, 07:30:50 am
I can start CodeBlocks, but the plugin does not load.

/home/seb/.codeblocks/share/codeblocks/plugins/XPMEditor.so: not loaded (missing symbols?)

There is probably something wrong in the plugin code.
I do not give up, I will find the solution !

I will try to create a simple plugin (using the wizard) and see what happens.

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 15, 2010, 07:38:49 am
OK, I have managed to load a minimal version of the plugin in Code::Blocks.
This narrow down the problem to the plugin code (as expected).

I will backtrack the svn revision to see where the problem occured at the first time

SVN 31 does not work ...

Note: please also be patient: my internet is flacky these last days. So if I do not post, it simply means I cannot !

Sebastien
Title: Re: Image Editor - new plugin
Post by: oBFusCATed on July 15, 2010, 10:47:03 am
I've found that adding '-z defs' to the linking options of a plugin helps a lot in the debugging undefined references... 8)
Title: Re: Image Editor - new plugin
Post by: jens on July 15, 2010, 11:14:33 am
What you can (and should do), if a plugin can not be loaded (or other problems occur), is to enable extra logging by setting the parameter of wxLog::EnableLogging at the beginning of OnInit in app.cpp to true.
Title: Re: Image Editor - new plugin
Post by: MortenMacFly on July 15, 2010, 12:39:57 pm
I've found that adding '-z defs' to the linking options of a plugin helps a lot in the debugging undefined references... 8)
True. We should add this to EVERY plugin in fact (I've done this partially already some time back...)
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 15, 2010, 10:10:19 pm
Hello,

thank you for everybody who helped.

Jens: I have followed your advice, Code::Blocks is currently recompiling.
Morten & oBFusCATed : once I have a new code::blocks, I will recompile the plugin with this option "-z defs"

I will post the results here.

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 15, 2010, 10:32:55 pm
You rock !!!!!!!!!!  :D :D :D :D :D :D :D :D :D :D :D

It works now !

I have applied the 2 tips above, and I got a message from Code::Blocks "OnDrawCanvasMouseLeave is not defined", or something like that.
I looked at the code, and I had a  #if __WXMSW__ around this method.
Strangely, it was not compiled on Ubuntu.

Now everything is working. Just this simple thing !!

I will update the svn (using Windows, because I have added several files, and I do not want to forget them.
I have to reboot now.

Sebastien

PS : how do we do a screenshot in Ubuntu ?
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 15, 2010, 11:01:45 pm
svn updated (revision 41) with new code & Unix project file
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 19, 2010, 11:42:30 pm
svn updated

1 - Remove files from SVN (*.layout, *.obj, *.depends, build log)
 2 - Remove ColourPickerPanel.cpp and ColourPickerPanel.h (unused - replaced by XPMColourPickerPanel.cpp and XPMColourPickerPanel.h)
     Remove XPMToggleBMPButton.cpp and .h from SVN
 3 - Add help support (via html display. Help remains to be written, but it is limited to writing 6 simple HTML files, located in the resource archive XPMEditor.zip)
 4 - Minimum size needed for the tool panel has been reduced and fixed
 5 - Load and Save file: use dynamic handler instead of static hard-coded switch statements based on file extension
     Moved all the code handling file format into XPMEditor.cpp
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 20, 2010, 09:39:03 pm
SVN Updated

 1 - advanced options implemented (JPG compression, PNG options).
 2 - added menu entries in Code::Blocks:
         File/New/New Image
         File/Open with XPMEditor
         wxSmith/Add Image
 3 - added file filter for FileOpen and FileSave dialog box.
 4 - file saving format can now be choosen by the user, bypassing file extension on request.
 5 - start to add fill options

Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 20, 2010, 09:43:29 pm
A few thoughts:
  • AFAIK it is not foreseen to add a file filter in the global CodeBlocks file open / save dialog box. The only way I found is to generate a lexer-configuration file (even if there does not exist a scintilla-lexer for bitmaps ).
  • Why do you not commit the code to the svn repo on sorceforge? It is also helpful for you.
  • Most other plugins use CamelCase namings (class and filenames) but this is only a matter of personal taste.

regards,
danselmi

Hello danselmi,

I have found a way to add file filters in the File Open / File Save dialog in CodeBlocks
You have to call FileFilters::Add()
You can have a look at how I have done it in XPMEditor.cpp
Code: [Select]
void XPMEditor::AddFileMasksToFileOpenSaveDialog(wxArrayString sFileMasks)
{
    wxString sImageMasks;
    wxString sMask;
    size_t i;

    //sImageMasks = wxImage::GetImageExtWildcard();
    sImageMasks = _("");
    for(i=0;i<sFileMasks.GetCount();i++)
    {
        sMask = sFileMasks.Item(i);
        if (sImageMasks.Len() > 0) sImageMasks += _(",");
        sImageMasks += sMask;
    }

    FileFilters::Add(_("Image Files"), sImageMasks);
}

This one work. I do not know if it is the best way to do it, but it make the job done.

Regards,

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on July 21, 2010, 10:47:35 pm
Hello,

SVN is updated (44)

 1 - Draw Opaque / transparent implemented
 2 - Line Style / Fill Style implemented wherever possible
 3 - Fixed a bug in Expand / Collapse panels at start

To do:
  1 - SHIFT key for drawing Square / Circle / horizontal line / vertical line
  2 - Helps + tooltips
  3 - bug correction (6 bugs to solve, 1 annoying)

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on August 05, 2010, 10:56:45 pm
Hello,

SVN is updated (45)

CHANGES:
 1 - ClearSelection called when a click is done
 2 - improved Pen, Brush & Eraser, when mouse is moved fast
 3 - Corrected a bug with the SHIFT key + Select tool.
     Now extend this functionality to all tools

BUGS:
1 - Copy / Paste:
    before copy : bitmap put in clipboard has a Mask
    after paste : bitmap does not have mask
2 - Zoom + Pen does not work good after moving selection
3 - Selection is not drawn when it is overlapping bitmap edges + zoom
4 - Redraw background: the bottom right corner is not covered when zooming out
5 - problem when the selection is bigger than the IMAGEINFO
6 - Drag image: flicker + cursor has a strange position sometimes.
7 - LINUX: Line not displayed dynamically

ROADMAP:
1 - add items 3 to 7 from todo list
2 - solve all the (known) bugs
3 - promote status to Beta
4 - test

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on August 08, 2010, 03:25:23 pm
SVN Updated (revision 46)

CHANGES:
 1 - Shift Key extended to other tools.
     Pen, Brush & Eraser to improve in this respect
 2 - Add a ClearSelection that I missed
 3 - LINUX: corrected a nasty bug: crash when using a complex selection
     The crash did not come from ProcessLassoTool as expected, but from IsPointInSelection.
     GTK was trying to create a polygon with less than 3 points => it raised an unhandled exception
     Bug fixed by adding a test
 4 - LINUX: corrected a widespread bug when using the wxMemoryDC.
     wxMemoryDC was created blank (without Bitmap selected). Once created, a wxMemoryDC::IsOk was called.
     On Windows it returns OK when no BMP are selected, but on GTK it returns FALSE
     Hence the drawing never took place, leading to strange results
     Fixed by moving all the call to wxMemoryDC::IsOk after selecting the bitmap
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on August 09, 2010, 11:34:46 pm
SVN Updated (47)

CHANGES:
1 - Interpolation improved
2 - Some bugs solved
      a - Selection is not drawn when it is overlapping bitmap edges + zoom
      b - Pen problem after Move Selection + Zoom
      c - Redraw background: the bottom right corner is not covered when zooming out
      d - problem when the selection is bigger than the Image
      e - Drag image: flicker on Win32 + cursor has a strange position sometimes.
3 - Reduced size (width) of the tool palette
4 - added options for Brush & Fill tools
5 - Added stubs & interface for Spray Can tool
    (need to implement 2 methods correctly:
    XPMEditorPanel::ProcessSprayCan() and XPMToolPanel::CreateSprayCanBitmap())
6 - Added stubs & interface for Gradient tool
    (need to implement only XPMEditorPanel::ProcessGradient(). Partially working for Linear gradients, crashing for concentric gradients)


TO DO UNIX:
 1 - add 2 icons (spray can + gradient) to Project
 2 - test that the DragImage is not broken
Title: Re: Image Editor - new plugin
Post by: MortenMacFly on August 10, 2010, 08:41:09 am
SVN Updated (47)

 1 - add 2 icons (spray can + gradient) to Project
...these images are missing in SVN and therefore break compilation. :-)
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on August 11, 2010, 10:00:09 pm
SVN Updated (47)

 1 - add 2 icons (spray can + gradient) to Project
...these images are missing in SVN and therefore break compilation. :-)

Just give me the time to reboot and log on Ubuntu. I will fix this immediately.

By the way, SVN updated (rev 49) for Windows (and SVN tested with a check-out on a fresh directory):

CHANGES:
1 - Gradient tool implemented
2 - SprayCan Tool implemented
3 - Text Tool fixed


TO DO UNIX:
 1 - add 2 icons (spray can + gradient) to Project
 2 - test that the DragImage is not broken
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on August 11, 2010, 11:15:50 pm
SVN updated (50)

CHANGES & INFO:
1 - added the missing files in LINUX Project
2 - fixed DragImage on LINUX (tested successfully on LINUX and Windows without too much flicker)
3 - spray can & Gradient Linear works on LINUX
4 - Gradient concentric broken on LINUX (wxWidgets bug)

Title: Re: Image Editor - new plugin
Post by: seb_seb0 on August 12, 2010, 10:03:49 pm
SVN updated
I have fixed the wxGTK problem with wxGradientFillConcentric (I have reimplemented it).
A side effect is that it looks nicer on Windows.

I have in parallel submited a a patch to wxWidgets ticket trackers.

I have still a few features to implement (therefore I do not move the status to beta yet). However they are now minor (ctrl-A, copy from / paste to a file)
I consider dropping any kind of customisation options that must be saved in a configuration file: it will make the plugin a bit safer.
I have still a few bugs to solve (see todo.txt)

I would be interested in some feedback from other testers.

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on August 13, 2010, 09:19:34 pm
SVN Updated (52)

CHANGES:
1 - some bugs solved (related to right-click handling and font bug).
2 - Select All implemented
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on August 14, 2010, 11:14:57 pm
SVN Updated (53)

CHANGES:
1 - bug solved Copy / Paste:
    before copy : bitmap put in clipboard has a Mask
    after paste : bitmap does not have mask
    Solved by adding a custom data format in the clipboard

2 - Change in Text Tool.
    Currently partially broken (orientation not taken into account) due to the changes.
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on August 17, 2010, 09:19:24 pm
SVN Updated (54)

CHANGES:
1 - Copy To / Paste from file implemented (via context menu)

2 - DragImage: bug solved to some extent when selection is large (zoomed for example)
    The cursor in that case was disappearing
    In addition, the flicker has been removed
    Solved by reordering the Drawing operations, and modifications of XPMEditorPanel::ProcessDragAction
    (hiding the drag image and repainting were not necessary).
    Note: the bug is still appearing for very big zoom (x16) and large screenshot (screen size)). The system cannot allocate memory I guess (too big bitmap). I am looking for a better way.

3 - Drag action: now holding the shift key will prevent the image to be deleted

4 - Bug solved in Drag Action: 1 or 2 pixels innacuracy in draging selection with the mouse

5 - Bug solved: PasteImage gives a black image when the image is truncated

6 - Bug solved: ClearSelection: when the image to paste is bigger than the destination image, nothing is done sometimes

Title: Re: Image Editor - new plugin
Post by: seb_seb0 on August 30, 2010, 10:50:45 pm
Hello,

I have updated the SVN (revision 55).
I have done many updates in the tool (mainly internal - nearly no new features - I have focused on debugging).

CHANGES:
1 - Copy To / Paste from file implemented (via context menu)

2 - DragImage: bug solved when selection is large (zoomed for example)
    The cursor in that case was disappearing
    In addition, the flicker has been removed
    Solved by reordering the Drawing operations, and modifications of XPMEditorPanel::ProcessDragAction
    (hiding the drag image and repainting were not necessary).

3 - Drag action: now holding the shift key will prevent the image to be deleted

4 - Bug solved in Drag Action: 1 or 2 pixels innacuracy in draging selection with the mouse

5 - Bug solved: PasteImage gives a black image when the image is truncated

6 - Bug solved: ClearSelection: when the image to paste is bigger than the destination image, nothing is done sometimes

7 - Bug solved: MIME Handling: when no extensions was available in the file name, the Plugin was trying to open the file anyway
                and gave no chance to the default MIME handler.

8 - Added default context menu entries in Project Manager

9 - Remove some flickering when creating the editor

10 - Bug solved: When dropping a file on Code::Blocks, the file is displayed correctly - however, the Zoom function does not work.
     Editing & Saving are working.
     Loading the SAME file using the Project Manager or the File/Load menu gives normal results (no bug)

11 - Pen + Brush + Eraser: SHIFT key behaviour implemented

12 - bug solved Copy / Paste:
    before copy : bitmap put in clipboard has a Mask
    after paste : bitmap does not have mask
    Solved by adding a custom data format in the clipboard

13 - Change in Text Tool.
    Currently partially broken (orientation not taken into account) due to the changes.

I am currently working on wxDragImage : I must rewrite it in part, because I have problems with large zoom (up to 1 GB memory used for a stupid bitmap...).

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on September 02, 2010, 10:34:56 pm
SVN Updated (revision 56)

I have solved the main bug in wxDragImageExt : the (unreasonnably) large memory consumption leads to the disappearance of the dragged image.
Now this problem is completly solved, removing the last really big bug preventing the plugin from working.

For dragging image, 2 small problems remain:
  1 - there is a flicker when starting the drag (1st click only)
  2 - there is a 1 or 2 pixel innacuracy with big zoom (the image is pasted 1 or 2 pixel too much to the right and to the bottom). Occurs with large zoom factor (I test with zoom = 1600 %)

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on September 03, 2010, 07:33:19 am
SVN Updated (revision 57)

CHANGES:
  - licence modified from "GPL" to "GPL v3" in manifest.xml
  - LINUX: Zoom box is now displaying the correct value

BUG FOUND: zoom factor is not working in LINUX anymore. There is probably a problem when scaling the bitmap.  :(
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on September 05, 2010, 10:21:05 pm
SVN Updated (revision 59)

CHANGES:
    1 - fix the bug with wxGTK regarding zooming
    2 - fixing the bug in 1 lead to refactoring wxDragImageExt. This is still a work in progress (changes are not committed in SVN : this is still working in Windows. I seriously doubt it is working on Linux -> I am going to test).

Sebastien

Title: Re: Image Editor - new plugin
Post by: seb_seb0 on September 23, 2010, 10:14:54 pm
SVN Updated (revision 60)

Changes:
1 - DragImage partially corrected. There are still 2 bugs
         a - when dragging the selection over the left or top edge of the bitmap, it has an inconsistent behaviour (dragging 1 pixel outside the bitmap will clip the selection by 2 pixels)
         b - when dragging very large bitmap, the selection is clipped too much.

  I am still working on it

2 - scrollbars behaviour improved (scrolled by 1 pixel only)

3 - a few minor bug fixes.

Sebastien
Title: Re: Image Editor - new plugin
Post by: seb_seb0 on October 18, 2010, 09:03:18 pm
Hello,

I have updated the SVN (revision 61)

Changes:

BUGS SOLVED:
    1 - DragImage solved, wxGTK + wxMSW (without #define conditionnal compilation)
    2 - Zoom > 200% + Selection overlaps on left edge: selection is only partially drawn.
    3 - Context menu: when a mouse click close the context menu, it should not send a mouse click event (because it clears the selection)
    4 - Resizing selection: resizing once will paste the selection
                            loss of quality when resizing to original solved. However, it comes at the price of loosing mask information

IMPROVEMENT:
    1 - replace m_Image pointer by a direct object instance (simplify the code in several place)


Now I have solved all the (known) bugs, and I have implemented everything I wanted. Therefore I move the status to BETA.

What remains to do:
   1 - some documentation
   2 - some speed improvement on wxGTK

Let me know what you think !

Sebastien
Title: Re: BETA - Image Editor plugin
Post by: seb_seb0 on October 25, 2010, 09:36:40 pm
Hello,

I have updated the svn repository (revision 64).

IMPROVEMENT:
    1 - catch events when environment settings are updated (to update wxAUI colors)
    2 - added some tooltips and help text (only in code. Not displayed yet). Work is still in progress.
    3 - SVN repository cleanup (removed the compiled files XPMEditor.cbplugin, XPMEditor.dll, XMPEditor.zip, test.bmp)

QUESTION FOR THE CODE::BLOCKS TEAM:

I am using wxAUI in my plugin. Since there are some Code::Blocks settings for wxAUI (menu Settings / environment / Docking system), I think it is better if the plugin uses the same settings as the IDE.
There are, at my knowledge, no events indicating that settings have been updated.
The only way I have found to know when settings are updated is to use a hack. I am using this notification update in Codeblocks/src/main.cpp
      
Code: [Select]
void MainFrame::OnSettingsEnvironment()
                {
                  ...
                  Manager::Get()->GetLogManager()->NotifyUpdate();
                }
       

I have therefore created a fake logger: it derives from the class
Code: [Select]
Logger, but if does not create a control. It implements the UpdateSettings virtual methods, but none others. The result is that it works as expected, and it does not add an additionnal Tab in the log window.
In short, it does what I want.

However, I keep thinking it is a hack. Is it possible to add a Code::Blocks event when some settings are updated ?

Sebastien
Title: Re: BETA - Image Editor plugin
Post by: seb_seb0 on October 26, 2010, 08:16:48 pm
Hello,

I have updated the SVN (revision 65)

CHANGES:

1- corrected a bug in wxDragImageExt: the transparent (masked) pixels of the image were drawn
2 - added tooltips to all controls. Currently adding context help strings (strings added in code, display needs to be done).

I continue working on help text. Then I will write a few html pages for online help. And then I will try to improve performances on wxGTK.

Sebastien
Title: Re: BETA - Image Editor plugin
Post by: MortenMacFly on October 26, 2010, 09:07:36 pm
QUESTION FOR THE CODE::BLOCKS TEAM:
There are, at my knowledge, no events indicating that settings have been updated.
That is true. If this makes sense for plugin we can think of an event. Nevertheless, you can always query configmanager if this setting is persisted (which is normally in the case for settings). That might be another option.

Besides that if you come up with a patch that's surely worth a look into.
Title: Re: BETA - Image Editor plugin
Post by: seb_seb0 on October 27, 2010, 08:54:27 pm
QUESTION FOR THE CODE::BLOCKS TEAM:
There are, at my knowledge, no events indicating that settings have been updated.
That is true. If this makes sense for plugin we can think of an event. Nevertheless, you can always query configmanager if this setting is persisted (which is normally in the case for settings). That might be another option.

Besides that if you come up with a patch that's surely worth a look into.

OK, I will try to do a patch - I believe it is a good functionnality.
I could also follow your other suggestion and regularly check the configuration file. But it is a bit overkill for just setting wxAUI colour. Therefore I will go with the patch.

Sebastien
Title: Re: BETA - Image Editor plugin
Post by: MortenMacFly on October 27, 2010, 08:59:55 pm
But it is a bit overkill for just setting wxAUI colour. Therefore I will go with the patch.
Why? That's how C::B stores / reads the settings. I mean you should do this only once on startup. That might be sufficient.
Title: Re: BETA - Image Editor plugin
Post by: seb_seb0 on October 27, 2010, 09:09:55 pm
But it is a bit overkill for just setting wxAUI colour. Therefore I will go with the patch.
Why? That's how C::B stores / reads the settings. I mean you should do this only once on startup. That might be sufficient.

Maybe you misunderstood me. When I create an editor, I read the configuration to get the wxAUI settings (colours & size). See in XPMEditorPanel::BuildContent this line (at line 168):
Code: [Select]
UpdateAUIColours();
It will read the configuration, and set the Font, Metrics and Colours for wxAUI.

So on creation, the user settings are respected.
However, if an image editor is already opened, and if the settings are changed by the user, then the new settings are not respected in the already opened editors. This is the only reason why I want to catch this event.

Sebastien
Title: BETA - Image Editor plugin
Post by: seb_seb0 on November 04, 2010, 08:36:52 pm
Hello,

SVN has been updated (66)

Main changes:

1 - add a patched xpm handler: the one from wxWidgets does not read the images when they have comments inside

2 - added HELP

3 - Size of Tool Panel fixed.

To do:
improve performance on wxGTK (working on it)
do the html doc

Sebastien
Title: Re: BETA - Image Editor plugin
Post by: seb_seb0 on November 28, 2010, 08:54:10 pm
I have noticed a crash on Linux (this is why the plugin is still in Beta stage).

I cannot find the reason of the crash. The following piece of code is sufficient to make code::blocks crash:
Code: [Select]
void XPMEditor::OnAttach()
{
     if (m_Singleton == NULL)
    {
        const FilesGroupsAndMasks *fm = Manager::Get()->GetProjectManager()->GetFilesGroupsAndMasks();
        wxString sMask;
        if (fm) sMask = fm->GetFileMasks(0);

        m_Singleton = this;
    }
}

with the following call stack:
Code: [Select]
<frame level="0" function="wxFatalSignalHandler" offset="00000026"/>
<frame level="1"/>
<frame level="2" function="wxBaseArrayPtrVoid::GetCount() const" offset="00000006"/>
<frame level="3" function="FilesGroupsAndMasks::GetFileMasks(unsigned int) const" offset="00000021"/>
<frame level="4" function="XPMEditor::OnAttach()" offset="000001d2"/>

And whaterver workaround I try, I always receive a crash with either wxBaseArrayPtrVoid::GetCount() or wxBaseArrayPtrVoid::Add()

This crash does not occur on Windows, only on Linux. It is totally impossible to understand for me.
So since this feature is not critical (addition of a virtual folder in the project manager for images), I will simply skip this step for Linux.
But I would like to understand.
Does anybody have an idea on what is going on ?

Sebastien
Title: Re: BETA - Image Editor plugin
Post by: jens on November 28, 2010, 10:05:53 pm
It works fine here, after some changes to the project-file to make it buildable from inside svn-tree and to use the same configurationa s the (most) contrib-plugins.

The second part of the project-file patch is most likely because of different line-endings.
In XPMEditor.cpp I just added your three lines and removed one unneeded space in a menu-entry.
Title: Re: BETA - Image Editor plugin
Post by: jens on November 28, 2010, 10:18:33 pm
But I sometimes get a crash, if I close the editor-tab, it does not happen reliable.

I will see if I find a cause or a regularity, but at the moment it seems more or less random.
Title: Re: BETA - Image Editor plugin
Post by: seb_seb0 on November 29, 2010, 09:41:39 pm
But I sometimes get a crash, if I close the editor-tab, it does not happen reliable.

I will see if I find a cause or a regularity, but at the moment it seems more or less random.

Thanks for the patch, I will have a try.
For the irregular crash, I have noticed it also - I will track it once I have solved the other problem.

Sebastien
Title: Re: BETA - Image Editor plugin
Post by: seb_seb0 on November 30, 2010, 10:10:47 pm
The patch provoked a mistake in my build => Codeblocks was complaining of not being able to find "XPMEditor.zip" (I checked it was there).

EDIT: I have found the reason of the problem : a directory "home/.codeblocks" has been created, and the lib from the "cbplugin" file was copied there. Apparently it posed some problems since I used a self compiled version from Codeblocks on Linux (latest SVN now) to avoid SDK mismatch. Removing this directory seems to solve the problem for now. The plugin could not be loaded, and all other plugins as well... Is it a new feature on Linux ? Or was this directory already present in the past ?

So what I will do:
  - rebuild codeblocks on Linux (it is probable I have broken something, because compiler plugin disappeared also. Better to have a fresh start)
  - I will create a minimal plugin with the wizard in Linux - and probably try if the strange bug still happens.
  - I will migrate the XPMEditor plugin to Linux again

For wxGTK performance, I have found the bottleneck: the scaling of a bitmap takes a LOT of time - and it was done in the Paint handler...
So I have found a workaround, but it involves some rewriting of the paint methods.
It is not that much work.
Since I am there, I will add an option (compile time or runtime) to use 1 of the 2 behaviours
   - scaling during the paint handler : fast on Windows, takes less memory
   - scaling outside the paint event, meaning keeping a big bitmap around => takes more memory, but faster on Linux (I made a test: a bitmap 500 x 250 scaled to 1600% will increase memory consuption by 100 Mb).

Please be patient !

Sebastien
Title: Re: BETA - Image Editor plugin
Post by: jens on November 30, 2010, 11:21:54 pm
 :oops: Forgot to write:
you need to put your sources into src/plugins/contrib with my patch and remove anything related to the plugin from ~/.codeblocks/share/codeblocks and ~/.codeblocks/share/codeblocks/plugins,  because the plugin will be placed in the output tree (below src/devel and src/output after running the update-script).
Title: Re: BETA - Image Editor plugin
Post by: seb_seb0 on December 02, 2010, 08:20:47 pm
OK, I managed to get the plugin to be installed, but I still have the crash.
Maybe it is something specific to my installation - I will continue to investigate...
Title: Re: BETA - Image Editor plugin
Post by: seb_seb0 on December 02, 2010, 08:44:33 pm
After a cleaning and rebuilding Codeblocks and the XPMEditor, I have no more crashes !!
Yes!!

Now I can focus on improving the performance for wxGTK.

Sebastien
Title: Re: BETA - Image Editor plugin
Post by: MortenMacFly on January 11, 2011, 04:10:43 pm
Something I noticed while using:
1.) Although clicking on ICO (icon resource) files works, the editor does not handle them correctly, i.e. all is white.
2.) XPM files with multiple resources are handled as if they had just one image. After saving the other images are all lost.
3.) The tool section "image modification" has no icons - only buttons with long text. This is probably by design.

...besides I created / manipulated quite some resource files meanwhile. It seems to have become quite stable. Good work! :-)
Title: Re: BETA - Image Editor plugin
Post by: seb_seb0 on January 11, 2011, 09:03:49 pm
1.) Although clicking on ICO (icon resource) files works, the editor does not handle them correctly, i.e. all is white.

I will look into it. It is probably a wxWidgets problem though (but maybe I am calling the wrong image handler)

2.) XPM files with multiple resources are handled as if they had just one image. After saving the other images are all lost.
I did not know that XPM can have multiple images into it. It can be a bit tricky to handle (Open multiple editors ? Ask the user which image to open ?). Besides, wxWidgets handler does not make provisions for it. But since I have already patched it (to handle XPM with C++ comments inside), I can maybe improve it.

3.) The tool section "image modification" has no icons - only buttons with long text. This is probably by design.
This is by design. The reason is: I have not found explicit icons for them. It can be improved, but it is not critical.

...besides I created / manipulated quite some resource files meanwhile. It seems to have become quite stable. Good work! :-)
Thank you for the support ! There is still a crash occuring on Linux, to fix.
Title: Re: BETA - Image Editor plugin
Post by: MortenMacFly on October 17, 2015, 07:53:55 pm
I have started to program a new Code::Blocks plugin.
I've sent you a patch through the patch tracker at SF.net to make this plugin compile again on recent C::B, including project files for wx30 andwx30-64 bit. Feel free to apply.

BTW: I am not the only one still using this plugin...
Title: Re: BETA - Image Editor plugin
Post by: seb_seb0 on October 25, 2015, 08:51:38 pm
I've sent you a patch through the patch tracker at SF.net to make this plugin compile again on recent C::B, including project files for wx30 andwx30-64 bit. Feel free to apply.

BTW: I am not the only one still using this plugin...

So much time as passed since I have last modified this plugin that I supposed nobody were interested anymore. I became quite busy with other topics (heavy workload at work + founding a family - 2nd kid underway) that it shifted low on my priority list.

I am still using it everyday (for icons works mostly).
I will apply your patch on the source forge repo, and maybe apply mine as well
Do not expect me to be lightning fast unfortunately.

Thanks for the contribution and the support.
Title: Re: BETA - Image Editor plugin
Post by: seb_seb0 on October 26, 2015, 09:26:40 pm
repository on sourceforge updated.
Thank you for the patch !