Skip to content

Commit

Permalink
Updated navigation bar UI with 2 new drop down menus (still not funct…
Browse files Browse the repository at this point in the history
…ioning)
  • Loading branch information
eranif committed Nov 22, 2017
1 parent 5ee97c7 commit e483279
Show file tree
Hide file tree
Showing 12 changed files with 372 additions and 113 deletions.
44 changes: 23 additions & 21 deletions CodeLite/codelite_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ wxDEFINE_EVENT(wxEVT_WORKSPACE_CLOSING, wxCommandEvent);
wxDEFINE_EVENT(wxEVT_FILE_VIEW_INIT_DONE, wxCommandEvent);
wxDEFINE_EVENT(wxEVT_FILE_VIEW_REFRESHED, wxCommandEvent);
wxDEFINE_EVENT(wxEVT_FILE_EXP_INIT_DONE, wxCommandEvent);
wxDEFINE_EVENT(wxEVT_FILE_EXP_REFRESHED, wxCommandEvent);
wxDEFINE_EVENT(wxEVT_FILE_EXP_REFRESHED, wxCommandEvent);
wxDEFINE_EVENT(wxEVT_CMD_FILE_EXP_ITEM_EXPANDING, wxCommandEvent);
wxDEFINE_EVENT(wxEVT_TREE_ITEM_FILE_ACTIVATED, clCommandEvent);
wxDEFINE_EVENT(wxEVT_PROJ_FILE_ADDED, clCommandEvent);
Expand Down Expand Up @@ -99,28 +99,28 @@ wxDEFINE_EVENT(wxEVT_COLOUR_TAB, clColourEvent);
wxDEFINE_EVENT(wxEVT_WORKSPACE_VIEW_BUILD_STARTING, clCommandEvent);
wxDEFINE_EVENT(wxEVT_WORKSPACE_VIEW_CUSTOMIZE_PROJECT, clColourEvent);
wxDEFINE_EVENT(wxEVT_GET_TAB_BORDER_COLOUR, clColourEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_START, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_CONTINUE, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_STOP, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_STEP_IN, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_STEP_I, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_STEP_OUT, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_NEXT, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_NEXT_INST, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_INTERRUPT, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_SHOW_CURSOR, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_RESTART, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_IS_RUNNING, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_START, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_CONTINUE, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_STOP, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_STEP_IN, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_STEP_I, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_STEP_OUT, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_NEXT, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_NEXT_INST, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_INTERRUPT, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_SHOW_CURSOR, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_RESTART, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_IS_RUNNING, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_TOGGLE_BREAKPOINT, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_CAN_INTERACT, clDebugEvent );
wxDEFINE_EVENT(wxEVT_DBG_EXPR_TOOLTIP, clDebugEvent );
wxDEFINE_EVENT(wxEVT_DBG_CAN_INTERACT, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_EXPR_TOOLTIP, clDebugEvent);

