wip
[fanfix.git] / src / be / nikiroo / fanfix / reader / tui / TuiReaderMainWindow.java
index 1fa6d8b6e19a42b0752b8afe05c4626c89507fba..b54d2cb695e45f87baf1ef70f9cf66aa01684a5b 100644 (file)
@@ -2,14 +2,14 @@ package be.nikiroo.fanfix.reader.tui;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import jexer.TAction;
-import jexer.TCommand;
 import jexer.TFileOpenBox.Type;
-import jexer.TKeypress;
 import jexer.TList;
 import jexer.TWindow;
+import jexer.event.TCommandEvent;
 import jexer.event.TMenuEvent;
 import be.nikiroo.fanfix.Instance;
 import be.nikiroo.fanfix.data.MetaData;
@@ -43,11 +43,28 @@ class TuiReaderMainWindow extends TWindow {
 
                this.reader = reader;
 
-               maximize();
-
                listKeys = new ArrayList<MetaData>();
                listItems = new ArrayList<String>();
-               list = addList(listItems, 0, 0, getWidth(), getHeight(), new TAction() {
+
+               // TODO size + onResize
+
+               
+
+               addLabel("Search: ", 5, 3);
+               addField(15, 3, 5, true);
+               
+               addLabel("Sort by: ", 5, 1);
+               // -1 = no default index (0 means first,...) 1=height when visible, null
+               // = action
+               List<String> data = Arrays.asList("(show all)", "Source", "Name", "Author");
+               // must be last so to be able to draw over the rest
+               // TODO: make it so we cannot add manual entries
+               // TODO: how to select the item via keyboard? why double-click via mouse?
+               addComboBox(15, 1, 12,
+                               data, 0, Math.min(data.size()+1,getHeight()-1-1),
+                               null);
+
+               list = addList(listItems, 0, 7, getWidth(), getHeight(), new TAction() {
                        @Override
                        public void DO() {
                                MetaData meta = getSelectedMeta();
@@ -58,8 +75,7 @@ class TuiReaderMainWindow extends TWindow {
                });
 
                // TODO: add the current "source/type" or filter
-               statusBar = newStatusBar("Library");
-               statusBar.addShortcutKeypress(TKeypress.kbF10, TCommand.cmExit, "Exit");
+               reader.setStatusBar(this, "Library");
 
                // TODO: remove when not used anymore
 
@@ -165,6 +181,16 @@ class TuiReaderMainWindow extends TWindow {
                return String.format("%5s: %s", meta.getLuid(), meta.getTitle());
        }
 
+       @Override
+       public void onCommand(TCommandEvent command) {
+               if (command.getCmd().equals(TuiReaderApplication.CMD_EXIT)) {
+                       TuiReaderApplication.close(this);
+               } else {
+                       // Handle our own event if needed here
+                       super.onCommand(command);
+               }
+       }
+
        @Override
        public void onMenu(TMenuEvent menu) {
                MetaData meta = getSelectedMeta();