diff --git a/modules/gui/src/CMakeLists.txt b/modules/gui/src/CMakeLists.txt index 41e0c9901e394f20ee79c2c76266bf9577920ccd..da9df49e3eb9f6886b5a0eea4bd10e5fa813c213 100644 --- a/modules/gui/src/CMakeLists.txt +++ b/modules/gui/src/CMakeLists.txt @@ -22,6 +22,7 @@ sequence_search_bar.hh set(OST_GUI_SEQUENCE_VIEW_HEADERS base_row.hh +background_painter.hh painter.hh secstr_row.hh seq_secstr_painter.hh @@ -211,6 +212,7 @@ sequence_viewer/sequence_viewer.cc sequence_viewer/sequence_scene.cc sequence_viewer/sequence_search_bar.cc sequence/base_row.cc +sequence/background_painter.cc sequence/secstr_row.cc sequence/seq_secstr_painter.cc sequence/seq_selection_painter.cc @@ -339,6 +341,7 @@ sequence_viewer/sequence_viewer_base.hh sequence_viewer/sequence_viewer.hh sequence_viewer/sequence_scene.hh sequence_viewer/sequence_search_bar.hh +sequence/background_painter.hh sequence/base_row.hh sequence/painter.hh sequence/secstr_row.hh diff --git a/modules/gui/src/sequence/background_painter.cc b/modules/gui/src/sequence/background_painter.cc new file mode 100644 index 0000000000000000000000000000000000000000..adc5e6a7374ae8b2dbfca069a4721cce291e74dd --- /dev/null +++ b/modules/gui/src/sequence/background_painter.cc @@ -0,0 +1,48 @@ +//------------------------------------------------------------------------------ +// This file is part of the OpenStructure project <www.openstructure.org> +// +// Copyright (C) 2008-2010 by the OpenStructure authors +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License as published by the Free +// Software Foundation; either version 3.0 of the License, or (at your option) +// any later version. +// This library is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +// details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this library; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +//------------------------------------------------------------------------------ + +/* + Author: Stefan Scheuber + */ + + +#include <QtGui> + +#include "background_painter.hh" + +namespace ost { namespace gui { + +BackgroundPainter::BackgroundPainter(QObject* parent) + : Painter(parent) +{} + +void BackgroundPainter::Paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index){ + painter->save(); + if ((index.column()-1)%10 > 4){ + painter->fillRect(option.rect, QColor(240,240,240)); + + } + if(index.row()>0 && (index.column())%10 == 0){ + painter->setPen(QPen(QColor(135,135,135))); + painter->drawLine(option.rect.topRight(),option.rect.bottomRight()); + } + painter->restore(); +} + +}} diff --git a/modules/gui/src/sequence/background_painter.hh b/modules/gui/src/sequence/background_painter.hh new file mode 100644 index 0000000000000000000000000000000000000000..942e1dde5bd9b67326862eaf605de1436c962ab7 --- /dev/null +++ b/modules/gui/src/sequence/background_painter.hh @@ -0,0 +1,43 @@ +//------------------------------------------------------------------------------ +// This file is part of the OpenStructure project <www.openstructure.org> +// +// Copyright (C) 2008-2010 by the OpenStructure authors +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License as published by the Free +// Software Foundation; either version 3.0 of the License, or (at your option) +// any later version. +// This library is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +// details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this library; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +//------------------------------------------------------------------------------ +#ifndef OST_SEQUENCE_VIEWER_BACKGROUND_PAINTER +#define OST_SEQUENCE_VIEWER_BACKGROUND_PAINTER + +/* + Author: Stefan Scheuber + */ + +#include <QObject> + +#include "painter.hh" + +namespace ost { namespace gui { + +class BackgroundPainter : public Painter +{ + Q_OBJECT +public: + BackgroundPainter(QObject* parent = 0); + void Paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index); +}; + +}} + +#endif diff --git a/modules/gui/src/sequence/seq_selection_painter.cc b/modules/gui/src/sequence/seq_selection_painter.cc index e9b0c4d5c8723a51c9277a03946c9d5d0968796a..8473171967a9f398e8e9a9883197ab54ff605146 100644 --- a/modules/gui/src/sequence/seq_selection_painter.cc +++ b/modules/gui/src/sequence/seq_selection_painter.cc @@ -29,27 +29,25 @@ namespace ost { namespace gui { SeqSelectionPainter::SeqSelectionPainter(QObject* parent) - : Painter(parent) -{} + : Painter(parent), focus_color_(255,0,0,0), mouse_over_color_(240,240,240,192) +{ + +} void SeqSelectionPainter::Paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index){ painter->save(); - if ((index.column()-1)%10 > 4){ - painter->fillRect(option.rect, QColor(240,240,240)); - - } - if((index.column())%10 == 0){ - painter->setPen(QPen(QColor(135,135,135))); - painter->drawLine(option.rect.topRight(),option.rect.bottomRight()); - } + /* if (option.state & QStyle::State_HasFocus){ - painter->fillRect(option.rect, QColor(240,240,0,60)); + painter->fillRect(option.rect, focus_color_); } + */ if (option.state & QStyle::State_MouseOver){ - painter->fillRect(option.rect, QColor(240,240,240,128)); + painter->fillRect(option.rect, mouse_over_color_); } if (option.state & QStyle::State_Selected){ - painter->fillRect(option.rect, QColor(0,240,0,128)); + QColor color = option.palette.highlight().color(); + color.setAlpha(128); + painter->fillRect(option.rect, color); } painter->restore(); } diff --git a/modules/gui/src/sequence/seq_selection_painter.hh b/modules/gui/src/sequence/seq_selection_painter.hh index 416f423c0fc1f187b81cb24f6297821d2fefd7df..a98d5afb6bf0cab9e33e7283ec5e6b80af423aa3 100644 --- a/modules/gui/src/sequence/seq_selection_painter.hh +++ b/modules/gui/src/sequence/seq_selection_painter.hh @@ -36,6 +36,9 @@ public: SeqSelectionPainter(QObject* parent = 0); void Paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index); +private: + QColor focus_color_; + QColor mouse_over_color_; }; }} diff --git a/modules/gui/src/sequence/sequence_model.cc b/modules/gui/src/sequence/sequence_model.cc index 428952657b2f0bb3e14277fdd2a5dbc4c2cf104c..ddac0e2a8db67446cb5bb75f32d699cf7a8c2c96 100644 --- a/modules/gui/src/sequence/sequence_model.cc +++ b/modules/gui/src/sequence/sequence_model.cc @@ -119,7 +119,7 @@ const PainterList& SequenceModel::GetPainters(const QModelIndex& index) const{ pair.second->GetRow(pair.first); return pair.second->GetRow(pair.first)->GetPainters(); } - assert(false); + return empty_list_; } QPair<int, ViewObject*> SequenceModel::GetRowWithItem(int row) const{ diff --git a/modules/gui/src/sequence/sequence_model.hh b/modules/gui/src/sequence/sequence_model.hh index 50618db9c0a8bc6054dc5ac3ff3d015b5b011c1b..1c8b27f6fca5cf94f9eefff0bd938025870b2180 100644 --- a/modules/gui/src/sequence/sequence_model.hh +++ b/modules/gui/src/sequence/sequence_model.hh @@ -81,6 +81,7 @@ private: QList<ViewObject*> objects_; int max_columns; + PainterList empty_list_; }; diff --git a/modules/gui/src/sequence/sequence_row.cc b/modules/gui/src/sequence/sequence_row.cc index b9f758053613d533897cf9f4b19092536259761f..2c33712ace2197cfe00160d78d120e4cf682b1f0 100644 --- a/modules/gui/src/sequence/sequence_row.cc +++ b/modules/gui/src/sequence/sequence_row.cc @@ -35,10 +35,16 @@ namespace ost { namespace gui { SequenceRow::SequenceRow(const QString& name, seq::SequenceHandle& sequence, ViewObject* parent) : BaseRow(QFont("Courier",11),parent), name_(name), name_font_(QFont("Courier",11)), sequence_(sequence) -{ } +{ + name_font_.setBold(true); + name_font_.setItalic(true); +} -SequenceRow::SequenceRow(const QString& name, ViewObject* parent) : BaseRow(QFont("Courier",11),parent), name_(name) -{ } +SequenceRow::SequenceRow(const QString& name, ViewObject* parent) : BaseRow(QFont("Courier",11),parent), name_(name), name_font_(QFont("Courier",11)) +{ + name_font_.setBold(true); + name_font_.setItalic(true); +} int SequenceRow::GetColumnCount() const { diff --git a/modules/gui/src/sequence/sequence_table_view.cc b/modules/gui/src/sequence/sequence_table_view.cc index 2152c1a6bb6b129e27b579d54ffc0560b036ee5f..73769705dde169a4c7b7f56707ef08e73f072ee6 100644 --- a/modules/gui/src/sequence/sequence_table_view.cc +++ b/modules/gui/src/sequence/sequence_table_view.cc @@ -95,7 +95,6 @@ void SequenceTableView::InitStaticColumn() static_column_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); static_column_->show(); static_column_->setStyleSheet("QTableView { border: 0px;" - "background-color: #F6F6F6;" "selection-background-color: #EEEEEE}" "QTableView::item{ border: none;" "padding: 0px; border-width: 0px; margin: 0px;}"); @@ -130,7 +129,7 @@ void SequenceTableView::InitStaticRow() static_row_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); static_row_->show(); static_row_->setStyleSheet("QTableView { border: 0px;" - "background-color: #F6F6F6;" + "background-color: #FFFFFF;" "selection-background-color: #EEEEEE}" "QTableView::item{ border: none;" "padding: 0px; border-width: 0px; margin: 0px;}"); @@ -169,7 +168,7 @@ void SequenceTableView::InitStaticField(){ static_field_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); static_field_->show(); static_field_->setStyleSheet("QTableView { border: 0px;" - "background-color: #E0E0E0;" + "background-color: #FFFFFF;" "selection-background-color: #EEEEEE}" "QTableView::item{ border: none;" "padding: 0px; border-width: 0px; margin: 0px;}"); diff --git a/modules/gui/src/sequence/view_object.cc b/modules/gui/src/sequence/view_object.cc index e422027e7105fa95277e89be52ce5f70aa110ddd..01d80818a08b725cdd655dec051f1b9f5b204aff 100644 --- a/modules/gui/src/sequence/view_object.cc +++ b/modules/gui/src/sequence/view_object.cc @@ -32,6 +32,7 @@ #include "title_row.hh" #include "painter.hh" +#include "background_painter.hh" #include "seq_secstr_painter.hh" #include "seq_selection_painter.hh" #include "seq_text_painter.hh" @@ -78,7 +79,9 @@ ViewObject::ViewObject(gfx::EntityP& entity, QObject* parent): QObject(parent), ViewObject::ViewObject(QObject* parent): QObject(parent) { TitleRow* new_row = new TitleRow(this); - Painter* p = new TickPainter(this); + Painter* p = new BackgroundPainter(this); + new_row->InsertPainter(p); + p = new TickPainter(this); new_row->InsertPainter(p); rows_.append(new_row); } @@ -111,7 +114,9 @@ int ViewObject::GetRowCount() void ViewObject::AddSequence(seq::SequenceHandle& sequence, const QString& name) { SequenceRow* new_row = new SequenceRow(name, sequence, this); - Painter* p = new SeqSelectionPainter(this); + Painter* p = new BackgroundPainter(this); + new_row->InsertPainter(p); + p = new SeqSelectionPainter(this); new_row->InsertPainter(p); p = new SeqTextPainter(this); new_row->InsertPainter(p); @@ -121,12 +126,14 @@ void ViewObject::AddSequence(seq::SequenceHandle& sequence, const QString& name) void ViewObject::AddChain(mol::ChainView& chain, const QString& name) { SecStrRow* new_row = new SecStrRow(name, chain, this); - Painter* p = new SeqSelectionPainter(this); + Painter* p = new BackgroundPainter(this); new_row->InsertPainter(p); p = new SeqSecStrPainter(this); new_row->InsertPainter(p); p = new SeqTextPainter(this); new_row->InsertPainter(p); + p = new SeqSelectionPainter(this); + new_row->InsertPainter(p); rows_.append(new_row); }