wxDEFINE_EVENT(wxEVT_DBG_IS_PLUGIN_DEBUGGER, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_QUICK_DEBUG, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_CORE_FILE, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_ATTACH_TO_PROCESS, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_DELTE_ALL_BREAKPOINTS, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_ENABLE_ALL_BREAKPOINTS, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_QUICK_DEBUG, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_CORE_FILE, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_ATTACH_TO_PROCESS, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_DELTE_ALL_BREAKPOINTS, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_ENABLE_ALL_BREAKPOINTS, clDebugEvent);
wxDEFINE_EVENT(wxEVT_DBG_UI_DISABLE_ALL_BREAKPOINTS, clDebugEvent);
wxDEFINE_EVENT(wxEVT_CMD_OPEN_PROJ_SETTINGS, clCommandEvent);
wxDEFINE_EVENT(wxEVT_WORKSPACE_RELOAD_STARTED, clCommandEvent);
Expand All @@ -141,7 +141,7 @@ wxDEFINE_EVENT(wxEVT_CONTEXT_MENU_WORKSPACE, clContextMenuEvent);
wxDEFINE_EVENT(wxEVT_CONTEXT_MENU_TAB_LABEL, clContextMenuEvent);
wxDEFINE_EVENT(wxEVT_CMD_COLOURS_FONTS_UPDATED, clCommandEvent);
wxDEFINE_EVENT(wxEVT_FILE_LOADED, clCommandEvent);
wxDEFINE_EVENT(wxEVT_CL_FRAME_TITLE, clCommandEvent);
wxDEFINE_EVENT(wxEVT_CL_FRAME_TITLE, clCommandEvent);
wxDEFINE_EVENT(wxEVT_BEFORE_EDITOR_SAVE, clCommandEvent);
wxDEFINE_EVENT(wxEVT_EDITOR_MODIFIED, clCommandEvent);
wxDEFINE_EVENT(wxEVT_CLANG_CODE_COMPLETE_MESSAGE, clCommandEvent);
Expand All @@ -164,3 +164,5 @@ wxDEFINE_EVENT(wxEVT_WORKSPACE_BUILD_CONFIG_CHANGED, clCommandEvent);
wxDEFINE_EVENT(wxEVT_GOTO_ANYTHING_SELECTED, clGotoEvent);
wxDEFINE_EVENT(wxEVT_GOTO_ANYTHING_SHOWING, clGotoEvent);
wxDEFINE_EVENT(wxEVT_GOTO_ANYTHING_SORT_NEEDED, clGotoEvent);
wxDEFINE_EVENT(wxEVT_NAVBAR_SCOPE_MENU_SHOWING, clContextMenuEvent);
wxDEFINE_EVENT(wxEVT_NAVBAR_SCOPE_MENU_SELECTION_MADE, clCommandEvent);
7 changes: 7 additions & 0 deletions CodeLite/codelite_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -795,4 +795,11 @@ wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_GOTO_ANYTHING_SORT_NEEDED, clGoto
// Build configuration for the workspace has changed
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_WORKSPACE_BUILD_CONFIG_CHANGED, clCommandEvent);

// The navigation bar is about show the scope drop down menu
// Build the menu using clContextMenuEvent::GetMenu()
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_NAVBAR_SCOPE_MENU_SHOWING, clContextMenuEvent);

// User selected an entry from the scope drop down menu. GetString() contains the selected string
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_NAVBAR_SCOPE_MENU_SELECTION_MADE, clCommandEvent);

#endif // CODELITE_EVENTS_H
4 changes: 2 additions & 2 deletions LiteEditor.workspace
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
<Project Name="SampleWorksapce" ConfigName="Debug"/>
<Project Name="SmartCompletion" ConfigName="Win_x64_Debug"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="Win_x64_Release" Selected="yes">
<WorkspaceConfiguration Name="Win_x64_Release" Selected="no">
<Environment/>
<Project Name="AutoSave" ConfigName="Win_x64_Release"/>
<Project Name="CCTest" ConfigName="Debug"/>
Expand Down Expand Up @@ -430,7 +430,7 @@
<Project Name="wxsqlite3" ConfigName="Win_x64_Release"/>
<Project Name="SmartCompletion" ConfigName="Win_x64_Release"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="Win_x64_Debug" Selected="no">
<WorkspaceConfiguration Name="Win_x64_Debug" Selected="yes">
<Environment/>
<Project Name="AutoSave" ConfigName="Win_x64_Debug"/>
<Project Name="CCTest" ConfigName="Debug"/>
Expand Down
163 changes: 88 additions & 75 deletions Plugin/clEditorBar.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "ColoursAndFontsManager.h"
#include "IWorkspace.h"
#include "bitmap_loader.h"
#include "clEditorBar.h"
#include "clTabRenderer.h"
#include "clWorkspaceManager.h"
Expand All @@ -24,31 +25,44 @@

