Author Topic: toolbar bottom edge is not shown corectly under C::B build with wx git master  (Read 31040 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
@cacb: In your Linux's screen shot:

So, the toolbar have both spaces in the top and bottom edges, you expect those edges should be smaller, right?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
@cacb: Sorry, I've asked the wrong question - it should have been - "What gtk theme are you using?"

This is what affects drawing of such controls.
Can you also try the auidemo sample or some other wxwidgets sample to verify that the problem happens there, too?
I'm sure it will happen.

Edit: What is the resolution of you display?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Can you also try the auidemo sample or some other wxwidgets sample to verify that the problem happens there, too?
The wx demo's should not have such issue(I have tested under Windows about one year before), because this issue is caused by our customized xrc loader, see discussion in this thread before(you can see the previous posts).

The wx guys are adding more vertical spaces as in wx 3.0+ compared with wx 2.8.12. This is because we more large screen resolutions nowadays(for me, I'm using a 1920x1080 for 14 inch screen), so people don't care about the added one or two pixels. But for a low resolution screen(as I have an old laptop which is 1280x800 for 14 inch screen), adding one or two space pixesl in the vertical edge may not look good, since the toolbar may looks too high in the vertical direction.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
So, the toolbar have both spaces in the top and bottom edges, you expect those edges should be smaller, right?
Yes, that is correct. This becomes problematic when there is also extra space used left & right of each toolbar item, making the toolbars extra wide. Because they are extra wide, you really need two rows of toolbars, but then you lose twice as much vertical space. So it really adds up.

Ideally, I would like something much more compact (like on Windows). The toolbars were always using more space on linux than windows but it became much more noticeable when I moved from Kubuntu 15.10 (+C::B compiled with wx 2.8.12) to Kubuntu 16.10 (+C::B compiled with wx 3.0)

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
@cacb: Sorry, I've asked the wrong question - it should have been - "What gtk theme are you using?"
This is what affects drawing of such controls.

It is just the default KDE desktop under Kubuntu 16.10, I think that is "plasma". Is that an answer? I don't have that computer available right now, will try to check tonight.

Can you also try the auidemo sample or some other wxwidgets sample to verify that the problem happens there, too?
I'm sure it will happen.

I will check this and get back to you. Btw, I have a couple of wx GUI applications I have written myself that is using AUI toolbars, and I do not see such issues there, the toolbars are ok. But I will try the auidemo also.

As far as I could tell from browsing the C::B source for the code completion plugin, the C::B toolbars are based on wxToolbar, not wxAuiToolbar, not sure if it makes any difference.

Edit: What is the resolution of you display?

I believe it is 1920x1200, will check later.

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
It is just the default KDE desktop under Kubuntu 16.10, I think that is "plasma". Is that an answer? I don't have that computer available right now, will try to check tonight.

The desktop theme is "Breeze"

I will check this and get back to you. Btw, I have a couple of wx GUI applications I have written myself that is using AUI toolbars, and I do not see such issues there, the toolbars are ok. But I will try the auidemo also.

See attached image (how do you embed images here??). At the top the C::B toolbar, below is the wxWidgets 3.0 auidemo with much more compact toolbar. At the bottom an application I have made with wxSmith and AUI.

Edit: What is the resolution of you display?

I believe it is 1920x1200, will check later.

Confirmed 1920x1200

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Here is how they look on my machine and theme: (both wx3 and 2.8 )



It is obvious that the toolbar with wxChoice control is bigger than the one without it.
Also it is obvious that our toolbars and the ones in the auidemo/your sample are different. Now we need someone to dig a big in the code and try to make them look the same.

p.s. it is better idea to use image sharing site instead of image attacments here.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
I found out something interesting

When using wxAuiToolbar, if you add the code below, the toolbar items are much more packed. If you don't call it, the default is similar to calling it with a paddeing value = 3. My toolbars are created with wxSmith and I tried to find such an option in the properties, with no luck. So I added the code below outside the auto-generated code:

    AuiToolBar1->SetToolBorderPadding(0);
    AuiToolBar1->Realize();


As mentioned, I think Code::Blocks is not using wxAuiToolbar, but wxToolbar? I could not find the SetToolBorderPadding(int padding) for wxToolbar, but there is something similar
   
    wxToolBar::SetToolSeparation(int separation);

In the documentation it says "The default value is 5.". Maybe this is a clue, although it does nothing for the vertical size.

EDIT: there is also
   wxToolBar::SetToolPacking(int packing);

PS. ok I see what you are saying about images, will consider

« Last Edit: March 13, 2017, 09:12:33 pm by cacb »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Can you try to modify C::B and test it with your theme? Then tell us if it makes a difference?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Can you try to modify C::B and test it with your theme? Then tell us if it makes a difference?

I can try, but I don't have a setup to build C::B other than running the build command as mentioned. Do you know where the wxToolbar objects are created (which source file)?  Then I can try to manipulate those things.

Maybe I could set up a virtual machine for building C::B with the IDE, if there is a good link on how to do that, please share.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Search the wiki for tutorials about building. For experiments you can use autotools. Just set the --prefix to something in your home folder.
This method Manager::CreateEmptyToolbar is probably the place to start the investigation.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Search the wiki for tutorials about building. For experiments you can use autotools. Just set the --prefix to something in your home folder.
This method Manager::CreateEmptyToolbar is probably the place to start the investigation.

I added
    toolbar->SetToolPacking(0);
    toolbar->SetToolSeparation(0);

in Manager::CreateEmptyToolbar and rebuilt C::B, but I could not observe any visual difference.

Then I tried
    toolbar->SetMargins(0,0);
This also did not make any difference that I could observe.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Then the next step is to replace wxToolbar with wxAuiToolbar in C::B or vice-versa in auidemo and see if this fixes/reproduces it.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
For this issue, I create a simple demo code to demonstrate.

Code

#include <wx/wx.h>
#include <wx/frame.h>
#include <wx/artprov.h>
#include <wx/aui/aui.h>

/*---------------------------------------------------------------------------------------------------------*/
// HEADER

enum
{
ID_ShowNormal = wxID_HIGHEST,
    ID_ShowBug,
    ID_ShowWorkaround,
};

class MyApp : public wxApp
{
public:
bool OnInit();
};

class MyFrame : public wxFrame
{
public:
MyFrame(wxFrame *parent,
wxWindowID id = wxID_ANY,
const wxString& title = _T("wxToolBar Bug Demo"),
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE|wxCLIP_CHILDREN|wxNO_FULL_REPAINT_ON_RESIZE);
virtual ~MyFrame();

wxToolBar *m_tb;
wxToolBar *m_tb2;
    wxToolBar *m_tb3;
wxAuiManager m_mngr;

DECLARE_EVENT_TABLE()
};

/*---------------------------------------------------------------------------------------------------------*/
// SOURCE

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit()
{
MyFrame* frame = new MyFrame((wxFrame *) NULL, wxID_ANY,
_T("wxToolbar Bug Demo"),
wxPoint(100, 100), wxSize(550, 300));

frame->Show(true);

wxInitAllImageHandlers();

SetTopWindow(frame);

return true;
}

BEGIN_EVENT_TABLE(MyFrame,wxFrame)
END_EVENT_TABLE()

MyFrame::MyFrame(wxFrame* parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style)
: wxFrame(parent, id, title, pos, size, style)
,m_tb(0), m_tb2(0),m_tb3(0)
{
m_mngr.SetManagedWindow(this);
wxMenu *menuFile=new wxMenu;
menuFile->Append(ID_ShowNormal,wxT("Show Normal"));
menuFile->Append(ID_ShowBug,wxT("Show Bug"));
menuFile->Append(ID_ShowWorkaround,wxT("Show Workaround"));
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(menuFile,wxT("Mode"));
SetMenuBar(menuBar);
//m_mngr.Update();



m_tb=new wxToolBar(this,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxTB_FLAT|wxTB_NODIVIDER);
//m_tb->AddTool(wxID_ANY,wxT("tool1"),wxArtProvider::GetBitmap(wxART_FILE_OPEN,wxART_TOOLBAR));
//m_tb->AddTool(wxID_ANY,wxT("tool2"),wxArtProvider::GetBitmap(wxART_FILE_SAVE,wxART_TOOLBAR));
    m_tb->AddTool(wxID_ANY,wxT("tool1"),wxBitmap(16,15));
m_tb->AddTool(wxID_ANY,wxT("tool2"),wxBitmap(16,15));

m_tb->Realize();
wxAuiPaneInfo pi = wxAuiPaneInfo() .Name(wxT("toolbar"))
.Caption(wxT("toolbar"))
.ToolbarPane()
.Floatable()
.Direction(wxAUI_DOCK_TOP) // see also ticket #9722
.LeftDockable(false)
.RightDockable(false);
m_mngr.AddPane(m_tb,pi);

    m_tb2=new wxToolBar(this,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxTB_FLAT|wxTB_NODIVIDER);
//m_tb2->AddTool(wxID_ANY,wxT("tool1"),wxArtProvider::GetBitmap(wxART_FILE_OPEN,wxART_TOOLBAR));
//m_tb2->AddTool(wxID_ANY,wxT("tool2"),wxArtProvider::GetBitmap(wxART_FILE_SAVE,wxART_TOOLBAR));
m_tb2->AddTool(wxID_ANY,wxT("tool1"),wxBitmap(16,15));
m_tb2->AddTool(wxID_ANY,wxT("tool2"),wxBitmap(16,15));
m_tb2->Realize();
wxAuiPaneInfo pi2 = wxAuiPaneInfo() .Name(wxT("toolbar2"))
.Caption(wxT("toolbar2"))
.ToolbarPane()
.Floatable()
.Direction(wxAUI_DOCK_TOP) // see also ticket #9722
.LeftDockable(false)
.RightDockable(false);
m_mngr.AddPane(m_tb2,pi2);


    m_tb3=new wxToolBar(this,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxTB_FLAT|wxTB_NODIVIDER);
//m_tb3->AddTool(wxID_ANY,wxT("tool1"),wxArtProvider::GetBitmap(wxART_FILE_OPEN,wxART_TOOLBAR));
//m_tb3->AddTool(wxID_ANY,wxT("tool2"),wxArtProvider::GetBitmap(wxART_FILE_SAVE,wxART_TOOLBAR));
m_tb3->AddTool(wxID_ANY,wxT("tool1"),wxBitmap(16,15));
m_tb3->AddTool(wxID_ANY,wxT("tool2"),wxBitmap(16,15));
wxChoice* choice = new wxChoice(m_tb3, wxID_ANY);
    choice->AppendString(wxT("One choice"));
    choice->AppendString(wxT("Another choice"));
    m_tb3->AddControl(choice);
m_tb3->Realize();
wxAuiPaneInfo pi3 = wxAuiPaneInfo() .Name(wxT("toolbar3"))
.Caption(wxT("toolbar3"))
.ToolbarPane()
.Floatable()
.Direction(wxAUI_DOCK_TOP) // see also ticket #9722
.LeftDockable(false)
.RightDockable(false);
m_mngr.AddPane(m_tb3,pi3);

m_mngr.Update();
}

MyFrame::~MyFrame()
{
m_mngr.UnInit();
}


When the toolbar button is small, such as "16*15", then you drag the toolbar to move horizontally, you see the screen shot as attachment.

If you use the standard toolbar size, such as the commented line, you don't have such issue.



If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.