Beispiel #1
0
// Eigentliche Auswahl beim Rahmenziehen:
// Zur Auswahl reicht es, wenn ein kleiner Zipfel eines Objekts im Rahmen ist.
bool Editor::get_overlap_at_2
(const EdGraphic& g, const int x1, const int y1, const int x2, const int y2)
{
    const int top_x = g.get_x() + g.get_selbox_x();
    const int top_y = g.get_y() + g.get_selbox_y();
    const int bot_x = top_x     + g.get_selbox_xl();
    const int bot_y = top_y     + g.get_selbox_yl();
    if (bot_x > x1 && bot_y > y1 && top_x <= x2 && top_y <= y2)
         return true;
    else return false;
}
Beispiel #2
0
void Editor::update_bar_text()
{
    if (Api::Manager::get_focus() != 0) return;

    bar.set_text(gloB->empty_string);
    std::ostringstream str;

    // Describe the panel buttons, this is most important.
    for (unsigned i = 0; i < panel.size(); ++i)
     if (panel[i].is_mouse_here()) {
        str << Language::editor_button[i];
        int key   = panel[i].get_hotkey();
        bool hold = false;
        if (i>=GRID_2 && i<=GRID_16) key = useR->key_ed_grid;
        else if (i == SELECT_FRAME)  key = useR->key_ed_sel_frame;
        else if (i == SELECT_ADD)    key = useR->key_ed_sel_add;
        else if (i == SELECT_BACK)   key = useR->key_ed_background;
        else if (i == SELECT_FRONT)  key = useR->key_ed_foreground;
        if (i == SELECT_BACK || i == SELECT_FRONT) hold = true;
        if (key) {
            str << " "
             << (hold ? Language::editor_hotkey_hold : Language::editor_hotkey)
             << " [" << Help::scancode_to_string(key) << "]";
        }
    }

    // Describe the current selection/hover info only if no panel icon is to
    // be described.
    if (str.str().empty()) {
        EdGraphic* tarinf = 0;
        if      (hover.size()     == 1) tarinf = &*hover.begin()->o;
        else if (selection.size() == 1) tarinf = &*selection.begin()->o;

        int add_movekey_info = 0;

        if (hover.size() > 2) {
            // display "n objects about to be selected"
            str << hover.size() << " " << Language::editor_bar_hover;
        }
        else if (tarinf) {
            // exactly one item is selected or about to be selected
            str << ObjLib::get_filename(tarinf->get_object());

            std::string flags;
            if (tarinf->get_mirror())                        flags += 'f';
            for (int i = 0; i < tarinf->get_rotation(); ++i) flags += 'r';
            if (tarinf->get_mode() == Cutbit::DARK_EDITOR)   flags += 'd';
            if (tarinf->get_mode() == Cutbit::NOOW_EDITOR)   flags += 'n';
            if (! flags.empty()) str << " [" << flags << "]";

            str << " " << Language::editor_bar_at
             << " (" << tarinf->get_x() << ", " << tarinf->get_y() << ")"
             << " (" << Help::int_to_hex(tarinf->get_x())
             << ", " << Help::int_to_hex(tarinf->get_y()) << ")";
        }
        else if (! selection.empty()) {
            // display "n objects are currently selected"
            str << selection.size() << " " << Language::editor_bar_selection;
            add_movekey_info = 1;
        }
        else {
            // nothing is selected or hovered above
            add_movekey_info = 2;
        }

        if (add_movekey_info > 0) {
            if (! str.str().empty()) str << " ";
            const std::string& beg = (add_movekey_info == 2
                                   ? Language::editor_bar_movekeys_long
                                   : Language::editor_bar_movekeys_short);
            const std::string& mid = Language::editor_bar_movekeys_mid;
            const std::string& end = Language::editor_bar_movekeys_end;
            str
             << beg << Help::scancode_to_string(useR->key_ed_up)
             << mid << Help::scancode_to_string(useR->key_ed_left)
             << mid << Help::scancode_to_string(useR->key_ed_down)
             << mid << Help::scancode_to_string(useR->key_ed_right)
             << end;
        }
    }

    bar.set_text(str.str());
}