clEditorBar::clEditorBar(wxWindow* parent)
: clEditorBarBase(parent)
, m_scopeButtonState(eButtonState::kNormal)
, m_state(eButtonState::kNormal)
, m_bookmarksButtonState(eButtonState::kNormal)
{
wxBitmap bmp(1, 1);
wxMemoryDC memDC(bmp);
m_defaultColour = DrawingUtils::GetPanelTextColour();
m_functionColour = DrawingUtils::GetPanelTextColour();
m_classColour = DrawingUtils::GetPanelTextColour();
m_bgColour = DrawingUtils::GetPanelBgColour();
m_textFont = m_textFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
LexerConf::Ptr_t defaultLexer = ColoursAndFontsManager::Get().GetLexer("default");
if(defaultLexer) { m_textFont = defaultLexer->GetFontForSyle(0); }

EventNotifier::Get()->Bind(wxEVT_ACTIVE_EDITOR_CHANGED, &clEditorBar::OnEditorChanged, this);
EventNotifier::Get()->Bind(wxEVT_CMD_PAGE_CHANGED, &clEditorBar::OnEditorChanged, this);
EventNotifier::Get()->Bind(wxEVT_ALL_EDITORS_CLOSED, &clEditorBar::OnEditorChanged, this);
EventNotifier::Get()->Bind(wxEVT_CL_THEME_CHANGED, &clEditorBar::OnThemeChanged, this);
SetBackgroundStyle(wxBG_STYLE_PAINT);

memDC.SetFont(m_textFont);
wxSize sz = memDC.GetTextExtent("Tp");
sz.y += 2 * Y_SPACER; // 2*3 pixels
SetSizeHints(wxSize(-1, sz.y));

Bind(wxEVT_ENTER_WINDOW, &clEditorBar::OnEnterWindow, this);
Bind(wxEVT_LEAVE_WINDOW, &clEditorBar::OnLeaveWindow, this);
{
wxBitmap bmp(1, 1);
wxMemoryDC memDC(bmp);
m_defaultColour = DrawingUtils::GetPanelTextColour();
m_functionColour = DrawingUtils::GetPanelTextColour();
m_classColour = DrawingUtils::GetPanelTextColour();
m_bgColour = DrawingUtils::GetPanelBgColour();
m_textFont = m_textFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
LexerConf::Ptr_t defaultLexer = ColoursAndFontsManager::Get().GetLexer("default");
if(defaultLexer) { m_textFont = defaultLexer->GetFontForSyle(0); }

EventNotifier::Get()->Bind(wxEVT_ACTIVE_EDITOR_CHANGED, &clEditorBar::OnEditorChanged, this);
EventNotifier::Get()->Bind(wxEVT_CMD_PAGE_CHANGED, &clEditorBar::OnEditorChanged, this);
EventNotifier::Get()->Bind(wxEVT_ALL_EDITORS_CLOSED, &clEditorBar::OnEditorChanged, this);
EventNotifier::Get()->Bind(wxEVT_CL_THEME_CHANGED, &clEditorBar::OnThemeChanged, this);
SetBackgroundStyle(wxBG_STYLE_PAINT);

memDC.SetFont(m_textFont);
wxSize sz = memDC.GetTextExtent("Tp");
sz.y += (2 * Y_SPACER); // 2*3 pixels
SetSizeHints(wxSize(-1, sz.y));
}

{
m_bookmarksBmp = wxBitmap(16, 16);
wxMemoryDC memDC(m_bookmarksBmp);
wxColour c("rgb(255, 128, 64)");
memDC.SetPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW));
memDC.SetBrush(wxColour(c));
memDC.DrawRectangle(0, 0, 16, 16);
memDC.SelectObject(wxNullBitmap);
}

Bind(wxEVT_IDLE, &clEditorBar::OnIdle, this);
Bind(wxEVT_LEFT_UP, &clEditorBar::OnLeftUp, this);
}

Expand All @@ -58,8 +72,7 @@ clEditorBar::~clEditorBar()
EventNotifier::Get()->Unbind(wxEVT_CMD_PAGE_CHANGED, &clEditorBar::OnEditorChanged, this);
EventNotifier::Get()->Unbind(wxEVT_ALL_EDITORS_CLOSED, &clEditorBar::OnEditorChanged, this);
EventNotifier::Get()->Unbind(wxEVT_CL_THEME_CHANGED, &clEditorBar::OnThemeChanged, this);
Unbind(wxEVT_ENTER_WINDOW, &clEditorBar::OnEnterWindow, this);
Unbind(wxEVT_LEAVE_WINDOW, &clEditorBar::OnLeaveWindow, this);
Unbind(wxEVT_IDLE, &clEditorBar::OnIdle, this);
Unbind(wxEVT_LEFT_UP, &clEditorBar::OnLeftUp, this);
}

