Skip to content
Snippets Groups Projects
Commit 3588605c authored by stefan's avatar stefan
Browse files

New SequenceViewer, changed colors of selection and background

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2188 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 96882628
Branches
Tags
No related merge requests found
......@@ -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
......
//------------------------------------------------------------------------------
// 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();
}
}}
//------------------------------------------------------------------------------
// 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
......@@ -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();
}
......
......@@ -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_;
};
}}
......
......@@ -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{
......
......@@ -81,6 +81,7 @@ private:
QList<ViewObject*> objects_;
int max_columns;
PainterList empty_list_;
};
......
......@@ -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
{
......
......@@ -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;}");
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment