I'm working on a simple app. I basically have a GUI made in Glade. I'm using C.
I have on the top a bar about 10 buttons. I want to press, for example, button 1 and I want my low-half screen (which is a box with a fixed and some buttons) to show.
However if a press the button 2 on the top bar I want my lower-half screen to hide that content an replace it with some new one. I know I can do it manually with widget_hide and show one by one, but is there any way I can do it with glade containers?
GtkWidget *btn = ptr[2];
GtkWidget *fx = ptr[1];
GtkWidget *holder = ptr[3];
if(gtk_toggle_button_get_active(btn)){
gtk_fixed_put(holder,fx,0,0);
gtk_widget_show(fx);
}else{
gtk_widget_hide(fx);
}
That's a really basic idea, btn being the button I press, holder being the fixed container inside the box, and fx being the fixed container of the widgets I want to show/hide and replace with other fixed with different widgets.
Kinda hard to explain myself. Basically y press a button for example each button its a different window, like changing a div and it's contents on HTML.
Not sure what design you exactly want. Just thinking from my side: I am having a python example app where I load several windows at init.
...
self.controlwindow = builder.get_object("scoreboard_control_window")
self.viewwindow = builder.get_object("scoreboard_view_window")
self.logdialog = builder.get_object("scoreboard_log_dialog")
self.logoffdialog = builder.get_object("scoreboard_logoff_confirm")
self.logcanceldialog = builder.get_object("scoreboard_logcancel_confirm")
self.resetdialog = builder.get_object("scoreboard_resetconfirm")
self.exitdialog = builder.get_object("scoreboard_exitconfirm")
And by using show/hide like GUI.controlwindow.show() or self.logoffdialog.show() or self.logoffdialog.hide(), I control the pop-up / hiding of dialog and entries windows.
Related
In my Codenameone app i have built a side menu, but i have 2 cosmetic issues with it.
When i swipe from the left and i lift my finger in the screen space, slightly further than the menu finishes, the menu snaps back. It doesn't snap back if i lift my finger in the space the menu will expand to. Is there a way to make the side menu stay on the screen when i swipe?
My main page has a vertically scrollable container. When i open the side menu, it doesn't disable my main page so i am still able to scroll my main page container by moving my finger on the space to the right of the menu. Are we able to disable the main page content by default when the menu is open?
For ref, my menu is along the design of this tutorial, with a very simple example being:
public void start() {
if (current != null) {
current.show();
return;
}
Form hi = new Form("Hi World", BoxLayout.y());
hi.add(new Label("Hi World"));
Toolbar t = new Toolbar();
hi.setToolbar(t);
t.setTitle("Title");
Label logoLabel = new Label("");
logoLabel.setTextPosition(Label.BOTTOM);
logoLabel.setText("label text here");
t.addComponentToSideMenu(logoLabel);
hi.show();
}
Thanks
The point of closing back seems to be hardcoded to a quarter of the screen here: https://github.com/codenameone/CodenameOne/blob/master/CodenameOne/src/com/codename1/ui/Toolbar.java#L1380
There might be other points in the code that implement this logic. It might be possible to change that to make that logic configurable via theme constants. But right now this is hard coded.
In a Codenameone app, I'm trying to develop a carousel with a thumbnail list at the bottom. I've used Tabs control to display files (of diff types like images, video, text, button etc) in carousel style in the center of a form and another Tabs control to display thumbanail images (of the first carousel files) at the bottom of the form. When a user selects a thumbnail image in the bottom carousel, corresponding component should be displayed in the first carousel.
hi.add(BorderLayout.CENTER, mainCarousel);
hi.add(BorderLayout.SOUTH, bottom_tab);
bottom_tab.addSelectionListener((i1, i2) -> {
// bottom_tab.getTabComponentAt(i2).addPointerPressedListener((i) -> {
mainCarousel.getTabComponentAt(i2).setVisible(true);
mainCarousel.getTabComponentAt(i2).repaint();
// });
});
But the component not getting displayed in the central carousel.
Also, I tried to capture the event addPointerPressedListener, but it's not getting fired when I select a thumbnail image.
You can't set tab components to visible/invisible to show/hide them. That won't work. I'm guessing that what you want is a horizontal list for the bottom UI similar to the answer here.
I would suggest using pointer released always. Notice that this will only get delivered to focusable components or the form. To make sure you get the event you can register a pointer release listener on the form.
I've dynamically created a horizontal scrolling list of labels (with icon and bottom text) within a container in a tab.
However, I cannot seem to bind any action to this Label - I want touch, long press, options(commands), drag, etc
If I use Button instead of Label, I cannot seem to use URLImage to grab the icon from a url and save it to storage and use that as the button icon. It always uses only the placeholder from:
Image img = URLImage.createToStorage(placeholder, counter+"_thumbnail", thumbnailURL, URLImage.RESIZE_SCALE);
How do I grab events on the Labels? Here is a snippet of how I'm adding the labels to the container:
Container c = StateMachine.instance.findFirstListContainer();
for(...){
Label l = new Label();
l.setText(title);
l.setIcon(img);
l.setUIID("listItem");
l.setTextPosition(2);
c.addComponent(l);
}
You should use a Button rather than a Label and invoke the setUIID("Label") method.
The reason why you didn't do this is a separate question/issue: https://groups.google.com/d/msg/codenameone-discussions/5HoDEFjB5II/5dc4iKuYNSYJ
I have an off panel menu working perfectly on a site. The user can open and close it using both a navicon or sliding it with the finger.
Right now I have a very nice navicon icon that transitions from Menu Icon to X Icon when is clicked (and opens the menu) and the other way around when is clicked again and the menu closes. Buuut if the user slides the menu open or closed instead of using the navicon, the transition is not triggered, which might lead to confusions on the UX (i.e. the menu being closed, and the navicon showing an X instead of the regular 3 horizontal lines icon).
So, the navicon has right now the following code to trigger the transition:
ng-click="open = !open" ng-class="{'open-mob':open}">
I thought that a nice and easy way to fix this, would be to trigger this "open = !open" every time that the menu is open or closed, as the js from the off panel adds the class slidRight to the main section when the menu is open, and removes it when it is closed.
Being so, is there some straight way to check if the class is there using AngularJS?
Something like if class = slidRight -> "open = !open".
Thanks!!
for those (including me) who could not get their head around Angular's documentation, here is an example which worked for me:
angular.element(myElement).hasClass('my-class');
angular.element(myElement).addClass('new-class');
angular.element(myElement).removeClass('old-class');
hope this help someone ...
Angular uses jqLite's .hasClass() natively.
Read here on the angular docs for more info.
http://docs.angularjs.org/api/angular.element
https://docs.angularjs.org/api/ng/function/angular.element
I just want to create a simple font chooser from button context menu so when I right click on the button it pops-up a list of all available system fonts.
http://msdn.microsoft.com/en-us/library/ms771765(v=vs.85).aspx
Have a look at that. It should give a good example of how to implement it a font selector.
This is how you get all system fonts...
System.Drawing.Text.InstalledFontCollection fonts = new System.Drawing.Text.InstalledFontCollection();
for (int i = 0; i < fonts.Families.Length; i++)
{
Console.WriteLine(fonts.Families[i].Name);
}
Then I would design user control for your font chooser and make it visible from the MouseRightButton_Down event of your button.