Expand All @@ -70,62 +83,54 @@ void clEditorBar::OnPaint(wxPaintEvent& e)
PrepareDC(bdc);
wxGCDC gcdc(bdc);
PrepareDC(gcdc);


wxFont guiFont = clTabRenderer::GetTabFont();
wxRect rect(GetClientRect());
gcdc.SetPen(m_bgColour);
gcdc.SetBrush(m_bgColour);
gcdc.DrawRectangle(rect);

// Draw the text
wxCoord textX = X_SPACER;
gcdc.SetFont(guiFont);

wxString fulltext;
if(!m_classname.IsEmpty()) { fulltext << m_classname << "::"; }
if(!m_function.IsEmpty()) { fulltext << m_function; }

gcdc.SetFont(m_textFont);
fulltext << "wwww"; // spacer
// wxSize fulltextSize = gcdc.GetTextExtent(fulltext);

// Draw the text
wxCoord textX = X_SPACER;
gcdc.SetFont(m_textFont);
wxSize textSize;
wxCoord textY = ((rect.GetHeight() - gcdc.GetTextExtent("Tp").GetHeight()) / 2);

const int filenameButtonWidth = 400 + (4 * X_SPACER);

if(!m_classname.IsEmpty()) {
textSize = gcdc.GetTextExtent(m_classname);
gcdc.SetTextForeground(m_classColour);
gcdc.DrawText(m_classname, textX, textY);
textX += textSize.x;

textSize = gcdc.GetTextExtent("::");
gcdc.SetTextForeground(m_defaultColour);
gcdc.DrawText("::", textX, textY);
textX += textSize.x;
}

if(!m_function.IsEmpty()) {
textSize = gcdc.GetTextExtent(m_function);
gcdc.SetTextForeground(m_functionColour);
gcdc.DrawText(m_function, textX, textY);
textX += textSize.x;
if(!fulltext.IsEmpty()) {
int scopeButtonWidth = gcdc.GetTextExtent("W" + fulltext + "W").GetWidth();
m_scopeRect = wxRect(textX, 0, scopeButtonWidth + 20, rect.GetHeight() - 2);
DrawingUtils::DrawButton(gcdc, this, m_scopeRect, fulltext, wxNullBitmap, eButtonKind::kDropDown,
m_scopeButtonState);
textX += m_scopeRect.GetWidth();
}


textX += X_SPACER;
if(!m_breadcrumbs.IsEmpty()) {
wxString breadcumbsText;
for(size_t i = 0; i < m_breadcrumbs.size(); ++i) {
breadcumbsText << m_breadcrumbs.Item(i) << " / ";
}

breadcumbsText.RemoveLast(3);
wxFont guiFont = clTabRenderer::GetTabFont();
gcdc.SetFont(guiFont);
int filenameButtonWidth = gcdc.GetTextExtent("W" + breadcumbsText + "W").GetWidth();

// Geometry
m_filenameRect = wxRect(GetClientRect().GetWidth() - filenameButtonWidth - X_SPACER, 0, filenameButtonWidth,
rect.GetHeight() - 2);
m_filenameRect = wxRect(textX, 0, filenameButtonWidth, rect.GetHeight() - 2);
DrawingUtils::DrawButton(gcdc, this, m_filenameRect, breadcumbsText, wxNullBitmap, eButtonKind::kDropDown,
m_state);
textX += filenameButtonWidth;
textX += (2 * X_SPACER);
textX += X_SPACER;

wxString bookmarksLabel = _("Bookmarks");
wxSize bookmarksTextSize = gcdc.GetTextExtent(bookmarksLabel);

// Add 60 (about 40 for the image and 20 needed for the drop down button
m_bookmarksRect = wxRect(textX, 0, bookmarksTextSize.GetWidth() + 60, rect.GetHeight() - 2);
DrawingUtils::DrawButton(gcdc, this, m_bookmarksRect, bookmarksLabel, m_bookmarksBmp, eButtonKind::kDropDown,
m_bookmarksButtonState);
}
}

