1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 19:42:17 +02:00

fill mode option

This commit is contained in:
Nikolay Pultsin 2014-08-30 15:48:32 +01:00
parent a47e5b1d3a
commit 7e7c4149ba
9 changed files with 54 additions and 17 deletions

View file

@ -622,6 +622,16 @@
<node name="leather" value="Leather"/>
<node name="sepia" value="Sepia"/>
<node name="wood" value="Wood"/>
<node name="paper" value="Paper"/>
<node name="papirus" value="Papirus"/>
</node>
<node name="fillMode" value="Fill mode">
<node name="tile" value="Tile"/>
<node name="tileMirror" value="Mirrored tile"/>
<node name="fullscreen" value="Full screen"/>
<node name="stretch" value="Stretch to fill screen"/>
<node name="tileVertically" value="Stretch horizontally, tile vertically"/>
<node name="tileHorizontally" value="Stretch vertically, tile horizontally"/>
</node>
<node name="selectionBackground" value="Selection background"/>
<node name="selectionForeground" value="Selected text"/>

View file

@ -449,13 +449,27 @@ public class PreferenceActivity extends ZLPreferenceActivity {
final Screen colorsScreen = createPreferenceScreen("colors");
final PreferenceSet backgroundSet = new PreferenceSet.Enabler() {
@Override
protected Boolean detectState() {
return profile.WallpaperOption.getValue().startsWith("/");
}
};
myBackgroundPreference = new BackgroundPreference(
this,
profile,
colorsScreen.Resource.getResource("background"),
BACKGROUND_REQUEST_CODE
);
) {
@Override
public void update(Intent data) {
super.update(data);
backgroundSet.run();
}
};
colorsScreen.addPreference(myBackgroundPreference);
backgroundSet.add(colorsScreen.addOption(profile.FillModeOption, "fillMode"));
backgroundSet.run();
colorsScreen.addOption(profile.HighlightingOption, "highlighting");
colorsScreen.addOption(profile.RegularTextOption, "text");

View file

