Make HomeView widget more responsive depending on its current size

This commit is contained in:
David Capello 2015-04-04 18:18:52 -03:00
parent 9157e3dd89
commit e4667149f4
3 changed files with 26 additions and 10 deletions

View File

@ -2,7 +2,7 @@
<!-- Copyright (C) 2001-2015 by David Capello --> <!-- Copyright (C) 2001-2015 by David Capello -->
<gui> <gui>
<vbox noborders="true" id="home_view" border="4" childspacing="2" expansive="true"> <vbox noborders="true" id="home_view" border="4" childspacing="2" expansive="true">
<hbox noborders="true"> <hbox noborders="true" id="header_placeholder">
<image file="icons/ase48.png" align="center" /> <image file="icons/ase48.png" align="center" />
<vbox border="4" childspacing="4"> <vbox border="4" childspacing="4">
<link id="new_file" text="New File..." style="workspace_link" /> <link id="new_file" text="New File..." style="workspace_link" />
@ -13,17 +13,22 @@
<link id="check_update" text="" style="workspace_link" /> <link id="check_update" text="" style="workspace_link" />
</vbox> </vbox>
</hbox> </hbox>
<hbox noborders="true" expansive="true" homogeneous="true" childspacing="2"> <splitter horizontal="true" noborders="true" childspacing="2"
<vbox noborders="true" childspacing="2"> expansive="true" by="percetage" position="50" >
<label text="Recent files:" style="workspace_label" /> <splitter vertical="true" noborders="true" childspacing="2">
<view id="files_view" expansive="true" style="workspace_view" /> <vbox id="files_placeholder">
<label text="Recent folders:" style="workspace_label" /> <label text="Recent files:" style="workspace_label" />
<view id="folders_view" expansive="true" style="workspace_view" /> <view id="files_view" expansive="true" style="workspace_view" />
</vbox> </vbox>
<vbox noborders="true" childspacing="2"> <vbox id="folders_placeholder">
<label text="Recent folders:" style="workspace_label" />
<view id="folders_view" expansive="true" style="workspace_view" />
</vbox>
</splitter>
<vbox id="news_placeholder" noborders="true" childspacing="2">
<label text="News:" style="workspace_label" /> <label text="News:" style="workspace_label" />
<view id="news_view" expansive="true" style="workspace_view" /> <view id="news_view" expansive="true" style="workspace_view" />
</vbox> </vbox>
</hbox> </splitter>
</vbox> </vbox>
</gui> </gui>

View File

@ -23,6 +23,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/exception.h" #include "base/exception.h"
#include "ui/label.h" #include "ui/label.h"
#include "ui/resize_event.h"
#include "ui/system.h" #include "ui/system.h"
#include "ui/textbox.h" #include "ui/textbox.h"
#include "ui/view.h" #include "ui/view.h"
@ -107,6 +108,15 @@ void HomeView::onOpenFile()
UIContext::instance()->executeCommand(command); UIContext::instance()->executeCommand(command);
} }
void HomeView::onResize(ui::ResizeEvent& ev)
{
headerPlaceholder()->setVisible(ev.getBounds().h > 200*ui::guiscale());
foldersPlaceholder()->setVisible(ev.getBounds().h > 150*ui::guiscale());
newsPlaceholder()->setVisible(ev.getBounds().w > 200*ui::guiscale());
ui::VBox::onResize(ev);
}
void HomeView::onCheckingUpdates() void HomeView::onCheckingUpdates()
{ {
checkUpdate()->setText("Checking Updates..."); checkUpdate()->setText("Checking Updates...");

View File

@ -50,6 +50,7 @@ namespace app {
void onWorkspaceViewSelected() override; void onWorkspaceViewSelected() override;
protected: protected:
void onResize(ui::ResizeEvent& ev) override;
#ifdef ENABLE_UPDATER #ifdef ENABLE_UPDATER
// CheckUpdateDelegate impl // CheckUpdateDelegate impl
void onCheckingUpdates() override; void onCheckingUpdates() override;