Expand Down Expand Up @@ -207,8 +212,11 @@ void clEditorBar::OnEditorSize(wxSizeEvent& event)
DoRefreshColoursAndFonts();
}

void clEditorBar::OnLeftDown(wxMouseEvent& e)
void clEditorBar::OnLeftDown(wxMouseEvent& e) { e.Skip(); }

void clEditorBar::OnLeftUp(wxMouseEvent& e)
{
e.Skip();
if(m_filenameRect.Contains(e.GetPosition())) {
wxMenu menu;
wxString text;
Expand Down Expand Up @@ -263,23 +271,28 @@ void clEditorBar::OnLeftDown(wxMouseEvent& e)
::CopyToClipboard(text);
clGetManager()->SetStatusMessage((wxString() << "'" << text << _("' copied!")), 2);
}
} else if(m_bookmarksRect.Contains(e.GetPosition())) {
// TODO: show bookmarks menu here
} else if(m_scopeRect.Contains(e.GetPosition())) {
// TODO: show scope menu here
}
}

void clEditorBar::OnLeftUp(wxMouseEvent& e)
{
m_state = eButtonState::kNormal;
Refresh();
}
void clEditorBar::DoRefresh() { Refresh(); }

void clEditorBar::OnEnterWindow(wxMouseEvent& e)
void clEditorBar::OnIdle(wxIdleEvent& e)
{
m_state = eButtonState::kHover;
Refresh();
}

void clEditorBar::OnLeaveWindow(wxMouseEvent& e)
{
m_state = eButtonState::kNormal;
Refresh();
e.Skip();
wxPoint pos = ScreenToClient(::wxGetMousePosition());
if(GetClientRect().Contains(pos)) {
m_state = m_bookmarksButtonState = m_scopeButtonState = eButtonState::kNormal;
if(m_filenameRect.Contains(pos)) {
m_state = eButtonState::kHover;
} else if(m_bookmarksRect.Contains(pos)) {
m_bookmarksButtonState = eButtonState::kHover;
} else if(m_scopeRect.Contains(pos)) {
m_scopeButtonState = eButtonState::kHover;
}
CallAfter(&clEditorBar::DoRefresh);
}
}
18 changes: 13 additions & 5 deletions Plugin/clEditorBar.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef CLEDITORBAR_H
#define CLEDITORBAR_H
#include "drawingutils.h"

#include "wxcrafter_plugin.h"
#include "drawingutils.h"
#include <wx/colour.h>
#include <wx/font.h>

Expand All @@ -14,7 +15,9 @@ class WXDLLIMPEXP_SDK clEditorBar : public clEditorBarBase
wxColour m_defaultColour;
wxColour m_bgColour;
wxFont m_textFont;

wxRect m_scopeRect;
eButtonState m_scopeButtonState;

// Breadcrumbs
wxString m_filename;
wxString m_filenameRelative;
Expand All @@ -25,15 +28,21 @@ class WXDLLIMPEXP_SDK clEditorBar : public clEditorBarBase
wxRect m_filenameRect;
eButtonState m_state;

// Bookmarks button
wxBitmap m_bookmarksBmp;
wxRect m_bookmarksRect;
eButtonState m_bookmarksButtonState;

private:
void DoRefreshColoursAndFonts();
void DoRefresh();

public:
clEditorBar(wxWindow* parent);
virtual ~clEditorBar();
void SetMessage(const wxString& className, const wxString& function);
void DoShow(bool s);

protected:
virtual void OnEditorSize(wxSizeEvent& e);
virtual void OnEraseBG(wxEraseEvent& e);
Expand All @@ -42,7 +51,6 @@ class WXDLLIMPEXP_SDK clEditorBar : public clEditorBarBase
void OnLeftDown(wxMouseEvent& e);
void OnLeftUp(wxMouseEvent& e);
void OnThemeChanged(wxCommandEvent& e);
void OnEnterWindow(wxMouseEvent& e);
void OnLeaveWindow(wxMouseEvent& e);
void OnIdle(wxIdleEvent& e);
};
#endif // CLEDITORBAR_H
Loading

0 comments on commit e483279

Please sign in to comment.