added image separators in ribbons + some refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-12-19 19:34:38 +03:00
parent c885ee0bcf
commit 828e13d9d1
4 changed files with 97 additions and 34 deletions

View File

@ -791,6 +791,25 @@ stretching in width... */
} }
/* image separators... */
.ribbon-image-separators.viewer .image {
box-shadow:
9px 4px 0 -8px rgba(128,128,128,0.2),
-9px 4px 0 -8px rgba(128,128,128,0.2);
}
.ribbon-image-separators.viewer .image[orientation="90"],
.ribbon-image-separators.viewer .image[orientation="270"] {
box-shadow:
4px 9px 0 -8px rgba(128,128,128,0.2),
4px -9px 0 -8px rgba(128,128,128,0.2);
}
.ribbon-image-separators.single-image-mode.viewer .image {
box-shadow: none;
}
/* default backgrounds */ /* default backgrounds */
/* XXX not sure if we need these... /* XXX not sure if we need these...
.image { .image {

View File

@ -175,7 +175,7 @@ var CurrentImageIndicatorActions = actions.Actions({
var cur = this.ribbons.getImage(target) var cur = this.ribbons.getImage(target)
// NOTE: cur may be unloaded... // NOTE: cur may be unloaded...
var ribbon = this.ribbons.getRibbon(cur.length > 0 ? target : this.currentRibbon) var ribbon = this.ribbons.getRibbon(cur.length > 0 ? target : this.current_ribbon)
var marker = ribbon.find('.current-marker') var marker = ribbon.find('.current-marker')
@ -310,12 +310,20 @@ module.CurrentImageIndicator = core.ImageGridFeatures.Feature({
function(target, s){ function(target, s){
var m = this.ribbons.viewer.find('.current-marker') var m = this.ribbons.viewer.find('.current-marker')
var c = this.current var c = this.current
var r = this.currentRibbon var r = this.current_ribbon
// only update if marker exists and we are in current ribbon... // only update if marker exists and we are in current ribbon...
if(m.length != 0 if(m.length != 0
&& (target == c // XXX not sure if target handling here is the
// right way to go -- we manually check things
// when .data.getImage(..) nad friends to this
// better and in one spot...
// ...the down side is that they are slower...
&& (target == 'current'
|| target == c
|| target == r || target == r
// XXX this seems to be slow enough to push
// the frame-rate down...
|| this.data.getRibbon(target) == r || this.data.getRibbon(target) == r
|| target == null)){ || target == null)){
m.hide() m.hide()

View File

@ -176,6 +176,8 @@ module.ViewerActions = actions.Actions({
'transparent-ribbon', 'transparent-ribbon',
], ],
'ribbon-image-separators': 'on',
'ribbon-rotation-step': 10, 'ribbon-rotation-step': 10,
// XXX BUG: for some reason this get's shadowed by base.config... // XXX BUG: for some reason this get's shadowed by base.config...
@ -404,6 +406,11 @@ module.ViewerActions = actions.Actions({
function(){ return this.ribbons.viewer }, function(){ return this.ribbons.viewer },
function(){ return this.config['ribbon-themes'] }, function(){ return this.config['ribbon-themes'] },
function(state){ this.config['ribbon-theme'] = state }) ], function(state){ this.config['ribbon-theme'] = state }) ],
toggleRibbonImageSepators: ['Interface/Theme/Toggle ribbon image separators',
toggler.CSSClassToggler(
function(){ return this.ribbons.viewer },
'ribbon-image-separators',
function(state){ this.config['ribbon-image-separators'] = state }) ],
/* /*
@ -1003,6 +1010,8 @@ module.Viewer = core.ImageGridFeatures.Feature({
&& this.toggleTheme(this.config.theme) && this.toggleTheme(this.config.theme)
this.config['ribbon-theme'] this.config['ribbon-theme']
&& this.toggleRibbonTheme(this.config['ribbon-theme']) && this.toggleRibbonTheme(this.config['ribbon-theme'])
this.config['ribbon-image-separators']
&& this.toggleRibbonImageSepators(this.config['ribbon-image-separators'])
// center viewer on resize events... // center viewer on resize events...
if(!this.__viewer_resize){ if(!this.__viewer_resize){

View File

@ -576,12 +576,21 @@ var RibbonsPrototype = {
// //
// XXX this might break when no images are loaded and proportions // XXX this might break when no images are loaded and proportions
// are not square... // are not square...
getVisibleImageSize: function(dim, scale, img){ getVisibleImageSize: function(dim, scale, img, force){
dim = dim == null ? 'width' : dim dim = dim == null ? 'width' : dim
img = img || this.viewer.find(IMAGE) img = img || this.viewer.find(IMAGE)
// if no images are loaded create one temporarily....
var tmp var tmp
// // XXX size cache -- not sure if this needs to be cached...
// var res = (this.__visible_image_size_cache || {})[dim]
//
// if(this.__visible_image_size_cache == false
// || img.length > 0
// || force
// || res == null){
// if no images are loaded create one temporarily....
if(img.length == 0){ if(img.length == 0){
img = tmp = this.createImage('__tmp_image__') img = tmp = this.createImage('__tmp_image__')
.css({ .css({
@ -610,6 +619,14 @@ var RibbonsPrototype = {
: dim == 'max' ? Math.max(parseFloat(css.height), parseFloat(css.width)) : dim == 'max' ? Math.max(parseFloat(css.height), parseFloat(css.width))
: dim == 'min' ? Math.min(parseFloat(css.height), parseFloat(css.width)) : dim == 'min' ? Math.min(parseFloat(css.height), parseFloat(css.width))
: null : null
// // XXX size cache -- not sure if this needs to be cached...
// if(this.__visible_image_size_cache != false){
// var cache = this.__visible_image_size_cache = this.__visible_image_size_cache || {}
// cache[dim] = res
// }
// }
// get size for given scale... // get size for given scale...
res = res ? res * scale : res res = res ? res * scale : res
@ -1385,7 +1402,7 @@ var RibbonsPrototype = {
}) })
} }
// if not images data defined drop out... // if no images data defined drop out...
if(that.images == null){ if(that.images == null){
return image[0] return image[0]
} }
@ -1447,7 +1464,11 @@ var RibbonsPrototype = {
} }
// NOTE: this only has effect on non-square image blocks... // NOTE: this only has effect on non-square image blocks...
// XXX this needs the loaded image, thus should be done right after preview loading... // XXX this needs the loaded image, thus should be done right
// after preview loading...
// XXX preview loading is async, is this the right
// place for this??
// ...this is also done in .rotateImage(..) above...
that.correctImageProportionsForRotation(image) that.correctImageProportionsForRotation(image)
// marks and other indicators... // marks and other indicators...
@ -1548,6 +1569,7 @@ var RibbonsPrototype = {
$(unload_marks) $(unload_marks)
.remove() .remove()
var images = []
$(gids).each(function(i, gid){ $(gids).each(function(i, gid){
// support for sparse ribbons... // support for sparse ribbons...
if(gid == null){ if(gid == null){
@ -1590,9 +1612,12 @@ var RibbonsPrototype = {
} }
} }
that.updateImage(img) images.push(img[0])
}) })
// XXX this appears to be the bottleneck on large numbers of images...
this.updateImage($(images))
if(place){ if(place){
this.placeRibbon(r, this.viewer.find(RIBBON).length) this.placeRibbon(r, this.viewer.find(RIBBON).length)
} }
@ -2199,6 +2224,8 @@ var RibbonsPrototype = {
// //
// NOTE: this is not needed for square image blocks. // NOTE: this is not needed for square image blocks.
// NOTE: if an image block is square, this will remove the margins. // NOTE: if an image block is square, this will remove the margins.
//
// XXX this does the same job as features/ui-single-image.js' .updateImageProportions(..)
correctImageProportionsForRotation: function(images){ correctImageProportionsForRotation: function(images){
// XXX // XXX
var W = this.viewer.innerWidth() var W = this.viewer.innerWidth()