linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #04379
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2585: Fix hiding splitter window parts
------------------------------------------------------------
revno: 2585
committer: Jacek Sieka <arnetheduck@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Fri 2011-08-05 22:59:14 +0200
message:
Fix hiding splitter window parts
modified:
dwt/include/dwt/aspects/AspectContainer.h
dwt/include/dwt/widgets/SplitterContainer.h
dwt/src/widgets/SplitterContainer.cpp
win32/HubFrame.cpp
win32/MainWindow.cpp
win32/QueueFrame.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dwt/include/dwt/aspects/AspectContainer.h'
--- dwt/include/dwt/aspects/AspectContainer.h 2011-01-29 14:15:43 +0000
+++ dwt/include/dwt/aspects/AspectContainer.h 2011-08-05 20:59:14 +0000
@@ -88,6 +88,10 @@
std::pair<ChildIterator<T>, ChildIterator<T> > getChildren() {
return std::make_pair(ChildIterator<T>::first(&W()), ChildIterator<T>());
}
+
+ void removeChild(Widget *w) {
+ ::DestroyWindow(w->handle());
+ }
};
}
=== modified file 'dwt/include/dwt/widgets/SplitterContainer.h'
--- dwt/include/dwt/widgets/SplitterContainer.h 2011-05-28 15:31:50 +0000
+++ dwt/include/dwt/widgets/SplitterContainer.h 2011-08-05 20:59:14 +0000
@@ -65,10 +65,12 @@
void setSplitter(size_t n, double relativePos);
double getSplitterPos(size_t n);
+ void maximize(Widget *w);
+
virtual void layout();
private:
- explicit SplitterContainer( Widget * parent ) : BaseType(parent), horizontal(false), startPos(0.5) { }
+ explicit SplitterContainer( Widget * parent ) : BaseType(parent), maximized(0), horizontal(false), startPos(0.5) { }
size_t ensureSplitters();
@@ -76,6 +78,7 @@
void onMove();
+ Widget *maximized;
bool horizontal;
double startPos;
};
=== modified file 'dwt/src/widgets/SplitterContainer.cpp'
--- dwt/src/widgets/SplitterContainer.cpp 2011-05-28 15:31:50 +0000
+++ dwt/src/widgets/SplitterContainer.cpp 2011-08-05 20:59:14 +0000
@@ -36,6 +36,7 @@
#include <boost/next_prior.hpp>
#include <boost/range/distance.hpp>
+#include <boost/range/adaptor/filtered.hpp>
#include <boost/range/algorithm/find.hpp>
#include <boost/range/algorithm/for_each.hpp>
@@ -49,6 +50,7 @@
using boost::find;
using boost::for_each;
using boost::next;
+using boost::adaptors::filtered;
SplitterContainer::Seed::Seed(double startPos, bool horizontal) :
BaseType::Seed(0, WS_EX_CONTROLPARENT),
@@ -89,46 +91,57 @@
auto children = getChildren<Widget>();
auto splitters = getChildren<Splitter>();
- auto size = getClientSize();
-
- auto avail = horizontal ? size.y : size.x;
+ auto rc = Rectangle(getClientSize());
+ util::HoldResize hr(this, boost::distance(children));
+
+ if(maximized) {
+ for_each(children, [&](Widget *w) {
+ if(w == maximized) {
+ hr.resize(w, rc);
+ } else {
+ hr.resize(w, Rectangle());
+ }
+ });
+
+ return;
+ }
+
+ auto &pos = horizontal ? rc.pos.y : rc.pos.x;
+ auto &size = horizontal ? rc.size.y : rc.size.x;
+
+ auto avail = size;
for_each(splitters, [&](Splitter *w) {
avail -= horizontal ? w->getPreferredSize().y : w->getPreferredSize().x;
});
- auto rc = Rectangle(getClientSize());
- auto &sz = horizontal ? rc.size.y : rc.size.x;
- auto &p = horizontal ? rc.pos.y : rc.pos.x;
-
- sz = 0;
-
auto splitter_iter = splitters.first;
- util::HoldResize hr(this, boost::distance(children));
- for_each(children, [&](Widget *w) {
- if(isSplitter(w)) {
- return;
- }
-
- if(splitter_iter == splitters.second) {
- // Last splitter, the next control gets any remaining space
- sz = std::max(avail - p, 0l);
+ auto nc = boost::distance(children | filtered(&isNotSplitter));
+ auto i = 0;
+ for_each(children | filtered(&isNotSplitter), [&](Widget *w) {
+ if(i++ == nc-1) {
+ // Last child - give it any remaining space
+ size = std::max(avail - pos, 0l);
hr.resize(w, rc);
} else {
auto splitter = *splitter_iter;
auto ss = horizontal ? splitter->getPreferredSize().y : splitter->getPreferredSize().x;
- sz = std::max(avail * splitter->getRelativePos() - ss / 2. - p, 0.);
+ size = std::max(avail * splitter->getRelativePos() - ss / 2. - pos, 0.);
hr.resize(w, rc);
- p += sz;
+ pos += size;
- sz = ss;
+ size = ss;
hr.resize(splitter, rc);
- p += sz;
+ pos += size;
splitter_iter++;
}
});
+
+ for(auto s = splitter_iter; s != splitters.second; ++s) {
+ hr.resize(*s, Rectangle());
+ }
}
size_t SplitterContainer::ensureSplitters() {
@@ -170,4 +183,11 @@
redraw(true);
}
+void SplitterContainer::maximize(Widget* w) {
+ if(w != maximized) {
+ maximized = w;
+ layout();
+ }
+}
+
}
=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp 2011-07-27 16:21:48 +0000
+++ win32/HubFrame.cpp 2011-08-05 20:59:14 +0000
@@ -292,15 +292,8 @@
r.size.y -= rm.size.y + border;
- /* TODO
- bool checked = showUsers->getChecked();
- if(checked && !paned->getSecond()) {
- paned->setSecond(userGrid);
- } else if(!checked && paned->getSecond()) {
- paned->setSecond(0);
- }
- */
hr.resize(paned, r);
+ paned->maximize(showUsers->getChecked() ? NULL : message);
}
void HubFrame::updateStatus() {
=== modified file 'win32/MainWindow.cpp'
--- win32/MainWindow.cpp 2011-06-27 16:02:40 +0000
+++ win32/MainWindow.cpp 2011-08-05 20:59:14 +0000
@@ -1394,22 +1394,19 @@
}
void MainWindow::switchTransfers() {
- /* TODO
if(transfers) {
transfers->prepareClose();
- ::DestroyWindow(transfers->handle());
+ paned->removeChild(transfers);
transfers = 0;
- paned->setSecond(transfers);
SettingsManager::getInstance()->set(SettingsManager::SHOW_TRANSFERVIEW, false);
viewMenu->checkItem(viewIndexes["Transfers"], false);
-
} else {
SettingsManager::getInstance()->set(SettingsManager::SHOW_TRANSFERVIEW, true);
initTransfers();
}
-*/
- layout();
+
+ paned->layout();
}
void MainWindow::switchStatus() {
=== modified file 'win32/QueueFrame.cpp'
--- win32/QueueFrame.cpp 2011-07-30 08:58:17 +0000
+++ win32/QueueFrame.cpp 2011-08-05 20:59:14 +0000
@@ -96,6 +96,10 @@
files->onKeyDown([this](int c) { return handleKeyDownFiles(c); });
files->onSelectionChanged([this] { GCC_WTF->callAsync([&] { updateStatus(); }); });
files->onContextMenu([this](const dwt::ScreenCoordinate &sc) { return handleFilesContextMenu(sc); });
+
+ if(!BOOLSETTING(QUEUEFRAME_SHOW_TREE)) {
+ paned->maximize(files);
+ }
}
initStatus();
@@ -260,19 +264,7 @@
}
void QueueFrame::handleShowTreeClicked() {
- bool checked = showTree->getChecked();
-
- /* TODO
- if(checked && !paned->getFirst()) {
- paned->setFirst(dirs);
- } else if(!checked && paned->getFirst()) {
- paned->setFirst(0);
- }
-
- dirs->setVisible(checked);
- paned->setVisible(checked);
-*/
- layout();
+ paned->maximize(showTree->getChecked() ? NULL : files);
}
void QueueFrame::updateFiles() {
@@ -308,7 +300,7 @@
display->columns[COLUMN_TARGET] = Text::toT(Util::getFileName(getTarget()));
}
int online = 0;
- if(colMask & MASK_USERS || colMask & MASK_STATUS) {
+ if(colMask & (MASK_USERS | MASK_STATUS)) {
tstring tmp;
for(QueueItem::SourceIter j = getSources().begin(); j != getSources().end(); ++j) {