@ -405,10 +405,10 @@ public final class FBView extends ZLTextView {
}
@Override
public ZLPaintContext.WallpaperMode getWallpaperMode() {
public ZLPaintContext.FillMode getFillMode() {
return getWallpaperFile() instanceof ZLResourceFile
? ZLPaintContext.WallpaperMode.TILE_MIRROR
: ZLPaintContext.WallpaperMode.TILE;
? ZLPaintContext.FillMode.tileMirror
: myViewOptions.getColorProfile().FillModeOption.getValue();
}
@Override
@ -497,7 +497,7 @@ public final class FBView extends ZLTextView {
public synchronized void paint(ZLPaintContext context) {
final ZLFile wallpaper = getWallpaperFile();
if (wallpaper != null) {
context.clear(wallpaper, getWallpaperMode());
context.clear(wallpaper, getFillMode());
} else {
context.clear(getBackgroundColor());
}

View file

@ -23,6 +23,7 @@ import java.util.*;
import org.geometerplus.zlibrary.core.util.ZLColor;
import org.geometerplus.zlibrary.core.options.*;
import org.geometerplus.zlibrary.core.view.ZLPaintContext;
public class ColorProfile {
public static final String DAY = "defaultLight";
@ -56,6 +57,7 @@ public class ColorProfile {
public final String Name;
public final ZLStringOption WallpaperOption;
public final ZLEnumOption<ZLPaintContext.FillMode> FillModeOption;
public final ZLColorOption BackgroundOption;
public final ZLColorOption SelectionBackgroundOption;
public final ZLColorOption SelectionForegroundOption;
@ -67,6 +69,8 @@ public class ColorProfile {
private ColorProfile(String name, ColorProfile base) {
this(name);
WallpaperOption.setValue(base.WallpaperOption.getValue());
FillModeOption.setValue(base.FillModeOption.getValue());
BackgroundOption.setValue(base.BackgroundOption.getValue());
SelectionBackgroundOption.setValue(base.SelectionBackgroundOption.getValue());
SelectionForegroundOption.setValue(base.SelectionForegroundOption.getValue());
@ -86,6 +90,8 @@ public class ColorProfile {
if (NIGHT.equals(name)) {
WallpaperOption =
new ZLStringOption("Colors", name + ":Wallpaper", "");
FillModeOption =
new ZLEnumOption<ZLPaintContext.FillMode>(name, "FillMode", ZLPaintContext.FillMode.tile);
BackgroundOption =
createOption(name, "Background", 0, 0, 0);
SelectionBackgroundOption =
@ -105,6 +111,8 @@ public class ColorProfile {
} else {
WallpaperOption =
new ZLStringOption("Colors", name + ":Wallpaper", "wallpapers/sepia.jpg");
FillModeOption =
new ZLEnumOption<ZLPaintContext.FillMode>(name, "FillMode", ZLPaintContext.FillMode.tile);
BackgroundOption =
createOption(name, "Background", 255, 255, 255);
SelectionBackgroundOption =

View file

@ -31,7 +31,7 @@ final class DummyPaintContext extends ZLPaintContext {
}
@Override
public void clear(ZLFile wallpaperFile, WallpaperMode mode) {
public void clear(ZLFile wallpaperFile, FillMode mode) {
}
@Override

View file

@ -32,11 +32,16 @@ abstract public class ZLPaintContext {
protected ZLPaintContext() {
}
public static enum WallpaperMode {
TILE,
TILE_MIRROR
public enum FillMode {
tile,
tileMirror,
fullscreen,
stretch,
tileVertically,
tileHorizontally
}
abstract public void clear(ZLFile wallpaperFile, WallpaperMode mode);
abstract public void clear(ZLFile wallpaperFile, FillMode mode);
abstract public void clear(ZLColor color);
abstract public ZLColor getBackgroundColor();

View file

@ -450,7 +450,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
setContext(context);
final ZLFile wallpaper = getWallpaperFile();
if (wallpaper != null) {
context.clear(wallpaper, getWallpaperMode());
context.clear(wallpaper, getFillMode());
} else {
context.clear(getBackgroundColor());
}

View file

@ -85,7 +85,7 @@ abstract class ZLTextViewBase extends ZLView {
public abstract boolean twoColumnView();
public abstract ZLFile getWallpaperFile();
public abstract ZLPaintContext.WallpaperMode getWallpaperMode();
public abstract ZLPaintContext.FillMode getFillMode();
public abstract ZLColor getBackgroundColor();
public abstract ZLColor getSelectionBackgroundColor();
public abstract ZLColor getSelectionForegroundColor();

View file

@ -81,7 +81,7 @@ public final class ZLAndroidPaintContext extends ZLPaintContext {
private static ZLFile ourWallpaperFile;
private static Bitmap ourWallpaper;
@Override
public void clear(ZLFile wallpaperFile, WallpaperMode mode) {
public void clear(ZLFile wallpaperFile, FillMode mode) {
if (!wallpaperFile.equals(ourWallpaperFile)) {
ourWallpaperFile = wallpaperFile;
ourWallpaper = null;
@ -89,7 +89,7 @@ public final class ZLAndroidPaintContext extends ZLPaintContext {
final Bitmap fileBitmap =
BitmapFactory.decodeStream(wallpaperFile.getInputStream());
switch (mode) {
case TILE_MIRROR:
case tileMirror:
{
final int w = fileBitmap.getWidth();
final int h = fileBitmap.getHeight();
@ -111,7 +111,7 @@ public final class ZLAndroidPaintContext extends ZLPaintContext {
ourWallpaper = wallpaper;
break;
}
case TILE:
case tile:
ourWallpaper = fileBitmap;
break;
}
@ -124,7 +124,7 @@ public final class ZLAndroidPaintContext extends ZLPaintContext {
final int w = ourWallpaper.getWidth();
final int h = ourWallpaper.getHeight();
for (int cw = 0, iw = 1; cw < myWidth; cw += w, ++iw) {
for (int ch = 0, ih = 1; ch < myHeight; ch += h, ++ih) {
for (int ch = 0, ih = 1; ch < myHeight + 100; ch += h, ++ih) {
myCanvas.drawBitmap(ourWallpaper, cw, ch, myFillPaint);
}
}
@ -137,7 +137,7 @@ public final class ZLAndroidPaintContext extends ZLPaintContext {
public void clear(ZLColor color) {
myBackgroundColor = color;
myFillPaint.setColor(ZLAndroidColorUtil.rgb(color));
myCanvas.drawRect(0, 0, myWidth + myScrollbarWidth, myHeight, myFillPaint);
myCanvas.drawRect(0, 0, myWidth + myScrollbarWidth, myHeight + 100, myFillPaint);
}
@Override