mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-01 07:42:40 -06:00
ide: fixed indication of splitted file in stacking mode, small tabbar optimization, removed quicktabs
git-svn-id: svn://ultimatepp.org/upp/trunk@3070 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
8b9dddddac
commit
97d08446dc
6 changed files with 119 additions and 77 deletions
|
|
@ -374,6 +374,7 @@ void TabBar::CloseAll(int exception)
|
|||
tabs.Remove(i);
|
||||
|
||||
SetCursor(0);
|
||||
|
||||
if (exception >= 0)
|
||||
WhenCloseSome(vv);
|
||||
else
|
||||
|
|
@ -725,14 +726,40 @@ Value TabBar::AlignValue(int align, const Value &v, const Size &sz)
|
|||
return AlignImage(align, (Image)w);
|
||||
}
|
||||
|
||||
void TabBar::TabItem::Clear()
|
||||
{
|
||||
text.Clear();
|
||||
ink = Null;
|
||||
img = Null;
|
||||
side = LEFT;
|
||||
clickable = false;
|
||||
cross = false;
|
||||
stacked_tab = -1;
|
||||
}
|
||||
|
||||
TabBar::TabItem& TabBar::Tab::AddItem()
|
||||
{
|
||||
if(itn < items.GetCount())
|
||||
{
|
||||
TabItem& ti = items[itn++];
|
||||
ti.Clear();
|
||||
return ti;
|
||||
}
|
||||
else
|
||||
{
|
||||
++itn;
|
||||
return items.Add();
|
||||
}
|
||||
}
|
||||
|
||||
void TabBar::Tab::Clear()
|
||||
{
|
||||
items.Clear();
|
||||
itn = 0;
|
||||
}
|
||||
|
||||
TabBar::TabItem& TabBar::Tab::AddImage(const Image& img, int side)
|
||||
{
|
||||
TabItem& ti = items.Add();
|
||||
TabItem& ti = AddItem();
|
||||
ti.img = img;
|
||||
ti.size = img.GetSize();
|
||||
ti.side = side;
|
||||
|
|
@ -741,7 +768,7 @@ TabBar::TabItem& TabBar::Tab::AddImage(const Image& img, int side)
|
|||
|
||||
TabBar::TabItem& TabBar::Tab::AddValue(const Value& q, const Font& font, const Color& ink)
|
||||
{
|
||||
TabItem& ti = items.Add();
|
||||
TabItem& ti = AddItem();
|
||||
|
||||
ti.font = font;
|
||||
ti.ink = ink;
|
||||
|
|
@ -764,7 +791,7 @@ TabBar::TabItem& TabBar::Tab::AddValue(const Value& q, const Font& font, const C
|
|||
|
||||
TabBar::TabItem& TabBar::Tab::AddText(const WString& s, const Font& font, const Color& ink)
|
||||
{
|
||||
TabItem& ti = items.Add();
|
||||
TabItem& ti = AddItem();
|
||||
|
||||
ti.font = font;
|
||||
ti.ink = ink;
|
||||
|
|
@ -775,7 +802,7 @@ TabBar::TabItem& TabBar::Tab::AddText(const WString& s, const Font& font, const
|
|||
|
||||
TabBar::TabItem& TabBar::Tab::AddSpace(int space, int side)
|
||||
{
|
||||
TabItem& ti = items.Add();
|
||||
TabItem& ti = AddItem();
|
||||
|
||||
ti.size.cx = space;
|
||||
ti.size.cy = 0;
|
||||
|
|
@ -858,7 +885,7 @@ void TabBar::PaintTabItems(Tab& t, Draw &w, const Rect& rn, int align)
|
|||
int pos_left = TB_MARGIN;
|
||||
int pos_right = (IsVert() ? rn.GetHeight() : rn.GetWidth()) - TB_MARGIN;
|
||||
|
||||
for(int i = 0; i < t.items.GetCount(); i++)
|
||||
for(int i = 0; i < t.itn; i++)
|
||||
{
|
||||
const TabItem& ti = t.items[i];
|
||||
|
||||
|
|
@ -987,8 +1014,8 @@ void TabBar::PaintTab(Draw &w, const Size &sz, int n, bool enable, bool dragsamp
|
|||
t.Clear();
|
||||
|
||||
if(crosses && cnt > mintabcount && !dragsample) {
|
||||
TabItem& ti = t.items.Add();
|
||||
ti.img = s.crosses[(cross == n) ? 2 : ((ac || hl) ? 1 : 0)];
|
||||
TabItem& ti = t.AddItem();
|
||||
ti.img = s.crosses[cross == n ? 2 : ac || hl ? 1 : 0];
|
||||
ti.side = crosses_side;
|
||||
ti.cross = true;
|
||||
ti.size = s.crosses[0].GetSize();
|
||||
|
|
@ -1005,10 +1032,10 @@ void TabBar::PaintTab(Draw &w, const Size &sz, int n, bool enable, bool dragsamp
|
|||
int ndx = !enable ? CTRL_DISABLED :
|
||||
highlight == ix ? CTRL_HOT : CTRL_NORMAL;
|
||||
|
||||
int sn = t.items.GetCount();
|
||||
int sn = t.itn;
|
||||
ComposeStackedTab(t, q, s.font, s.text_color[ndx], ndx);
|
||||
if(t.items.GetCount() > sn)
|
||||
for(; sn < t.items.GetCount(); sn++)
|
||||
if(t.itn > sn)
|
||||
for(; sn < t.itn; sn++)
|
||||
t.items[sn].stacked_tab = ix;
|
||||
|
||||
ix++;
|
||||
|
|
@ -1293,7 +1320,7 @@ int TabBar::GetWidth() const
|
|||
ix--;
|
||||
while (ix >= 0 && tabs[ix].stack == stack)
|
||||
ix--;
|
||||
return tabs[ix+1].Right() + s.margin * 2;
|
||||
return tabs[ix + 1].Right() + s.margin * 2;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -2206,12 +2233,15 @@ bool TabBar::SetCursor0(int n, bool action)
|
|||
return false;
|
||||
|
||||
bool repos = false;
|
||||
|
||||
if (!IsStackHead(n))
|
||||
{
|
||||
n = SetStackHead(tabs[n]);
|
||||
repos = true;
|
||||
}
|
||||
|
||||
active = n;
|
||||
|
||||
if(!is_all && !same_group)
|
||||
{
|
||||
SetGroup(tabs[n].group);
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ public:
|
|||
int stacked_tab;
|
||||
|
||||
TabItem& Clickable(bool b = true) { clickable = b; return *this; }
|
||||
void Clear();
|
||||
|
||||
TabItem() : side(LEFT), clickable(false), cross(false), stacked_tab(-1) {}
|
||||
String ToString() const {
|
||||
|
|
@ -177,8 +178,9 @@ public:
|
|||
virtual void Serialize(Stream& s);
|
||||
|
||||
Vector<TabItem> items;
|
||||
int itn;
|
||||
|
||||
Tab() : id(-1), stack(-1), visible(true) { }
|
||||
Tab() : id(-1), stack(-1), visible(true), itn(0) { items.SetCount(5); }
|
||||
Tab(const Tab& t) { Set(t); }
|
||||
|
||||
void Set(const Tab& t);
|
||||
|
|
@ -188,6 +190,7 @@ public:
|
|||
bool HasIcon() const { return !img.IsEmpty(); }
|
||||
int Right() const { return pos.x + size.cx; }
|
||||
|
||||
TabItem& AddItem();
|
||||
void Clear();
|
||||
TabItem& AddValue(const Value& q, const Font& font = StdFont(), const Color& ink = SColorText);
|
||||
TabItem& AddText(const WString& s, const Font& font = StdFont(), const Color& ink = SColorText);
|
||||
|
|
@ -270,8 +273,7 @@ protected:
|
|||
TabKeySort keysorter_inst;
|
||||
TabValueSort stacksorter_inst;
|
||||
|
||||
private:
|
||||
void PaintTab(Draw& w, const Size& sz, int i, bool enable, bool dragsample = false);
|
||||
void PaintTab(Draw& w, const Size& sz, int i, bool enable, bool dragsample = false);
|
||||
|
||||
int TabPos(const String& g, bool& first, int i, int j, bool inactive);
|
||||
void ShowScrollbarFrame(bool b);
|
||||
|
|
@ -306,6 +308,7 @@ private:
|
|||
static int GetStyleHeight();
|
||||
static Image AlignImage(int align, const Image& img);
|
||||
static Value AlignValue(int align, const Value& v, const Size& isz);
|
||||
|
||||
protected:
|
||||
virtual void Paint(Draw& w);
|
||||
virtual void LeftDown(Point p, dword keysflags);
|
||||
|
|
|
|||
|
|
@ -40,20 +40,80 @@ void EditorTabBar::RenameFile(const String& fn, const String& nn)
|
|||
|
||||
void EditorTabBar::SetSplitColor(const String& fn, const Color& c)
|
||||
{
|
||||
int n = -1;
|
||||
|
||||
for(int i = 0; i < tabs.GetCount(); i++)
|
||||
{
|
||||
Tab& t = tabs[i];
|
||||
t.col = t.key == fn ? c : Null;
|
||||
tabs[i].col = Null;
|
||||
|
||||
if(n < 0 && tabs[i].key == fn)
|
||||
n = i;
|
||||
}
|
||||
|
||||
if(n >= 0)
|
||||
{
|
||||
if(stacking)
|
||||
n = FindStackHead(tabs[n].stack);
|
||||
tabs[n].col = c;
|
||||
}
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void EditorTabBar::ClearSplitColor()
|
||||
{
|
||||
for(int i = 0; i < tabs.GetCount(); i++)
|
||||
{
|
||||
Tab& t = tabs[i];
|
||||
t.col = Null;
|
||||
}
|
||||
tabs[i].col = Null;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void Ide::TabFile()
|
||||
{
|
||||
int q = tabs.GetCursor();
|
||||
if(q >= 0)
|
||||
EditFile(tabs.GetFile(q));
|
||||
}
|
||||
|
||||
void Ide::ClearTab()
|
||||
{
|
||||
int c = tabs.GetCursor();
|
||||
if(c >= 0)
|
||||
tabs.Close(c);
|
||||
}
|
||||
|
||||
void Ide::ClearTabs()
|
||||
{
|
||||
tabs.Clear();
|
||||
FileSelected();
|
||||
}
|
||||
|
||||
void Ide::CloseRest(EditorTabBar *tabs)
|
||||
{
|
||||
Index<String> fn;
|
||||
const Workspace& wspc = IdeWorkspace();
|
||||
for(int i = 0; i < wspc.GetCount(); i++)
|
||||
for(int j = 0; j < wspc.GetPackage(i).file.GetCount(); j++)
|
||||
fn.Add(SourcePath(wspc[i], wspc.GetPackage(i).file[j]));
|
||||
String cfn;
|
||||
if(tabs->GetCursor() >= 0)
|
||||
cfn = tabs->GetFile(tabs->GetCursor());
|
||||
for(int i = tabs->GetCount() - 1; i >= 0; i--)
|
||||
if(fn.Find(tabs->GetFile(i)) < 0)
|
||||
tabs->Close(i);
|
||||
tabs->FindSetFile(cfn);
|
||||
}
|
||||
|
||||
void Ide::TabsLR(int d)
|
||||
{
|
||||
int c = tabs.GetCursor();
|
||||
if(c < 0 || tabs.GetCount() <= 1)
|
||||
return;
|
||||
c = minmax(c + d, 0, tabs.GetCount() - 1);
|
||||
EditFile(tabs.GetFile(c));
|
||||
}
|
||||
|
||||
void Ide::FileSelected()
|
||||
{
|
||||
if(!IsNull(editfile))
|
||||
tabs.SetAddFile(editfile);
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
#include "ide.h"
|
||||
|
||||
void Ide::TabFile()
|
||||
{
|
||||
int q = tabs.GetCursor();
|
||||
if(q >= 0)
|
||||
EditFile(tabs.GetFile(q));
|
||||
}
|
||||
|
||||
void Ide::ClearTab()
|
||||
{
|
||||
int c = tabs.GetCursor();
|
||||
if(c >= 0)
|
||||
tabs.Close(c);
|
||||
}
|
||||
|
||||
void Ide::ClearTabs()
|
||||
{
|
||||
tabs.Clear();
|
||||
FileSelected();
|
||||
}
|
||||
|
||||
void Ide::CloseRest(EditorTabBar *tabs)
|
||||
{
|
||||
Index<String> fn;
|
||||
const Workspace& wspc = IdeWorkspace();
|
||||
for(int i = 0; i < wspc.GetCount(); i++)
|
||||
for(int j = 0; j < wspc.GetPackage(i).file.GetCount(); j++)
|
||||
fn.Add(SourcePath(wspc[i], wspc.GetPackage(i).file[j]));
|
||||
String cfn;
|
||||
if(tabs->GetCursor() >= 0)
|
||||
cfn = tabs->GetFile(tabs->GetCursor());
|
||||
for(int i = tabs->GetCount() - 1; i >= 0; i--)
|
||||
if(fn.Find(tabs->GetFile(i)) < 0)
|
||||
tabs->Close(i);
|
||||
tabs->FindSetFile(cfn);
|
||||
}
|
||||
|
||||
void Ide::TabsLR(int d)
|
||||
{
|
||||
int c = tabs.GetCursor();
|
||||
if(c < 0 || tabs.GetCount() <= 1)
|
||||
return;
|
||||
c = minmax(c + d, 0, tabs.GetCount() - 1);
|
||||
EditFile(tabs.GetFile(c));
|
||||
}
|
||||
|
||||
void Ide::FileSelected()
|
||||
{
|
||||
if(!IsNull(editfile))
|
||||
tabs.SetAddFile(editfile);
|
||||
}
|
||||
|
|
@ -37,7 +37,6 @@ file
|
|||
ide.cpp,
|
||||
idefile.cpp charset "iso8859-1",
|
||||
EditorTabBar.cpp,
|
||||
QuickTabs.cpp,
|
||||
Bottom.cpp,
|
||||
t.cpp,
|
||||
Cpp.cpp,
|
||||
|
|
|
|||
|
|
@ -423,6 +423,7 @@ void Ide::EditFile0(const String& path, byte charset, bool astext, const String&
|
|||
}
|
||||
|
||||
tabs.SetAddFile(editfile);
|
||||
tabs.SetSplitColor(editfile2, Yellow);
|
||||
editor.Enable();
|
||||
editpane.Add(editorsplit);
|
||||
editor.HiliteScope(hilite_scope);
|
||||
|
|
@ -692,8 +693,7 @@ void Ide::PassEditor()
|
|||
editor2.CheckEdited();
|
||||
editor.SetFocus();
|
||||
editor.ScrollIntoCursor();
|
||||
tabs.SetSplitColor(editfile, Yellow);
|
||||
;}
|
||||
}
|
||||
|
||||
void Ide::ClearEditedFile()
|
||||
{
|
||||
|
|
@ -725,8 +725,9 @@ void Ide::SplitEditor(bool horz)
|
|||
editorsplit.Horz(editor2, editor);
|
||||
else
|
||||
editorsplit.Vert(editor2, editor);
|
||||
PassEditor();
|
||||
|
||||
tabs.SetSplitColor(editfile, Yellow);
|
||||
PassEditor();
|
||||
}
|
||||
|
||||
void Ide::SwapEditors()
|
||||
|
|
@ -752,6 +753,7 @@ void Ide::CloseSplit()
|
|||
{
|
||||
editorsplit.Vert(editor, editor2);
|
||||
editorsplit.Zoom(0);
|
||||
editfile2.Clear();
|
||||
tabs.ClearSplitColor();
|
||||
SyncEditorSplit();
|
||||
editor.SetFocus();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue